FIX: Flaky tests

FIX: Flaky tests

We had acceptance tests that were testing the contents of the post stream preview, not the contents of the eventual topic itself.

This became apparent when I introduced a new promise which caused the tests to finish waiting for work properly. Before that, it was up to the speed of the execution, very spooky!

diff --git a/test/javascripts/acceptance/category-hashtag-test.js.es6 b/test/javascripts/acceptance/category-hashtag-test.js.es6
index c2ffdcd..e5bbdf3 100644
--- a/test/javascripts/acceptance/category-hashtag-test.js.es6
+++ b/test/javascripts/acceptance/category-hashtag-test.js.es6
@@ -7,6 +7,7 @@ QUnit.test("category hashtag is cooked properly", async assert => {
   await click("#topic-footer-buttons .btn.create");
 
   await fillIn(".d-editor-input", "this is a category hashtag #bug");
+
   // TODO: Test that the autocomplete shows
   assert.equal(
     find(".d-editor-preview:visible")
@@ -14,12 +15,4 @@ QUnit.test("category hashtag is cooked properly", async assert => {
       .trim(),
     '<p>this is a category hashtag <a href="/c/bugs" class="hashtag">#<span>bug</span></a></p>'
   );
-
-  await click("#reply-control .btn.create");
-  assert.equal(
-    find(".topic-post:last .cooked p")
-      .html()
-      .trim(),
-    'this is a category hashtag <a href="/c/bugs" class="hashtag">#<span>bug</span></a>'
-  );
 });
diff --git a/test/javascripts/acceptance/composer-test.js.es6 b/test/javascripts/acceptance/composer-test.js.es6
index 26ccba2..5123276 100644
--- a/test/javascripts/acceptance/composer-test.js.es6
+++ b/test/javascripts/acceptance/composer-test.js.es6
@@ -249,7 +249,7 @@ QUnit.test("Create a Reply", async assert => {
   await click("#reply-control button.create");
   assert.equal(
     find(".cooked:last p").text(),
-    "this is the content of my reply"
+    "If you use gettext format you could leverage Launchpad 13 translations and the community behind it."
   );
 });
 
@@ -266,7 +266,7 @@ QUnit.test("Posting on a different topic", async assert => {
   await click(".btn-reply-here");
   assert.equal(
     find(".cooked:last p").text(),
-    "this is the content for a different topic"
+    "If you use gettext format you could leverage Launchpad 13 translations and the community behind it."
   );
 });
 
diff --git a/test/javascripts/acceptance/emoji-test.js.es6 b/test/javascripts/acceptance/emoji-test.js.es6
index 39dc376..087a923 100644
--- a/test/javascripts/acceptance/emoji-test.js.es6
+++ b/test/javascripts/acceptance/emoji-test.js.es6
@@ -14,14 +14,6 @@ QUnit.test("emoji is cooked properly", async assert => {
       .trim(),
     `<p>this is an emoji <img src="/images/emoji/emoji_one/blonde_woman.png?v=${v}" title=":blonde_woman:" class="emoji" alt=":blonde_woman:"></p>`
   );
-
-  await click("#reply-control .btn.create");
-  assert.equal(
-    find(".topic-post:last .cooked p")
-      .html()
-      .trim(),
-    `this is an emoji <img src="/images/emoji/emoji_one/blonde_woman.png?v=${v}" title=":blonde_woman:" class="emoji" alt=":blonde_woman:">`
-  );
 });
 
 QUnit.test("skin toned emoji is cooked properly", async assert => {
diff --git a/test/javascripts/acceptance/tag-hashtag-test.js.es6 b/test/javascripts/acceptance/tag-hashtag-test.js.es6
index 1e3e468..b640d2c 100644
--- a/test/javascripts/acceptance/tag-hashtag-test.js.es6
+++ b/test/javascripts/acceptance/tag-hashtag-test.js.es6
@@ -24,12 +24,4 @@ QUnit.test("tag is cooked properly", async assert => {
       .trim(),
     '<p>this is a tag hashtag <a href="/tags/monkey" class="hashtag">#<span>monkey</span></a></p>'
   );
-
-  await click("#reply-control .btn.create");
-  assert.equal(
-    find(".topic-post:last .cooked")
-      .html()
-      .trim(),
-    '<p>this is a tag hashtag <a href="/tags/monkey" class="hashtag">#<span>monkey</span></a></p>'
-  );
 });
diff --git a/test/javascripts/helpers/create-pretender.js.es6 b/test/javascripts/helpers/create-pretender.js.es6
index cb45974..d05a79a 100644
--- a/test/javascripts/helpers/create-pretender.js.es6
+++ b/test/javascripts/helpers/create-pretender.js.es6
@@ -199,7 +199,9 @@ export default function() {
 
     this.get("/t/280.json", () => response(fixturesByUrl["/t/280/1.json"]));
     this.get("/t/34.json", () => response(fixturesByUrl["/t/34/1.json"]));
-    this.get("/t/280/20.json", () => response(fixturesByUrl["/t/280/1.json"]));
+    this.get("/t/280/:post_number.json", () =>
+      response(fixturesByUrl["/t/280/1.json"])
+    );
     this.get("/t/28830.json", () => response(fixturesByUrl["/t/28830/1.json"]));
     this.get("/t/9.json", () => response(fixturesByUrl["/t/9/1.json"]));
     this.get("/t/12.json", () => response(fixturesByUrl["/t/12/1.json"]));

GitHub sha: 342bbe66

1 Like