FIX: Broken tests

FIX: Broken tests

diff --git a/app/assets/javascripts/discourse/templates/components/reviewable-score.js.es6 b/app/assets/javascripts/discourse/templates/components/reviewable-score.js.es6
index 1a96cb9..fb76ed3 100644
--- a/app/assets/javascripts/discourse/templates/components/reviewable-score.js.es6
+++ b/app/assets/javascripts/discourse/templates/components/reviewable-score.js.es6
@@ -5,7 +5,7 @@ export default Ember.Component.extend({
 
   @computed("rs.score_type.title", "reviewable.target_created_by")
   title(title, targetCreatedBy) {
-    if (targetCreatedBy) {
+    if (title && targetCreatedBy) {
       return title.replace("{{username}}", targetCreatedBy.username);
     }
 
diff --git a/test/javascripts/acceptance/review-test.js.es6 b/test/javascripts/acceptance/review-test.js.es6
index 9259d27..958f6fe 100644
--- a/test/javascripts/acceptance/review-test.js.es6
+++ b/test/javascripts/acceptance/review-test.js.es6
@@ -4,26 +4,26 @@ acceptance("Review", {
   loggedIn: true
 });
 
-// const user = ".reviewable-item[data-reviewable-id=1234]";
-
-// QUnit.test("It returns a list of reviewable items", async assert => {
-//   await visit("/review");
-
-//   assert.ok(find(".reviewable-item").length, "has a list of items");
-//   assert.ok(find(user).length);
-//   assert.ok(
-//     find(`${user}.reviewable-user`).length,
-//     "applies a class for the type"
-//   );
-//   assert.ok(
-//     find(`${user} .reviewable-action.approve`).length,
-//     "creates a button for approve"
-//   );
-//   assert.ok(
-//     find(`${user} .reviewable-action.reject`).length,
-//     "creates a button for reject"
-//   );
-// });
+const user = ".reviewable-item[data-reviewable-id=1234]";
+
+QUnit.test("It returns a list of reviewable items", async assert => {
+  await visit("/review");
+
+  assert.ok(find(".reviewable-item").length, "has a list of items");
+  assert.ok(find(user).length);
+  assert.ok(
+    find(`${user}.reviewable-user`).length,
+    "applies a class for the type"
+  );
+  assert.ok(
+    find(`${user} .reviewable-action.approve`).length,
+    "creates a button for approve"
+  );
+  assert.ok(
+    find(`${user} .reviewable-action.reject`).length,
+    "creates a button for reject"
+  );
+});
 
 QUnit.test("Grouped by topic", async assert => {
   await visit("/review/topics");
@@ -43,105 +43,105 @@ QUnit.test("Settings", async assert => {
   assert.ok(find(".reviewable-settings .saved").length, "it saved");
 });
 
-// QUnit.test("Flag related", async assert => {
-//   await visit("/review");
-
-//   assert.ok(
-//     find(".reviewable-flagged-post .post-contents .username a[href]").length,
-//     "it has a link to the user"
-//   );
-
-//   assert.equal(
-//     find(".reviewable-flagged-post .post-body")
-//       .html()
-//       .trim(),
-//     "<b>cooked content</b>"
-//   );
-
-//   assert.equal(find(".reviewable-flagged-post .reviewable-score").length, 2);
-// });
-
-// QUnit.test("Flag related", async assert => {
-//   await visit("/review/1");
-
-//   assert.ok(
-//     find(".reviewable-flagged-post").length,
-//     "it shows the flagged post"
-//   );
-// });
-
-// QUnit.test("Clicking the buttons triggers actions", async assert => {
-//   await visit("/review");
-//   await click(`${user} .reviewable-action.approve`);
-//   assert.equal(find(user).length, 0, "it removes the reviewable on success");
-// });
-
-// QUnit.test("Editing a reviewable", async assert => {
-//   const topic = ".reviewable-item[data-reviewable-id=4321]";
-//   await visit("/review");
-//   assert.ok(find(`${topic} .reviewable-action.approve`).length);
-//   assert.ok(!find(`${topic} .category-name`).length);
-//   assert.equal(find(`${topic} .discourse-tag:eq(0)`).text(), "hello");
-//   assert.equal(find(`${topic} .discourse-tag:eq(1)`).text(), "world");
-
-//   assert.equal(
-//     find(`${topic} .post-body`)
-//       .text()
-//       .trim(),
-//     "existing body"
-//   );
-
-//   await click(`${topic} .reviewable-action.edit`);
-//   await click(`${topic} .reviewable-action.save-edit`);
-//   assert.ok(
-//     find(`${topic} .reviewable-action.approve`).length,
-//     "saving without changes is a cancel"
-//   );
-//   await click(`${topic} .reviewable-action.edit`);
-
-//   assert.equal(
-//     find(`${topic} .reviewable-action.approve`).length,
-//     0,
-//     "when editing actions are disabled"
-//   );
-
-//   await fillIn(".editable-field.payload-raw textarea", "new raw contents");
-//   await click(`${topic} .reviewable-action.cancel-edit`);
-//   assert.equal(
-//     find(`${topic} .post-body`)
-//       .text()
-//       .trim(),
-//     "existing body",
-//     "cancelling does not update the value"
-//   );
-
-//   await click(`${topic} .reviewable-action.edit`);
-//   let category = selectKit(`${topic} .category-id .select-kit`);
-//   await category.expand();
-//   await category.selectRowByValue("6");
-
-//   let tags = selectKit(`${topic} .payload-tags .mini-tag-chooser`);
-//   await tags.expand();
-//   await tags.fillInFilter("monkey");
-//   await tags.keyboard("enter");
-
-//   await fillIn(".editable-field.payload-raw textarea", "new raw contents");
-//   await click(`${topic} .reviewable-action.save-edit`);
-
-//   assert.equal(find(`${topic} .discourse-tag:eq(0)`).text(), "hello");
-//   assert.equal(find(`${topic} .discourse-tag:eq(1)`).text(), "world");
-//   assert.equal(find(`${topic} .discourse-tag:eq(2)`).text(), "monkey");
-
-//   assert.equal(
-//     find(`${topic} .post-body`)
-//       .text()
-//       .trim(),
-//     "new raw contents"
-//   );
-//   assert.equal(
-//     find(`${topic} .category-name`)
-//       .text()
-//       .trim(),
-//     "support"
-//   );
-// });
+QUnit.test("Flag related", async assert => {
+  await visit("/review");
+
+  assert.ok(
+    find(".reviewable-flagged-post .post-contents .username a[href]").length,
+    "it has a link to the user"
+  );
+
+  assert.equal(
+    find(".reviewable-flagged-post .post-body")
+      .html()
+      .trim(),
+    "<b>cooked content</b>"
+  );
+
+  assert.equal(find(".reviewable-flagged-post .reviewable-score").length, 2);
+});
+
+QUnit.test("Flag related", async assert => {
+  await visit("/review/1");
+
+  assert.ok(
+    find(".reviewable-flagged-post").length,
+    "it shows the flagged post"
+  );
+});
+
+QUnit.test("Clicking the buttons triggers actions", async assert => {
+  await visit("/review");
+  await click(`${user} .reviewable-action.approve`);
+  assert.equal(find(user).length, 0, "it removes the reviewable on success");
+});
+
+QUnit.test("Editing a reviewable", async assert => {
+  const topic = ".reviewable-item[data-reviewable-id=4321]";
+  await visit("/review");
+  assert.ok(find(`${topic} .reviewable-action.approve`).length);
+  assert.ok(!find(`${topic} .category-name`).length);
+  assert.equal(find(`${topic} .discourse-tag:eq(0)`).text(), "hello");
+  assert.equal(find(`${topic} .discourse-tag:eq(1)`).text(), "world");
+
+  assert.equal(
+    find(`${topic} .post-body`)
+      .text()
+      .trim(),
+    "existing body"
+  );
+
+  await click(`${topic} .reviewable-action.edit`);
+  await click(`${topic} .reviewable-action.save-edit`);
+  assert.ok(
+    find(`${topic} .reviewable-action.approve`).length,
+    "saving without changes is a cancel"
+  );
+  await click(`${topic} .reviewable-action.edit`);
+
+  assert.equal(
+    find(`${topic} .reviewable-action.approve`).length,
+    0,
+    "when editing actions are disabled"
+  );
+
+  await fillIn(".editable-field.payload-raw textarea", "new raw contents");
+  await click(`${topic} .reviewable-action.cancel-edit`);
+  assert.equal(
+    find(`${topic} .post-body`)
+      .text()
+      .trim(),
+    "existing body",
+    "cancelling does not update the value"
+  );
+
+  await click(`${topic} .reviewable-action.edit`);
+  let category = selectKit(`${topic} .category-id .select-kit`);
+  await category.expand();
+  await category.selectRowByValue("6");
+

[... diff too long, it was truncated ...]

GitHub sha: 4552d866

2 Likes