DEV: Clean up tests (#388)
This commit is contained in:
parent
17bcfde257
commit
5eee863d01
|
@ -1,23 +1,17 @@
|
||||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||||
import {
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
acceptance,
|
|
||||||
updateCurrentUser,
|
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
|
||||||
import { visit } from "@ember/test-helpers";
|
import { visit } from "@ember/test-helpers";
|
||||||
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
|
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("Discourse Assign | Assign disabled mobile", function (needs) {
|
acceptance("Discourse Assign | Assign disabled mobile", function (needs) {
|
||||||
needs.user();
|
needs.user({ can_assign: true });
|
||||||
needs.mobileView();
|
needs.mobileView();
|
||||||
needs.settings({ assign_enabled: false });
|
needs.settings({ assign_enabled: false });
|
||||||
needs.hooks.beforeEach(() => clearTopicFooterButtons());
|
|
||||||
|
|
||||||
test("Footer dropdown does not contain button", async (assert) => {
|
|
||||||
updateCurrentUser({ can_assign: true });
|
|
||||||
const menu = selectKit(".topic-footer-mobile-dropdown");
|
|
||||||
|
|
||||||
|
test("Footer dropdown does not contain button", async function (assert) {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
|
const menu = selectKit(".topic-footer-mobile-dropdown");
|
||||||
await menu.expand();
|
await menu.expand();
|
||||||
|
|
||||||
assert.notOk(menu.rowByValue("assign").exists());
|
assert.notOk(menu.rowByValue("assign").exists());
|
||||||
|
|
|
@ -7,14 +7,12 @@ import {
|
||||||
updateCurrentUser,
|
updateCurrentUser,
|
||||||
} from "discourse/tests/helpers/qunit-helpers";
|
} from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { click, visit } from "@ember/test-helpers";
|
import { click, visit } from "@ember/test-helpers";
|
||||||
import { clearTopicFooterButtons } from "discourse/lib/register-topic-footer-button";
|
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance("Discourse Assign | Assign mobile", function (needs) {
|
acceptance("Discourse Assign | Assign mobile", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.mobileView();
|
needs.mobileView();
|
||||||
needs.settings({ assign_enabled: true });
|
needs.settings({ assign_enabled: true });
|
||||||
needs.hooks.beforeEach(() => clearTopicFooterButtons());
|
|
||||||
|
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
server.get("/assign/suggestions", () => {
|
server.get("/assign/suggestions", () => {
|
||||||
|
@ -39,7 +37,7 @@ acceptance("Discourse Assign | Assign mobile", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Footer dropdown contains button", async (assert) => {
|
test("Footer dropdown contains button", async function (assert) {
|
||||||
updateCurrentUser({ can_assign: true });
|
updateCurrentUser({ can_assign: true });
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
const menu = selectKit(".topic-footer-mobile-dropdown");
|
const menu = selectKit(".topic-footer-mobile-dropdown");
|
||||||
|
@ -58,7 +56,6 @@ acceptance("Discourse Assign | Assign desktop", function (needs) {
|
||||||
can_assign: true,
|
can_assign: true,
|
||||||
});
|
});
|
||||||
needs.settings({ assign_enabled: true });
|
needs.settings({ assign_enabled: true });
|
||||||
needs.hooks.beforeEach(() => clearTopicFooterButtons());
|
|
||||||
|
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
server.get("/assign/suggestions", () => {
|
server.get("/assign/suggestions", () => {
|
||||||
|
@ -82,7 +79,8 @@ acceptance("Discourse Assign | Assign desktop", function (needs) {
|
||||||
return helper.response({ success: true });
|
return helper.response({ success: true });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
test("Post contains hidden assign button", async (assert) => {
|
|
||||||
|
test("Post contains hidden assign button", async function (assert) {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
||||||
assert.ok(
|
assert.ok(
|
||||||
|
@ -99,7 +97,7 @@ acceptance("Discourse Assign | Assign desktop", function (needs) {
|
||||||
assert.ok(exists(".assign.modal-body"), "assign modal opens");
|
assert.ok(exists(".assign.modal-body"), "assign modal opens");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Footer dropdown contains button", async (assert) => {
|
test("Footer dropdown contains button", async function (assert) {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
await click("#topic-footer-button-assign");
|
await click("#topic-footer-button-assign");
|
||||||
|
|
||||||
|
@ -118,7 +116,6 @@ acceptance("Discourse Assign | Assign Status enabled", function (needs) {
|
||||||
enable_assign_status: true,
|
enable_assign_status: true,
|
||||||
assign_statuses: "New|In Progress|Done",
|
assign_statuses: "New|In Progress|Done",
|
||||||
});
|
});
|
||||||
needs.hooks.beforeEach(() => clearTopicFooterButtons());
|
|
||||||
|
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
server.get("/assign/suggestions", () => {
|
server.get("/assign/suggestions", () => {
|
||||||
|
@ -143,7 +140,7 @@ acceptance("Discourse Assign | Assign Status enabled", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Modal contains status dropdown", async (assert) => {
|
test("Modal contains status dropdown", async function (assert) {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
await click("#topic-footer-button-assign");
|
await click("#topic-footer-button-assign");
|
||||||
|
|
||||||
|
@ -159,7 +156,6 @@ acceptance("Discourse Assign | Assign Status disabled", function (needs) {
|
||||||
can_assign: true,
|
can_assign: true,
|
||||||
});
|
});
|
||||||
needs.settings({ assign_enabled: true, enable_assign_status: false });
|
needs.settings({ assign_enabled: true, enable_assign_status: false });
|
||||||
needs.hooks.beforeEach(() => clearTopicFooterButtons());
|
|
||||||
|
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
server.get("/assign/suggestions", () => {
|
server.get("/assign/suggestions", () => {
|
||||||
|
@ -184,7 +180,7 @@ acceptance("Discourse Assign | Assign Status disabled", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Modal contains status dropdown", async (assert) => {
|
test("Modal contains status dropdown", async function (assert) {
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
await click("#topic-footer-button-assign");
|
await click("#topic-footer-button-assign");
|
||||||
|
|
||||||
|
@ -226,36 +222,36 @@ acceptance("Discourse Assign | User preferences", function (needs) {
|
||||||
remind_assigns_frequency: 43200,
|
remind_assigns_frequency: 43200,
|
||||||
});
|
});
|
||||||
|
|
||||||
test("The frequency for assigned topic reminders defaults to the site setting", async (assert) => {
|
test("The frequency for assigned topic reminders defaults to the site setting", async function (assert) {
|
||||||
await visit("/u/eviltrout/preferences/notifications");
|
await visit("/u/eviltrout/preferences/notifications");
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
selectKit("#remind-assigns-frequency").header().value(),
|
selectKit("#remind-assigns-frequency").header().value(),
|
||||||
"43200",
|
"43200",
|
||||||
"set frequency to default of Monthly"
|
"set frequency to default of Monthly"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("The user can change the frequency to Never", async (assert) => {
|
test("The user can change the frequency to Never", async function (assert) {
|
||||||
await visit("/u/eviltrout/preferences/notifications");
|
await visit("/u/eviltrout/preferences/notifications");
|
||||||
|
|
||||||
await selectKit("#remind-assigns-frequency").expand();
|
await selectKit("#remind-assigns-frequency").expand();
|
||||||
await selectKit("#remind-assigns-frequency").selectRowByValue(0);
|
await selectKit("#remind-assigns-frequency").selectRowByValue(0);
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
selectKit("#remind-assigns-frequency").header().value(),
|
selectKit("#remind-assigns-frequency").header().value(),
|
||||||
"0",
|
"0",
|
||||||
"set frequency to Never"
|
"set frequency to Never"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("The user can change the frequency to some other non-default value", async (assert) => {
|
test("The user can change the frequency to some other non-default value", async function (assert) {
|
||||||
await visit("/u/eviltrout/preferences/notifications");
|
await visit("/u/eviltrout/preferences/notifications");
|
||||||
|
|
||||||
await selectKit("#remind-assigns-frequency").expand();
|
await selectKit("#remind-assigns-frequency").expand();
|
||||||
await selectKit("#remind-assigns-frequency").selectRowByValue(10080); // weekly
|
await selectKit("#remind-assigns-frequency").selectRowByValue(10080); // weekly
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
selectKit("#remind-assigns-frequency").header().value(),
|
selectKit("#remind-assigns-frequency").header().value(),
|
||||||
"10080",
|
"10080",
|
||||||
"set frequency to Weekly"
|
"set frequency to Weekly"
|
||||||
|
@ -286,10 +282,10 @@ acceptance(
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("The user's previously selected value is loaded", async (assert) => {
|
test("The user's previously selected value is loaded", async function (assert) {
|
||||||
await visit("/u/eviltrout/preferences/notifications");
|
await visit("/u/eviltrout/preferences/notifications");
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
selectKit("#remind-assigns-frequency").header().value(),
|
selectKit("#remind-assigns-frequency").header().value(),
|
||||||
"10080",
|
"10080",
|
||||||
"frequency is pre-selected to Weekly"
|
"frequency is pre-selected to Weekly"
|
||||||
|
|
|
@ -52,22 +52,22 @@ acceptance("Discourse Assign | Assignment notifications", function (needs) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Shows the right icons", async (assert) => {
|
test("Shows the right icons", async function (assert) {
|
||||||
await visit("/");
|
await visit("/");
|
||||||
await click("#current-user.header-dropdown-toggle");
|
await click("#current-user.header-dropdown-toggle");
|
||||||
|
|
||||||
const userAssignment = query(".quick-access-panel li:nth-child(1) a");
|
const userAssignment = query(".quick-access-panel li:nth-child(1) a");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
[...userAssignment.querySelector(".d-icon").classList].includes(
|
userAssignment
|
||||||
"d-icon-user-plus"
|
.querySelector(".d-icon")
|
||||||
)
|
.classList.contains("d-icon-user-plus")
|
||||||
);
|
);
|
||||||
|
|
||||||
const groupAssignment = query(".quick-access-panel li:nth-child(2) a");
|
const groupAssignment = query(".quick-access-panel li:nth-child(2) a");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
[...groupAssignment.querySelector(".d-icon").classList].includes(
|
groupAssignment
|
||||||
"d-icon-group-plus"
|
.querySelector(".d-icon")
|
||||||
)
|
.classList.contains("d-icon-group-plus")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -95,27 +95,27 @@ acceptance("Discourse Assign | Assigned topic", function (needs) {
|
||||||
|
|
||||||
assignCurrentUserToTopic(needs);
|
assignCurrentUserToTopic(needs);
|
||||||
|
|
||||||
test("Shows user assignment info", async (assert) => {
|
test("Shows user assignment info", async function (assert) {
|
||||||
updateCurrentUser({ can_assign: true });
|
updateCurrentUser({ can_assign: true });
|
||||||
await visit("/t/assignment-topic/44");
|
await visit("/t/assignment-topic/44");
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query("#topic-title .assigned-to").innerText.trim(),
|
query("#topic-title .assigned-to").innerText.trim(),
|
||||||
"eviltrout",
|
"eviltrout",
|
||||||
"shows assignment in the header"
|
"shows assignment in the header"
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query("#post_1 .assigned-to").innerText,
|
query("#post_1 .assigned-to").innerText,
|
||||||
"Assigned toeviltrout#2 Developers",
|
"Assigned toeviltrout#2 Developers",
|
||||||
"shows assignment and indirect assignments in the first post"
|
"shows assignment and indirect assignments in the first post"
|
||||||
);
|
);
|
||||||
assert.ok(exists("#post_1 .assigned-to svg.d-icon-user-plus"));
|
assert.ok(exists("#post_1 .assigned-to svg.d-icon-user-plus"));
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query(".discourse-tags .assigned-to[href='/t/28830'] span").title,
|
query(".discourse-tags .assigned-to[href='/t/28830'] span").title,
|
||||||
"Shark Doododooo",
|
"Shark Doododooo",
|
||||||
"shows topic assign notes"
|
"shows topic assign notes"
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query(".discourse-tags .assigned-to[href='/p/2'] span").title,
|
query(".discourse-tags .assigned-to[href='/p/2'] span").title,
|
||||||
'<script>alert("xss")</script>',
|
'<script>alert("xss")</script>',
|
||||||
"shows indirect assign notes"
|
"shows indirect assign notes"
|
||||||
|
@ -126,16 +126,16 @@ acceptance("Discourse Assign | Assigned topic", function (needs) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Shows group assignment info", async (assert) => {
|
test("Shows group assignment info", async function (assert) {
|
||||||
updateCurrentUser({ can_assign: true });
|
updateCurrentUser({ can_assign: true });
|
||||||
await visit("/t/assignment-topic/45");
|
await visit("/t/assignment-topic/45");
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query("#topic-title .assigned-to").innerText.trim(),
|
query("#topic-title .assigned-to").innerText.trim(),
|
||||||
"Developers",
|
"Developers",
|
||||||
"shows assignment in the header"
|
"shows assignment in the header"
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query("#post_1 .assigned-to-group").innerText.trim(),
|
query("#post_1 .assigned-to-group").innerText.trim(),
|
||||||
"Developers",
|
"Developers",
|
||||||
"shows assignment in the first post"
|
"shows assignment in the first post"
|
||||||
|
@ -147,7 +147,7 @@ acceptance("Discourse Assign | Assigned topic", function (needs) {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("User without assign ability cannot see footer button", async (assert) => {
|
test("User without assign ability cannot see footer button", async function (assert) {
|
||||||
updateCurrentUser({ can_assign: false, admin: false, moderator: false });
|
updateCurrentUser({ can_assign: false, admin: false, moderator: false });
|
||||||
await visit("/t/assignment-topic/45");
|
await visit("/t/assignment-topic/45");
|
||||||
|
|
||||||
|
@ -166,18 +166,17 @@ acceptance("Discourse Assign | Assigned topic", function (needs) {
|
||||||
"section.user-content ul.notifications li.item.notification"
|
"section.user-content ul.notifications li.item.notification"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.ok(
|
||||||
notification.children[0].classList,
|
notification.children[0].classList.contains("assigned"),
|
||||||
"assigned",
|
|
||||||
"with correct assigned class"
|
"with correct assigned class"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
notification.querySelector("a").title,
|
notification.querySelector("a").title,
|
||||||
I18n.t("notifications.titles.assigned"),
|
I18n.t("notifications.titles.assigned"),
|
||||||
"with correct title"
|
"with correct title"
|
||||||
);
|
);
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
notification.querySelector("svg use").href["baseVal"],
|
notification.querySelector("svg use").href["baseVal"],
|
||||||
"#user-plus",
|
"#user-plus",
|
||||||
"with correct icon"
|
"with correct icon"
|
||||||
|
@ -185,7 +184,7 @@ acceptance("Discourse Assign | Assigned topic", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Discourse Assign | Re-assign topic", function (needs) {
|
acceptance("Discourse Assign | Reassign topic", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.settings({
|
needs.settings({
|
||||||
assign_enabled: true,
|
assign_enabled: true,
|
||||||
|
@ -195,7 +194,7 @@ acceptance("Discourse Assign | Re-assign topic", function (needs) {
|
||||||
|
|
||||||
assignNewUserToTopic(needs);
|
assignNewUserToTopic(needs);
|
||||||
|
|
||||||
test("Re-assign Footer dropdown contains reassign buttons", async (assert) => {
|
test("Reassign Footer dropdown contains reassign buttons", async function (assert) {
|
||||||
updateCurrentUser({ can_assign: true });
|
updateCurrentUser({ can_assign: true });
|
||||||
const menu = selectKit("#topic-footer-dropdown-reassign");
|
const menu = selectKit("#topic-footer-dropdown-reassign");
|
||||||
|
|
||||||
|
@ -208,7 +207,7 @@ acceptance("Discourse Assign | Re-assign topic", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Discourse Assign | Re-assign topic | mobile", function (needs) {
|
acceptance("Discourse Assign | Reassign topic | mobile", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.mobileView();
|
needs.mobileView();
|
||||||
needs.settings({
|
needs.settings({
|
||||||
|
@ -219,7 +218,7 @@ acceptance("Discourse Assign | Re-assign topic | mobile", function (needs) {
|
||||||
|
|
||||||
assignNewUserToTopic(needs);
|
assignNewUserToTopic(needs);
|
||||||
|
|
||||||
test("Mobile Footer dropdown contains reassign buttons", async (assert) => {
|
test("Mobile Footer dropdown contains reassign buttons", async function (assert) {
|
||||||
updateCurrentUser({ can_assign: true });
|
updateCurrentUser({ can_assign: true });
|
||||||
const menu = selectKit(".topic-footer-mobile-dropdown");
|
const menu = selectKit(".topic-footer-mobile-dropdown");
|
||||||
|
|
||||||
|
@ -232,7 +231,7 @@ acceptance("Discourse Assign | Re-assign topic | mobile", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
acceptance("Discourse Assign | Re-assign topic conditionals", function (needs) {
|
acceptance("Discourse Assign | Reassign topic conditionals", function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.settings({
|
needs.settings({
|
||||||
assign_enabled: true,
|
assign_enabled: true,
|
||||||
|
@ -242,7 +241,7 @@ acceptance("Discourse Assign | Re-assign topic conditionals", function (needs) {
|
||||||
|
|
||||||
assignCurrentUserToTopic(needs);
|
assignCurrentUserToTopic(needs);
|
||||||
|
|
||||||
test("Reassign Footer dropdown won't display reassign-to-self button when already assigned to current user", async (assert) => {
|
test("Reassign Footer dropdown won't display reassign-to-self button when already assigned to current user", async function (assert) {
|
||||||
updateCurrentUser({ can_assign: true });
|
updateCurrentUser({ can_assign: true });
|
||||||
const menu = selectKit("#topic-footer-dropdown-reassign");
|
const menu = selectKit("#topic-footer-dropdown-reassign");
|
||||||
|
|
||||||
|
|
|
@ -490,17 +490,15 @@ acceptance("Discourse Assign | experimental user menu", function (needs) {
|
||||||
await click(".d-header-icons .current-user");
|
await click(".d-header-icons .current-user");
|
||||||
await click("#user-menu-button-assign-list");
|
await click("#user-menu-button-assign-list");
|
||||||
|
|
||||||
const notifications = queryAll(
|
const notification = query("#quick-access-assign-list ul li.notification");
|
||||||
"#quick-access-assign-list ul li.notification"
|
|
||||||
);
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
notifications[0].textContent.replace(/\s+/g, " ").trim(),
|
notification.textContent.replace(/\s+/g, " ").trim(),
|
||||||
"tony notificationModelTransformer Test poll topic please bear with me"
|
"tony notificationModelTransformer Test poll topic please bear with me"
|
||||||
);
|
);
|
||||||
|
|
||||||
const assigns = queryAll("#quick-access-assign-list ul li.assign");
|
const assign = query("#quick-access-assign-list ul li.assign");
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
assigns[0].textContent.replace(/\s+/g, " ").trim(),
|
assign.textContent.replace(/\s+/g, " ").trim(),
|
||||||
"topicModelTransformer Howdy this my test topic with emoji !"
|
"topicModelTransformer Howdy this my test topic with emoji !"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,7 +36,7 @@ acceptance(
|
||||||
});
|
});
|
||||||
stubCategory(needs, { enable_unassigned_filter: "true" });
|
stubCategory(needs, { enable_unassigned_filter: "true" });
|
||||||
|
|
||||||
test("can see Unassigned button", async (assert) => {
|
test("can see Unassigned button", async function (assert) {
|
||||||
await visit("/c/test");
|
await visit("/c/test");
|
||||||
|
|
||||||
const title = I18n.t("filters.unassigned.help");
|
const title = I18n.t("filters.unassigned.help");
|
||||||
|
@ -56,7 +56,7 @@ acceptance(
|
||||||
});
|
});
|
||||||
stubCategory(needs, { enable_unassigned_filter: "false" });
|
stubCategory(needs, { enable_unassigned_filter: "false" });
|
||||||
|
|
||||||
test("cannot see Unassigned button", async (assert) => {
|
test("cannot see Unassigned button", async function (assert) {
|
||||||
await visit("/c/test");
|
await visit("/c/test");
|
||||||
|
|
||||||
const title = I18n.t("filters.unassigned.help");
|
const title = I18n.t("filters.unassigned.help");
|
||||||
|
@ -76,7 +76,7 @@ acceptance(
|
||||||
});
|
});
|
||||||
stubCategory(needs, { enable_unassigned_filter: "true" });
|
stubCategory(needs, { enable_unassigned_filter: "true" });
|
||||||
|
|
||||||
test("can see Unassigned button", async (assert) => {
|
test("can see Unassigned button", async function (assert) {
|
||||||
await visit("/c/test");
|
await visit("/c/test");
|
||||||
|
|
||||||
const title = I18n.t("filters.unassigned.help");
|
const title = I18n.t("filters.unassigned.help");
|
||||||
|
@ -96,7 +96,7 @@ acceptance(
|
||||||
});
|
});
|
||||||
stubCategory(needs, { enable_unassigned_filter: "true" });
|
stubCategory(needs, { enable_unassigned_filter: "true" });
|
||||||
|
|
||||||
test("cannot see Unassigned button", async (assert) => {
|
test("cannot see Unassigned button", async function (assert) {
|
||||||
await visit("/c/test");
|
await visit("/c/test");
|
||||||
|
|
||||||
const title = I18n.t("filters.unassigned.help");
|
const title = I18n.t("filters.unassigned.help");
|
||||||
|
|
|
@ -19,13 +19,13 @@ acceptance("Discourse Assign | GroupAssignments", function (needs) {
|
||||||
server.get(getMembersPath, () => helper.response(getMembers));
|
server.get(getMembersPath, () => helper.response(getMembers));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Group Assignments Everyone", async (assert) => {
|
test("Group Assignments Everyone", async function (assert) {
|
||||||
await visit("/g/discourse/assigned");
|
await visit("/g/discourse/assigned");
|
||||||
assert.equal(count(".topic-list-item"), 1);
|
assert.strictEqual(count(".topic-list-item"), 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Group Assignments Ahmedgagan", async (assert) => {
|
test("Group Assignments Ahmedgagan", async function (assert) {
|
||||||
await visit("/g/discourse/assigned/ahmedgagan6");
|
await visit("/g/discourse/assigned/ahmedgagan6");
|
||||||
assert.equal(count(".topic-list-item"), 1);
|
assert.strictEqual(count(".topic-list-item"), 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -43,7 +43,7 @@ acceptance(
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Show default assign reason when user tracks topics", async (assert) => {
|
test("Show default assign reason when user tracks topics", async function (assert) {
|
||||||
updateCurrentUser({ never_auto_track_topics: false });
|
updateCurrentUser({ never_auto_track_topics: false });
|
||||||
|
|
||||||
await visit("/t/assignment-topic/44");
|
await visit("/t/assignment-topic/44");
|
||||||
|
@ -54,7 +54,7 @@ acceptance(
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Show user assign reason when user never tracks topics", async (assert) => {
|
test("Show user assign reason when user never tracks topics", async function (assert) {
|
||||||
updateCurrentUser({
|
updateCurrentUser({
|
||||||
never_auto_track_topics: true,
|
never_auto_track_topics: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ acceptance(
|
||||||
server.get(messagesPath, () => helper.response(assigns));
|
server.get(messagesPath, () => helper.response(assigns));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Quick access assignments panel", async (assert) => {
|
test("Quick access assignments panel", async function (assert) {
|
||||||
updateCurrentUser({ can_assign: true });
|
updateCurrentUser({ can_assign: true });
|
||||||
|
|
||||||
await visit("/");
|
await visit("/");
|
||||||
|
@ -32,7 +32,7 @@ acceptance(
|
||||||
assert.ok(assignment.href.includes("/t/greetings/10/5"));
|
assert.ok(assignment.href.includes("/t/greetings/10/5"));
|
||||||
|
|
||||||
await click(".widget-button.assigned");
|
await click(".widget-button.assigned");
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
currentURL(),
|
currentURL(),
|
||||||
"/u/eviltrout/activity/assigned",
|
"/u/eviltrout/activity/assigned",
|
||||||
"a second click should redirect to the full assignments page"
|
"a second click should redirect to the full assignments page"
|
||||||
|
|
|
@ -20,7 +20,7 @@ acceptance("Discourse Assign | Search - Full Page", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("update in:assigned filter through advanced search ui", async (assert) => {
|
test("update in:assigned filter through advanced search ui", async function (assert) {
|
||||||
const inSelector = selectKit(".search-advanced-options .select-kit#in");
|
const inSelector = selectKit(".search-advanced-options .select-kit#in");
|
||||||
|
|
||||||
await visit("/search");
|
await visit("/search");
|
||||||
|
@ -28,14 +28,14 @@ acceptance("Discourse Assign | Search - Full Page", function (needs) {
|
||||||
await fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
await inSelector.expand();
|
await inSelector.expand();
|
||||||
await inSelector.selectRowByValue("assigned");
|
await inSelector.selectRowByValue("assigned");
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query(".search-query").value,
|
query(".search-query").value,
|
||||||
"none in:assigned",
|
"none in:assigned",
|
||||||
'has updated search term to "none in:assigned"'
|
'has updated search term to "none in:assigned"'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("update in:unassigned filter through advanced search ui", async (assert) => {
|
test("update in:unassigned filter through advanced search ui", async function (assert) {
|
||||||
const inSelector = selectKit(".search-advanced-options .select-kit#in");
|
const inSelector = selectKit(".search-advanced-options .select-kit#in");
|
||||||
|
|
||||||
await visit("/search");
|
await visit("/search");
|
||||||
|
@ -43,14 +43,14 @@ acceptance("Discourse Assign | Search - Full Page", function (needs) {
|
||||||
await fillIn(".search-query", "none");
|
await fillIn(".search-query", "none");
|
||||||
await inSelector.expand();
|
await inSelector.expand();
|
||||||
await inSelector.selectRowByValue("unassigned");
|
await inSelector.selectRowByValue("unassigned");
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query(".search-query").value,
|
query(".search-query").value,
|
||||||
"none in:unassigned",
|
"none in:unassigned",
|
||||||
'has updated search term to "none in:unassigned"'
|
'has updated search term to "none in:unassigned"'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("update assigned to through advanced search ui", async (assert) => {
|
test("update assigned to through advanced search ui", async function (assert) {
|
||||||
const assignedField = selectKit(".assigned-advanced-search .select-kit");
|
const assignedField = selectKit(".assigned-advanced-search .select-kit");
|
||||||
|
|
||||||
await visit("/search");
|
await visit("/search");
|
||||||
|
@ -61,13 +61,13 @@ acceptance("Discourse Assign | Search - Full Page", function (needs) {
|
||||||
await assignedField.fillInFilter("admin");
|
await assignedField.fillInFilter("admin");
|
||||||
await assignedField.selectRowByValue("admin");
|
await assignedField.selectRowByValue("admin");
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
assignedField.header().value(),
|
assignedField.header().value(),
|
||||||
"admin",
|
"admin",
|
||||||
'has "admin" filled in'
|
'has "admin" filled in'
|
||||||
);
|
);
|
||||||
|
|
||||||
assert.equal(
|
assert.strictEqual(
|
||||||
query(".search-query").value,
|
query(".search-query").value,
|
||||||
"none assigned:admin",
|
"none assigned:admin",
|
||||||
'has updated search term to "none assigned:admin"'
|
'has updated search term to "none assigned:admin"'
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { cloneJSON } from "discourse-common/lib/object";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
acceptance(
|
acceptance(
|
||||||
"Discourse Assign | UnAssign/Re-assign from the topics list",
|
"Discourse Assign | Unassign/reassign from the topics list",
|
||||||
function (needs) {
|
function (needs) {
|
||||||
needs.user();
|
needs.user();
|
||||||
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
|
needs.settings({ assign_enabled: true, assigns_user_url_path: "/" });
|
||||||
|
@ -20,14 +20,14 @@ acceptance(
|
||||||
server.get(messagesPath, () => helper.response(assigns));
|
server.get(messagesPath, () => helper.response(assigns));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Unassign/Re-assign options are visible", async (assert) => {
|
test("Unassign/reassign options are visible", async function (assert) {
|
||||||
const options = selectKit(".assign-actions-dropdown");
|
const options = selectKit(".assign-actions-dropdown");
|
||||||
|
|
||||||
await visit("/u/eviltrout/activity/assigned");
|
await visit("/u/eviltrout/activity/assigned");
|
||||||
await options.expand();
|
await options.expand();
|
||||||
|
|
||||||
assert.equal(count("li[data-value='unassign']"), 1);
|
assert.strictEqual(count("li[data-value='unassign']"), 1);
|
||||||
assert.equal(count("li[data-value='reassign']"), 1);
|
assert.strictEqual(count("li[data-value='reassign']"), 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,7 +10,7 @@ discourseModule(
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
componentTest("displays username and name", {
|
componentTest("displays username and name", {
|
||||||
template: hbs`{{group-assigned-filter showAvatar=true filter=filter}}`,
|
template: hbs`<GroupAssignedFilter @showAvatar={{true}} @filter={{filter}} />`,
|
||||||
|
|
||||||
beforeEach() {
|
beforeEach() {
|
||||||
this.set("filter", {
|
this.set("filter", {
|
||||||
|
@ -27,8 +27,8 @@ discourseModule(
|
||||||
},
|
},
|
||||||
|
|
||||||
test(assert) {
|
test(assert) {
|
||||||
assert.equal(query(".assign-username").innerText, "Ahmed");
|
assert.strictEqual(query(".assign-username").innerText, "Ahmed");
|
||||||
assert.equal(query(".assign-name").innerText, "Ahmed Gagan");
|
assert.strictEqual(query(".assign-name").innerText, "Ahmed Gagan");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,19 @@
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
|
|
||||||
discourseModule("Unit | Controller | assign-user", function () {
|
discourseModule("Unit | Controller | assign-user", function () {
|
||||||
test("assigning a user via suggestions makes API call and closes the modal", async function (assert) {
|
test("assigning a user via suggestions makes API call and closes the modal", async function (assert) {
|
||||||
pretender.get("/assign/suggestions", () => {
|
pretender.get("/assign/suggestions", () =>
|
||||||
return [
|
response({
|
||||||
200,
|
suggestions: [],
|
||||||
{ "Content-Type": "application/json" },
|
assign_allowed_on_groups: ["nat"],
|
||||||
{
|
assign_allowed_for_groups: [],
|
||||||
suggestions: [],
|
})
|
||||||
assign_allowed_on_groups: ["nat"],
|
);
|
||||||
assign_allowed_for_groups: [],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
pretender.put("/assign/assign", () => {
|
pretender.put("/assign/assign", () => response({}));
|
||||||
return [200, { "Content-Type": "application/json" }, {}];
|
|
||||||
});
|
|
||||||
|
|
||||||
let modalClosed = false;
|
let modalClosed = false;
|
||||||
const controller = this.getController("assign-user", {
|
const controller = this.getController("assign-user", {
|
||||||
|
@ -39,17 +33,13 @@ discourseModule("Unit | Controller | assign-user", function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
test("assigning a user by selector does not close the modal", async function (assert) {
|
test("assigning a user by selector does not close the modal", async function (assert) {
|
||||||
pretender.get("/assign/suggestions", () => {
|
pretender.get("/assign/suggestions", () =>
|
||||||
return [
|
response({
|
||||||
200,
|
suggestions: [],
|
||||||
{ "Content-Type": "application/json" },
|
assign_allowed_on_groups: ["nat"],
|
||||||
{
|
assign_allowed_for_groups: [],
|
||||||
suggestions: [],
|
})
|
||||||
assign_allowed_on_groups: ["nat"],
|
);
|
||||||
assign_allowed_for_groups: [],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
let modalClosed = false;
|
let modalClosed = false;
|
||||||
const controller = this.getController("assign-user", {
|
const controller = this.getController("assign-user", {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import * as showModal from "discourse/lib/show-modal";
|
import * as showModal from "discourse/lib/show-modal";
|
||||||
import pretender from "discourse/tests/helpers/create-pretender";
|
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||||
|
|
||||||
discourseModule("Unit | Service | task-actions", function () {
|
discourseModule("Unit | Service | task-actions", function () {
|
||||||
test("assign", function (assert) {
|
test("assign", function (assert) {
|
||||||
|
@ -14,10 +14,9 @@ discourseModule("Unit | Service | task-actions", function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
const modal = service.assign(target);
|
const modal = service.assign(target);
|
||||||
|
|
||||||
const modalCall = stub.getCall(0).args;
|
const modalCall = stub.getCall(0).args;
|
||||||
|
|
||||||
assert.equal(modal, "the modal");
|
assert.strictEqual(modal, "the modal");
|
||||||
assert.deepEqual(modalCall[0], "assign-user");
|
assert.deepEqual(modalCall[0], "assign-user");
|
||||||
assert.deepEqual(modalCall[1], {
|
assert.deepEqual(modalCall[1], {
|
||||||
title: "discourse_assign.assign_modal.title",
|
title: "discourse_assign.assign_modal.title",
|
||||||
|
@ -40,7 +39,7 @@ discourseModule("Unit | Service | task-actions", function () {
|
||||||
let assignRequest;
|
let assignRequest;
|
||||||
pretender.put("/assign/assign", (request) => {
|
pretender.put("/assign/assign", (request) => {
|
||||||
assignRequest = request;
|
assignRequest = request;
|
||||||
return [200];
|
return response({});
|
||||||
});
|
});
|
||||||
|
|
||||||
await service.reassignUserToTopic(user, target);
|
await service.reassignUserToTopic(user, target);
|
||||||
|
|
Loading…
Reference in New Issue