Skip to content

A platform for community discussion. Free, open, simple.

DEV: Clean up d-assign tests (#34183)

Jarek Radosz3bb1a77b038d
diff --git a/plugins/discourse-assign/test/javascripts/acceptance/assigned-topic-test.js b/plugins/discourse-assign/test/javascripts/acceptance/assigned-topic-test.js
index 3788ff16b58..e535cee4d52 100644
--- a/plugins/discourse-assign/test/javascripts/acceptance/assigned-topic-test.js
+++ b/plugins/discourse-assign/test/javascripts/acceptance/assigned-topic-test.js
@@ -4,7 +4,6 @@ import { cloneJSON } from "discourse/lib/object";
import topicFixtures from "discourse/tests/fixtures/topic";
import {
acceptance,
- query,
updateCurrentUser,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
@@ -114,7 +113,7 @@ function assignNewUserToTopic(needs) {
);
assert
.dom("#post_1 .assigned-to")
- .includesText("#2 to Developers", "Also shows indirects assignments");
+ .includesText("#2 to Developers", "Also shows indirect assignments");
assert.dom("#post_1 .assigned-to svg.d-icon-user-plus").exists();
assert.dom("#post_1 .assigned-to a[href='/']").exists();
assert
@@ -174,25 +173,24 @@ function assignNewUserToTopic(needs) {
await visit("/u/eviltrout/notifications");
- const notification = query(
- "section.user-content .user-notifications-list li.notification"
- );
-
- assert.true(
- notification.classList.contains("assigned"),
- "with correct assigned class"
- );
-
- assert.strictEqual(
- notification.querySelector("a").title,
- i18n("notifications.titles.assigned"),
- "with correct title"
- );
- assert.strictEqual(
- notification.querySelector("svg use").href["baseVal"],
- "#user-plus",
- "with correct icon"
- );
+ assert
+ .dom("section.user-content .user-notifications-list li.notification")
+ .hasClass("assigned", "with correct assigned class");
+
+ assert
+ .dom(
+ "section.user-content .user-notifications-list li.notification a"
+ )
+ .hasAttribute(
+ "title",
+ i18n("notifications.titles.assigned"),
+ "with correct title"
+ );
+ assert
+ .dom(
+ "section.user-content .user-notifications-list li.notification svg use"
+ )
+ .hasAttribute("href", "#user-plus", "with correct icon");
});
}
);
diff --git a/plugins/discourse-assign/test/javascripts/acceptance/user-assignments-list-test.js b/plugins/discourse-assign/test/javascripts/acceptance/user-assignments-list-test.js
index a4aef499c8b..4b31d80901e 100644
--- a/plugins/discourse-assign/test/javascripts/acceptance/user-assignments-list-test.js
+++ b/plugins/discourse-assign/test/javascripts/acceptance/user-assignments-list-test.js
@@ -12,11 +12,12 @@ acceptance(
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
needs.pretender((server, helper) => {
const messagesPath = "/topics/messages-assigned/eviltrout.json";
- const assigns = AssignedTopics[messagesPath];
- server.get(messagesPath, () => helper.response(assigns));
+ server.get(messagesPath, () =>
+ helper.response(cloneJSON(AssignedTopics[messagesPath]))
+ );
});
- test("Unassign/reassign options are visible", async function (assert) {
+ test("unassign/reassign options are visible", async function (assert) {
const options = selectKit(".assign-actions-dropdown");
await visit("/u/eviltrout/activity/assigned");
@@ -43,12 +44,12 @@ acceptance(
);
});
- test("It renders the empty state panel", async function (assert) {
+ test("renders the empty state panel", async function (assert) {
await visit("/u/eviltrout/activity/assigned");
assert.dom("div.empty-state").exists();
});
- test("It does not render the search form", async function (assert) {
+ test("does not render the search form", async function (assert) {
await visit("/u/eviltrout/activity/assigned");
assert.dom("div.topic-search-div").doesNotExist();
});
diff --git a/plugins/discourse-assign/test/javascripts/acceptance/user-private-messages-assigned-test.js b/plugins/discourse-assign/test/javascripts/acceptance/user-private-messages-assigned-test.js
index 4fdf4537bfc..1840e92e2f9 100644
--- a/plugins/discourse-assign/test/javascripts/acceptance/user-private-messages-assigned-test.js
+++ b/plugins/discourse-assign/test/javascripts/acceptance/user-private-messages-assigned-test.js
@@ -1,4 +1,4 @@
-import { click, currentURL, findAll, visit } from "@ember/test-helpers";
+import { click, currentURL, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { cloneJSON } from "discourse/lib/object";
import {
@@ -16,12 +16,10 @@ acceptance("Discourse Assign | User Private Messages", function (needs) {
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
needs.pretender((server, helper) => {
- const assignments = cloneJSON(
- AssignedTopics["/topics/messages-assigned/eviltrout.json"]
- );
-
server.get("/topics/private-messages-assigned/eviltrout.json", () =>
- helper.response(assignments)
+ helper.response(
+ cloneJSON(AssignedTopics["/topics/messages-assigned/eviltrout.json"])
+ )
);
});
@@ -30,10 +28,11 @@ acceptance("Discourse Assign | User Private Messages", function (needs) {
await visit("/u/eviltrout/messages");
await click(".messages-dropdown-trigger");
- const options = findAll(".dropdown-menu__item");
- assert.dom(options[2]).hasText(i18n("discourse_assign.assigned"));
+ assert
+ .dom(".dropdown-menu li:nth-child(3)")
+ .hasText(i18n("discourse_assign.assigned"));
- await click(options[2].querySelector(".btn"));
+ await click(".dropdown-menu li:nth-child(3) .btn");
assert.strictEqual(
currentURL(),
"/u/eviltrout/messages/assigned",