DEV: Update tests (#177)

DEV: Update tests (#177)

Included:

  • DEV: Add “assigned topic” test
  • DEV: Update and re-enable disabled test
  • DEV: Add missing imports
  • DEV: Fix typos
  • DEV: Don’t use find()
  • DEV: Use the hbs helper
diff --git a/test/javascripts/acceptance/assign-disabled-test.js.es6 b/test/javascripts/acceptance/assign-disabled-test.js.es6
index 1f2310c..368d5f1 100644
--- a/test/javascripts/acceptance/assign-disabled-test.js.es6
+++ b/test/javascripts/acceptance/assign-disabled-test.js.es6
@@ -3,7 +3,9 @@ import {
   acceptance,
   updateCurrentUser,
 } from "discourse/tests/helpers/qunit-helpers";
+import { visit } from "@ember/test-helpers";
 import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
+import { test } from "qunit";
 
 acceptance("Assign disabled mobile", function (needs) {
   needs.user();
diff --git a/test/javascripts/acceptance/assign-enabled-test.js.es6 b/test/javascripts/acceptance/assign-enabled-test.js.es6
index ac09694..b0e4491 100644
--- a/test/javascripts/acceptance/assign-enabled-test.js.es6
+++ b/test/javascripts/acceptance/assign-enabled-test.js.es6
@@ -1,9 +1,12 @@
 import selectKit from "discourse/tests/helpers/select-kit-helper";
 import {
   acceptance,
+  exists,
   updateCurrentUser,
 } from "discourse/tests/helpers/qunit-helpers";
+import { click, visit } from "@ember/test-helpers";
 import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
+import { test } from "qunit";
 
 acceptance("Assign mobile", function (needs) {
   needs.user();
diff --git a/test/javascripts/acceptance/assigned-topic-test.js.es6 b/test/javascripts/acceptance/assigned-topic-test.js.es6
new file mode 100644
index 0000000..127daf2
--- /dev/null
+++ b/test/javascripts/acceptance/assigned-topic-test.js.es6
@@ -0,0 +1,53 @@
+import { test } from "qunit";
+import {
+  acceptance,
+  exists,
+  query,
+  updateCurrentUser,
+} from "discourse/tests/helpers/qunit-helpers";
+import { visit } from "@ember/test-helpers";
+import { cloneJSON } from "discourse-common/lib/object";
+import topicFixtures from "discourse/tests/fixtures/topic";
+
+acceptance("Assigned topic", function (needs) {
+  needs.user();
+  needs.settings({
+    assign_enabled: true,
+    tagging_enabled: true,
+    assigns_user_url_path: "/",
+  });
+
+  needs.pretender((server, helper) => {
+    server.get("/t/44.json", () => {
+      let topic = cloneJSON(topicFixtures["/t/28830/1.json"]);
+      topic["assigned_to_user"] = {
+        username: "eviltrout",
+        name: "Robin Ward",
+        avatar_template:
+          "/letter_avatar/eviltrout/{size}/3_f9720745f5ce6dfc2b5641fca999d934.png",
+        assigned_at: "2021-06-13T16:33:14.189Z",
+      };
+      return helper.response(topic);
+    });
+  });
+
+  test("Shows assignment info", async (assert) => {
+    updateCurrentUser({ can_assign: true });
+    await visit("/t/assignment-topic/44");
+
+    assert.equal(
+      query("#topic-title .assigned-to").innerText,
+      "eviltrout",
+      "shows assignment in the header"
+    );
+    assert.equal(
+      query("#post_1 .assigned-to-username").innerText,
+      "eviltrout",
+      "shows assignment in the first post"
+    );
+    assert.ok(
+      exists("#topic-footer-button-assign .unassign-label"),
+      "shows unassign button at the bottom of the topic"
+    );
+  });
+});
diff --git a/test/javascripts/acceptance/group-assignments-test.js.es6 b/test/javascripts/acceptance/group-assignments-test.js.es6
index 6fc53c5..b196c98 100644
--- a/test/javascripts/acceptance/group-assignments-test.js.es6
+++ b/test/javascripts/acceptance/group-assignments-test.js.es6
@@ -1,6 +1,8 @@
 import { acceptance, count } from "discourse/tests/helpers/qunit-helpers";
+import { visit } from "@ember/test-helpers";
 import AssignedTopics from "../fixtures/assigned-group-assignments-fixtures";
 import GroupMembers from "../fixtures/group-members-fixtures";
+import { test } from "qunit";
 
 acceptance("GroupAssignments", function (needs) {
   needs.user();
@@ -19,13 +21,11 @@ acceptance("GroupAssignments", function (needs) {
 
   test("Group Assignments Everyone", async (assert) => {
     await visit("/g/discourse/assigned");
-    assert.equal(currentPath(), "group.assigned.show");
     assert.equal(count(".topic-list-item"), 1);
   });
 
   test("Group Assignments Ahmedgagan", async (assert) => {
     await visit("/g/discourse/assigned/ahmedgagan6");
-    assert.equal(currentPath(), "group.assigned.show");
     assert.equal(count(".topic-list-item"), 1);
   });
 });
diff --git a/test/javascripts/acceptance/quick-access-assignments-test.js.es6 b/test/javascripts/acceptance/quick-access-assignments-test.js.es6
index cdf8f31..f00ad02 100644
--- a/test/javascripts/acceptance/quick-access-assignments-test.js.es6
+++ b/test/javascripts/acceptance/quick-access-assignments-test.js.es6
@@ -3,7 +3,9 @@ import {
   query,
   updateCurrentUser,
 } from "discourse/tests/helpers/qunit-helpers";
+import { click, currentURL, visit } from "@ember/test-helpers";
 import AssignedTopics from "../fixtures/assigned-topics-fixtures";
+import { test } from "qunit";
 
 acceptance("Quick access assignments panel", function (needs) {
   needs.user();
@@ -29,8 +31,8 @@ acceptance("Quick access assignments panel", function (needs) {
 
     await click(".widget-button.assigned");
     assert.equal(
-      currentPath(),
-      "user.userActivity.assigned",
+      currentURL(),
+      "/u/eviltrout/activity/assigned",
       "a second click should redirect to the full assignments page"
     );
   });
diff --git a/test/javascripts/acceptance/search-full-test.js.es6 b/test/javascripts/acceptance/search-full-test.js.es6
index 300e0b2..00344c4 100644
--- a/test/javascripts/acceptance/search-full-test.js.es6
+++ b/test/javascripts/acceptance/search-full-test.js.es6
@@ -1,14 +1,28 @@
 import selectKit from "discourse/tests/helpers/select-kit-helper";
 import {
   acceptance,
+  query,
   updateCurrentUser,
-  waitFor,
 } from "discourse/tests/helpers/qunit-helpers";
-import { skip, test } from "qunit";
+import { fillIn, visit } from "@ember/test-helpers";
+import { test } from "qunit";
 
 acceptance("Search - Full Page", function (needs) {
   needs.settings({ assign_enabled: true });
   needs.user();
+  needs.pretender((server, helper) => {
+    server.get("/u/search/users", () => {
+      return helper.response({
+        users: [
+          {
+            username: "admin",
+            name: "admin",
+            avatar_template: "/images/avatar.png",
+          },
+        ],
+      });
+    });
+  });
 
   test("update in:assigned filter through advanced search ui", async (assert) => {
     updateCurrentUser({ can_assign: true });
@@ -25,9 +39,9 @@ acceptance("Search - Full Page", function (needs) {
       'has "are assigned" populated'
     );
     assert.equal(
-      find(".search-query").val(),
+      query(".search-query").value,
       "none in:assigned",
-      'has updated search term to "none in:assinged"'
+      'has updated search term to "none in:assigned"'
     );
   });
 
@@ -46,46 +60,32 @@ acceptance("Search - Full Page", function (needs) {
       'has "are unassigned" populated'
     );
     assert.equal(
-      find(".search-query").val(),
+      query(".search-query").value,
       "none in:unassigned",
-      'has updated search term to "none in:unassinged"'
+      'has updated search term to "none in:unassigned"'
     );
   });
 
-  skip("update assigned to through advanced search ui", async (assert) => {
+  test("update assigned to through advanced search ui", async (assert) => {
     updateCurrentUser({ can_assign: true });
+    const assignedField = selectKit(".assigned-advanced-search .select-kit");
+
     await visit("/search");
-    await fillIn(".search-query", "none");
-    await fillIn(".search-advanced-options .user-selector-assigned", "admin");
-    await click(".search-advanced-options .user-selector-assigned");
-    await keyEvent(
-      ".search-advanced-options .user-selector-assigned",
-      "keydown",
-      8
-    );
-    waitFor(assert, async () => {
-      assert.ok(
-        visible(".search-advanced-options .autocomplete"),

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

GitHub sha: 53d3bda543dedee99a5e148fe9e5edd3106bb2e9

This commit appears in #177 which was approved by eviltrout. It was merged by CvX.