FIX: Randomly failing QUnit test.

FIX: Randomly failing QUnit test.

The post variable can be an actual post object or a new Placeholder("post-placeholder") which does not define the function get.

  • QUNIT_SEED=11414431645131211212599424733847938795
From c92c56d98642d932cb5a4227fefa3ca6e2774f6e Mon Sep 17 00:00:00 2001
From: Guo Xiang Tan <tgx_world@hotmail.com>
Date: Tue, 27 Nov 2018 15:58:00 +0800
Subject: [PATCH] FIX: Randomly failing QUnit test.

The `post` variable can be an actual post object or a `new Placeholder("post-placeholder")` which does not define the function `get`.

* QUNIT_SEED=11414431645131211212599424733847938795

diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6
index d30dfee..f7863e1 100644
--- a/app/assets/javascripts/discourse/controllers/topic.js.es6
+++ b/app/assets/javascripts/discourse/controllers/topic.js.es6
@@ -305,7 +305,7 @@ export default Ember.Controller.extend(BufferedContent, {
       const postStream = this.get("model.postStream");
       const firstLoadedPost = postStream.get("posts.firstObject");
 
-      if (post.get("post_number") === 1) {
+      if (post.get && post.get("post_number") === 1) {
         return;
       }

GitHub

2 Likes

I feel we should add a tiny test for this, cause that code is very non obvious and someone may remove it one day.

1 Like

Done in DEV: Add tests for c92c56d98642d932cb5a4227fefa3ca6e2774f6e. · discourse/discourse@ceaf234 · GitHub :slight_smile:

2 Likes