mirror of
https://github.com/discourse/discourse.git
synced 2025-05-29 11:48:08 +08:00
DEV: migrate acceptance tests to async await - admin, about, account created (#6111)
This commit is contained in:

committed by
Guo Xiang Tan

parent
4bee7fb458
commit
6aa2eb19d4
@ -1,12 +1,11 @@
|
|||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("About");
|
acceptance("About");
|
||||||
|
|
||||||
QUnit.test("viewing", assert => {
|
QUnit.test("viewing", async assert => {
|
||||||
visit("/about");
|
await visit("/about");
|
||||||
andThen(() => {
|
|
||||||
assert.ok($("body.about-page").length, "has body class");
|
assert.ok($("body.about-page").length, "has body class");
|
||||||
assert.ok(exists(".about.admins .user-info"), "has admins");
|
assert.ok(exists(".about.admins .user-info"), "has admins");
|
||||||
assert.ok(exists(".about.moderators .user-info"), "has moderators");
|
assert.ok(exists(".about.moderators .user-info"), "has moderators");
|
||||||
assert.ok(exists(".about.stats tr td"), "has stats");
|
assert.ok(exists(".about.stats tr td"), "has stats");
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -3,97 +3,90 @@ import PreloadStore from "preload-store";
|
|||||||
|
|
||||||
acceptance("Account Created");
|
acceptance("Account Created");
|
||||||
|
|
||||||
QUnit.test("account created - message", assert => {
|
QUnit.test("account created - message", async assert => {
|
||||||
PreloadStore.store("accountCreated", {
|
PreloadStore.store("accountCreated", {
|
||||||
message: "Hello World"
|
message: "Hello World"
|
||||||
});
|
});
|
||||||
visit("/u/account-created");
|
await visit("/u/account-created");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists(".account-created"));
|
||||||
assert.ok(exists(".account-created"));
|
assert.equal(
|
||||||
assert.equal(
|
find(".account-created .ac-message")
|
||||||
find(".account-created .ac-message")
|
.text()
|
||||||
.text()
|
.trim(),
|
||||||
.trim(),
|
"Hello World",
|
||||||
"Hello World",
|
"it displays the message"
|
||||||
"it displays the message"
|
);
|
||||||
);
|
assert.notOk(exists(".activation-controls"));
|
||||||
assert.notOk(exists(".activation-controls"));
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("account created - resend email", assert => {
|
QUnit.test("account created - resend email", async assert => {
|
||||||
PreloadStore.store("accountCreated", {
|
PreloadStore.store("accountCreated", {
|
||||||
message: "Hello World",
|
message: "Hello World",
|
||||||
username: "eviltrout",
|
username: "eviltrout",
|
||||||
email: "eviltrout@example.com",
|
email: "eviltrout@example.com",
|
||||||
show_controls: true
|
show_controls: true
|
||||||
});
|
});
|
||||||
visit("/u/account-created");
|
|
||||||
|
|
||||||
andThen(() => {
|
await visit("/u/account-created");
|
||||||
assert.ok(exists(".account-created"));
|
|
||||||
assert.equal(
|
|
||||||
find(".account-created .ac-message")
|
|
||||||
.text()
|
|
||||||
.trim(),
|
|
||||||
"Hello World",
|
|
||||||
"it displays the message"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".activation-controls .resend");
|
assert.ok(exists(".account-created"));
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(currentPath(), "account-created.resent");
|
find(".account-created .ac-message")
|
||||||
const email = find(".account-created .ac-message b").text();
|
.text()
|
||||||
assert.equal(email, "eviltrout@example.com");
|
.trim(),
|
||||||
});
|
"Hello World",
|
||||||
|
"it displays the message"
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".activation-controls .resend");
|
||||||
|
|
||||||
|
assert.equal(currentPath(), "account-created.resent");
|
||||||
|
const email = find(".account-created .ac-message b").text();
|
||||||
|
assert.equal(email, "eviltrout@example.com");
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("account created - update email - cancel", assert => {
|
QUnit.test("account created - update email - cancel", async assert => {
|
||||||
PreloadStore.store("accountCreated", {
|
PreloadStore.store("accountCreated", {
|
||||||
message: "Hello World",
|
message: "Hello World",
|
||||||
username: "eviltrout",
|
username: "eviltrout",
|
||||||
email: "eviltrout@example.com",
|
email: "eviltrout@example.com",
|
||||||
show_controls: true
|
show_controls: true
|
||||||
});
|
});
|
||||||
visit("/u/account-created");
|
|
||||||
|
|
||||||
click(".activation-controls .edit-email");
|
await visit("/u/account-created");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(currentPath(), "account-created.edit-email");
|
|
||||||
assert.ok(find(".activation-controls .btn-primary:disabled").length);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".activation-controls .edit-cancel");
|
await click(".activation-controls .edit-email");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(currentPath(), "account-created.index");
|
assert.equal(currentPath(), "account-created.edit-email");
|
||||||
});
|
assert.ok(find(".activation-controls .btn-primary:disabled").length);
|
||||||
|
|
||||||
|
await click(".activation-controls .edit-cancel");
|
||||||
|
|
||||||
|
assert.equal(currentPath(), "account-created.index");
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("account created - update email - submit", assert => {
|
QUnit.test("account created - update email - submit", async assert => {
|
||||||
PreloadStore.store("accountCreated", {
|
PreloadStore.store("accountCreated", {
|
||||||
message: "Hello World",
|
message: "Hello World",
|
||||||
username: "eviltrout",
|
username: "eviltrout",
|
||||||
email: "eviltrout@example.com",
|
email: "eviltrout@example.com",
|
||||||
show_controls: true
|
show_controls: true
|
||||||
});
|
});
|
||||||
visit("/u/account-created");
|
|
||||||
|
|
||||||
click(".activation-controls .edit-email");
|
await visit("/u/account-created");
|
||||||
andThen(() => {
|
|
||||||
assert.ok(find(".activation-controls .btn-primary:disabled").length);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".activate-new-email", "newemail@example.com");
|
await click(".activation-controls .edit-email");
|
||||||
andThen(() => {
|
|
||||||
assert.notOk(find(".activation-controls .btn-primary:disabled").length);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".activation-controls .btn-primary");
|
assert.ok(find(".activation-controls .btn-primary:disabled").length);
|
||||||
andThen(() => {
|
|
||||||
assert.equal(currentPath(), "account-created.resent");
|
await fillIn(".activate-new-email", "newemail@example.com");
|
||||||
const email = find(".account-created .ac-message b").text();
|
|
||||||
assert.equal(email, "newemail@example.com");
|
assert.notOk(find(".activation-controls .btn-primary:disabled").length);
|
||||||
});
|
|
||||||
|
await click(".activation-controls .btn-primary");
|
||||||
|
|
||||||
|
assert.equal(currentPath(), "account-created.resent");
|
||||||
|
const email = find(".account-created .ac-message b").text();
|
||||||
|
assert.equal(email, "newemail@example.com");
|
||||||
});
|
});
|
||||||
|
@ -1,139 +1,128 @@
|
|||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("Admin - Flagging", { loggedIn: true });
|
acceptance("Admin - Flagging", { loggedIn: true });
|
||||||
|
|
||||||
QUnit.test("flagged posts", assert => {
|
QUnit.test("flagged posts", async assert => {
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(find(".flagged-posts .flagged-post").length, 1);
|
assert.equal(find(".flagged-posts .flagged-post").length, 1);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".flagged-post .flag-user").length,
|
find(".flagged-post .flag-user").length,
|
||||||
1,
|
1,
|
||||||
"shows who flagged it"
|
"shows who flagged it"
|
||||||
);
|
);
|
||||||
assert.equal(find(".flagged-post-response").length, 2);
|
assert.equal(find(".flagged-post-response").length, 2);
|
||||||
assert.equal(find(".flagged-post-response:eq(0) img.avatar").length, 1);
|
assert.equal(find(".flagged-post-response:eq(0) img.avatar").length, 1);
|
||||||
assert.equal(
|
assert.equal(
|
||||||
find(".flagged-post-user-details .username").length,
|
find(".flagged-post-user-details .username").length,
|
||||||
1,
|
1,
|
||||||
"shows the flagged username"
|
"shows the flagged username"
|
||||||
);
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("flagged posts - agree", assert => {
|
QUnit.test("flagged posts - agree", async assert => {
|
||||||
const agreeFlag = selectKit(".agree-flag");
|
const agreeFlag = selectKit(".agree-flag");
|
||||||
|
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
|
|
||||||
agreeFlag.expand().selectRowByValue("confirm-agree-keep");
|
await agreeFlag.expandAwait();
|
||||||
|
await agreeFlag.selectRowByValueAwait("confirm-agree-keep");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".admin-flags .flagged-post").length,
|
||||||
find(".admin-flags .flagged-post").length,
|
0,
|
||||||
0,
|
"post was removed"
|
||||||
"post was removed"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("flagged posts - agree + hide", assert => {
|
QUnit.test("flagged posts - agree + hide", async assert => {
|
||||||
const agreeFlag = selectKit(".agree-flag");
|
const agreeFlag = selectKit(".agree-flag");
|
||||||
|
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
|
|
||||||
agreeFlag.expand().selectRowByValue("confirm-agree-hide");
|
await agreeFlag.expandAwait();
|
||||||
|
await agreeFlag.selectRowByValueAwait("confirm-agree-hide");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".admin-flags .flagged-post").length,
|
||||||
find(".admin-flags .flagged-post").length,
|
0,
|
||||||
0,
|
"post was removed"
|
||||||
"post was removed"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("flagged posts - agree + deleteSpammer", assert => {
|
QUnit.test("flagged posts - agree + deleteSpammer", async assert => {
|
||||||
const agreeFlag = selectKit(".agree-flag");
|
const agreeFlag = selectKit(".agree-flag");
|
||||||
|
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
|
|
||||||
agreeFlag.expand().selectRowByValue("delete-spammer");
|
await agreeFlag.expandAwait();
|
||||||
|
await agreeFlag.selectRowByValueAwait("delete-spammer");
|
||||||
|
|
||||||
click(".confirm-delete");
|
await click(".confirm-delete");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".admin-flags .flagged-post").length,
|
||||||
find(".admin-flags .flagged-post").length,
|
0,
|
||||||
0,
|
"post was removed"
|
||||||
"post was removed"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("flagged posts - disagree", assert => {
|
QUnit.test("flagged posts - disagree", async assert => {
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
click(".disagree-flag");
|
await click(".disagree-flag");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("flagged posts - defer", assert => {
|
QUnit.test("flagged posts - defer", async assert => {
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
click(".defer-flag");
|
await click(".defer-flag");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("flagged posts - delete + defer", assert => {
|
QUnit.test("flagged posts - delete + defer", async assert => {
|
||||||
const deleteFlag = selectKit(".delete-flag");
|
const deleteFlag = selectKit(".delete-flag");
|
||||||
|
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
|
|
||||||
deleteFlag.expand().selectRowByValue("delete-defer");
|
await deleteFlag.expandAwait();
|
||||||
|
await deleteFlag.selectRowByValueAwait("delete-defer");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
||||||
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("flagged posts - delete + agree", assert => {
|
QUnit.test("flagged posts - delete + agree", async assert => {
|
||||||
const deleteFlag = selectKit(".delete-flag");
|
const deleteFlag = selectKit(".delete-flag");
|
||||||
|
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
|
|
||||||
deleteFlag.expand().selectRowByValue("delete-agree");
|
await deleteFlag.expandAwait();
|
||||||
|
await deleteFlag.selectRowByValueAwait("delete-agree");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
||||||
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("flagged posts - delete + deleteSpammer", assert => {
|
QUnit.test("flagged posts - delete + deleteSpammer", async assert => {
|
||||||
const deleteFlag = selectKit(".delete-flag");
|
const deleteFlag = selectKit(".delete-flag");
|
||||||
|
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
|
|
||||||
deleteFlag.expand().selectRowByValue("delete-spammer");
|
await deleteFlag.expandAwait();
|
||||||
|
await deleteFlag.selectRowByValueAwait("delete-spammer");
|
||||||
|
|
||||||
click(".confirm-delete");
|
await click(".confirm-delete");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
||||||
assert.equal(find(".admin-flags .flagged-post").length, 0);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("topics with flags", assert => {
|
QUnit.test("topics with flags", async assert => {
|
||||||
visit("/admin/flags/topics");
|
await visit("/admin/flags/topics");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(find(".flagged-topics .flagged-topic").length, 1);
|
|
||||||
assert.equal(find(".flagged-topic .flagged-topic-user").length, 2);
|
|
||||||
assert.equal(find(".flagged-topic div.flag-counts").length, 3);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".flagged-topic .show-details");
|
assert.equal(find(".flagged-topics .flagged-topic").length, 1);
|
||||||
andThen(() => {
|
assert.equal(find(".flagged-topic .flagged-topic-user").length, 2);
|
||||||
assert.equal(currentURL(), "/admin/flags/topics/280");
|
assert.equal(find(".flagged-topic div.flag-counts").length, 3);
|
||||||
});
|
|
||||||
|
await click(".flagged-topic .show-details");
|
||||||
|
|
||||||
|
assert.equal(currentURL(), "/admin/flags/topics/280");
|
||||||
});
|
});
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("Admin - Search Log Term", { loggedIn: true });
|
acceptance("Admin - Search Log Term", { loggedIn: true });
|
||||||
|
|
||||||
QUnit.test("show search log term details", assert => {
|
QUnit.test("show search log term details", async assert => {
|
||||||
visit("/admin/logs/search_logs/term/ruby");
|
await visit("/admin/logs/search_logs/term/ruby");
|
||||||
andThen(() => {
|
|
||||||
assert.ok($("div.search-logs-filter").length, "has the search type filter");
|
assert.ok($("div.search-logs-filter").length, "has the search type filter");
|
||||||
assert.ok(exists("canvas.chartjs-render-monitor"), "has graph canvas");
|
assert.ok(exists("canvas.chartjs-render-monitor"), "has graph canvas");
|
||||||
assert.ok(exists("div.header-search-results"), "has header search results");
|
assert.ok(exists("div.header-search-results"), "has header search results");
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("Admin - Search Logs", { loggedIn: true });
|
acceptance("Admin - Search Logs", { loggedIn: true });
|
||||||
|
|
||||||
QUnit.test("show search logs", assert => {
|
QUnit.test("show search logs", async assert => {
|
||||||
visit("/admin/logs/search_logs");
|
await visit("/admin/logs/search_logs");
|
||||||
andThen(() => {
|
|
||||||
assert.ok($("table.search-logs-list.grid").length, "has the div class");
|
assert.ok($("table.search-logs-list.grid").length, "has the div class");
|
||||||
assert.ok(
|
assert.ok(
|
||||||
exists(".search-logs-list .admin-list-item .col"),
|
exists(".search-logs-list .admin-list-item .col"),
|
||||||
"has a list of search logs"
|
"has a list of search logs"
|
||||||
);
|
);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -2,51 +2,44 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||||||
|
|
||||||
acceptance("Admin - Site Texts", { loggedIn: true });
|
acceptance("Admin - Site Texts", { loggedIn: true });
|
||||||
|
|
||||||
QUnit.test("search for a key", assert => {
|
QUnit.test("search for a key", async assert => {
|
||||||
visit("/admin/customize/site_texts");
|
await visit("/admin/customize/site_texts");
|
||||||
|
|
||||||
fillIn(".site-text-search", "Test");
|
await fillIn(".site-text-search", "Test");
|
||||||
andThen(() => {
|
|
||||||
assert.ok(exists(".site-text"));
|
assert.ok(exists(".site-text"));
|
||||||
assert.ok(exists(".site-text:not(.overridden)"));
|
assert.ok(exists(".site-text:not(.overridden)"));
|
||||||
assert.ok(exists(".site-text.overridden"));
|
assert.ok(exists(".site-text.overridden"));
|
||||||
});
|
|
||||||
|
|
||||||
// Only show overridden
|
// Only show overridden
|
||||||
click(".extra-options input");
|
await click(".extra-options input");
|
||||||
andThen(() => {
|
|
||||||
assert.ok(!exists(".site-text:not(.overridden)"));
|
assert.ok(!exists(".site-text:not(.overridden)"));
|
||||||
assert.ok(exists(".site-text.overridden"));
|
assert.ok(exists(".site-text.overridden"));
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("edit and revert a site text by key", assert => {
|
QUnit.test("edit and revert a site text by key", async assert => {
|
||||||
visit("/admin/customize/site_texts/site.test");
|
await visit("/admin/customize/site_texts/site.test");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(find(".title h3").text(), "site.test");
|
assert.equal(find(".title h3").text(), "site.test");
|
||||||
assert.ok(!exists(".save-messages .saved"));
|
assert.ok(!exists(".save-messages .saved"));
|
||||||
assert.ok(!exists(".save-messages .saved"));
|
assert.ok(!exists(".save-messages .saved"));
|
||||||
assert.ok(!exists(".revert-site-text"));
|
assert.ok(!exists(".revert-site-text"));
|
||||||
});
|
|
||||||
|
|
||||||
// Change the value
|
// Change the value
|
||||||
fillIn(".site-text-value", "New Test Value");
|
await fillIn(".site-text-value", "New Test Value");
|
||||||
click(".save-changes");
|
await click(".save-changes");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists(".save-messages .saved"));
|
||||||
assert.ok(exists(".save-messages .saved"));
|
assert.ok(exists(".revert-site-text"));
|
||||||
assert.ok(exists(".revert-site-text"));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Revert the changes
|
// Revert the changes
|
||||||
click(".revert-site-text");
|
await click(".revert-site-text");
|
||||||
andThen(() => {
|
|
||||||
assert.ok(exists(".bootbox.modal"));
|
|
||||||
});
|
|
||||||
click(".bootbox.modal .btn-primary");
|
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(exists(".bootbox.modal"));
|
||||||
assert.ok(!exists(".save-messages .saved"));
|
|
||||||
assert.ok(!exists(".revert-site-text"));
|
await click(".bootbox.modal .btn-primary");
|
||||||
});
|
|
||||||
|
assert.ok(!exists(".save-messages .saved"));
|
||||||
|
assert.ok(!exists(".revert-site-text"));
|
||||||
});
|
});
|
||||||
|
@ -22,60 +22,52 @@ acceptance("Admin - Suspend User", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("suspend a user - cancel", assert => {
|
QUnit.test("suspend a user - cancel", async assert => {
|
||||||
visit("/admin/users/1234/regular");
|
await visit("/admin/users/1234/regular");
|
||||||
click(".suspend-user");
|
await click(".suspend-user");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(find(".suspend-user-modal:visible").length, 1);
|
||||||
assert.equal(find(".suspend-user-modal:visible").length, 1);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".d-modal-cancel");
|
await click(".d-modal-cancel");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(find(".suspend-user-modal:visible").length, 0);
|
assert.equal(find(".suspend-user-modal:visible").length, 0);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("suspend, then unsuspend a user", assert => {
|
QUnit.test("suspend, then unsuspend a user", async assert => {
|
||||||
const suspendUntilCombobox = selectKit(".suspend-until .combobox");
|
const suspendUntilCombobox = selectKit(".suspend-until .combobox");
|
||||||
|
|
||||||
visit("/admin/flags/active");
|
await visit("/admin/flags/active");
|
||||||
|
|
||||||
visit("/admin/users/1234/regular");
|
await visit("/admin/users/1234/regular");
|
||||||
|
|
||||||
andThen(() => {
|
assert.ok(!exists(".suspension-info"));
|
||||||
assert.ok(!exists(".suspension-info"));
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".suspend-user");
|
await click(".suspend-user");
|
||||||
|
|
||||||
andThen(() => {
|
assert.equal(
|
||||||
assert.equal(
|
find(".perform-suspend[disabled]").length,
|
||||||
find(".perform-suspend[disabled]").length,
|
1,
|
||||||
1,
|
"disabled by default"
|
||||||
"disabled by default"
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
suspendUntilCombobox.expand().selectRowByValue("tomorrow");
|
suspendUntilCombobox.expandAwait();
|
||||||
|
suspendUntilCombobox.selectRowByValueAwait("tomorrow");
|
||||||
|
|
||||||
fillIn(".suspend-reason", "for breaking the rules");
|
await fillIn(".suspend-reason", "for breaking the rules");
|
||||||
fillIn(".suspend-message", "this is an email reason why");
|
await fillIn(".suspend-message", "this is an email reason why");
|
||||||
andThen(() => {
|
|
||||||
assert.equal(
|
|
||||||
find(".perform-suspend[disabled]").length,
|
|
||||||
0,
|
|
||||||
"no longer disabled"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
click(".perform-suspend");
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(find(".suspend-user-modal:visible").length, 0);
|
|
||||||
assert.ok(exists(".suspension-info"));
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".unsuspend-user");
|
assert.equal(
|
||||||
andThen(() => {
|
find(".perform-suspend[disabled]").length,
|
||||||
assert.ok(!exists(".suspension-info"));
|
0,
|
||||||
});
|
"no longer disabled"
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".perform-suspend");
|
||||||
|
|
||||||
|
assert.equal(find(".suspend-user-modal:visible").length, 0);
|
||||||
|
assert.ok(exists(".suspension-info"));
|
||||||
|
|
||||||
|
await click(".unsuspend-user");
|
||||||
|
|
||||||
|
assert.ok(!exists(".suspension-info"));
|
||||||
});
|
});
|
||||||
|
@ -2,10 +2,9 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||||||
|
|
||||||
acceptance("Admin - Users List", { loggedIn: true });
|
acceptance("Admin - Users List", { loggedIn: true });
|
||||||
|
|
||||||
QUnit.test("lists users", assert => {
|
QUnit.test("lists users", async assert => {
|
||||||
visit("/admin/users/list/active");
|
await visit("/admin/users/list/active");
|
||||||
andThen(() => {
|
|
||||||
assert.ok(exists(".users-list .user"));
|
assert.ok(exists(".users-list .user"));
|
||||||
assert.ok(!exists(".user:eq(0) .email small"), "escapes email");
|
assert.ok(!exists(".user:eq(0) .email small"), "escapes email");
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
@ -1,88 +1,81 @@
|
|||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
acceptance("Admin - Watched Words", { loggedIn: true });
|
acceptance("Admin - Watched Words", { loggedIn: true });
|
||||||
|
|
||||||
QUnit.test("list words in groups", assert => {
|
QUnit.test("list words in groups", async assert => {
|
||||||
visit("/admin/logs/watched_words/action/block");
|
await visit("/admin/logs/watched_words/action/block");
|
||||||
andThen(() => {
|
|
||||||
assert.ok(exists(".watched-words-list"));
|
|
||||||
assert.ok(
|
|
||||||
!exists(".watched-words-list .watched-word"),
|
|
||||||
"Don't show bad words by default."
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".admin-controls .controls input[type=text]", "li");
|
assert.ok(exists(".watched-words-list"));
|
||||||
andThen(() => {
|
assert.ok(
|
||||||
assert.equal(
|
!exists(".watched-words-list .watched-word"),
|
||||||
find(".watched-words-list .watched-word").length,
|
"Don't show bad words by default."
|
||||||
1,
|
);
|
||||||
"When filtering, show words even if checkbox is unchecked."
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
fillIn(".admin-controls .controls input[type=text]", "");
|
await fillIn(".admin-controls .controls input[type=text]", "li");
|
||||||
andThen(() => {
|
|
||||||
assert.ok(
|
|
||||||
!exists(".watched-words-list .watched-word"),
|
|
||||||
"Clearing the filter hides words again."
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".show-words-checkbox");
|
assert.equal(
|
||||||
andThen(() => {
|
find(".watched-words-list .watched-word").length,
|
||||||
assert.ok(
|
1,
|
||||||
exists(".watched-words-list .watched-word"),
|
"When filtering, show words even if checkbox is unchecked."
|
||||||
"Always show the words when checkbox is checked."
|
);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
click(".nav-stacked .censor a");
|
await fillIn(".admin-controls .controls input[type=text]", "");
|
||||||
andThen(() => {
|
|
||||||
assert.ok(exists(".watched-words-list"));
|
assert.ok(
|
||||||
assert.ok(!exists(".watched-words-list .watched-word"), "Empty word list.");
|
!exists(".watched-words-list .watched-word"),
|
||||||
});
|
"Clearing the filter hides words again."
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".show-words-checkbox");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
exists(".watched-words-list .watched-word"),
|
||||||
|
"Always show the words when checkbox is checked."
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".nav-stacked .censor a");
|
||||||
|
|
||||||
|
assert.ok(exists(".watched-words-list"));
|
||||||
|
assert.ok(!exists(".watched-words-list .watched-word"), "Empty word list.");
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("add words", assert => {
|
QUnit.test("add words", async assert => {
|
||||||
visit("/admin/logs/watched_words/action/block");
|
await visit("/admin/logs/watched_words/action/block");
|
||||||
andThen(() => {
|
|
||||||
click(".show-words-checkbox");
|
click(".show-words-checkbox");
|
||||||
fillIn(".watched-word-form input", "poutine");
|
fillIn(".watched-word-form input", "poutine");
|
||||||
});
|
|
||||||
click(".watched-word-form button");
|
await click(".watched-word-form button");
|
||||||
andThen(() => {
|
|
||||||
let found = [];
|
let found = [];
|
||||||
_.each(find(".watched-words-list .watched-word"), i => {
|
_.each(find(".watched-words-list .watched-word"), i => {
|
||||||
if (
|
if (
|
||||||
$(i)
|
$(i)
|
||||||
.text()
|
.text()
|
||||||
.trim() === "poutine"
|
.trim() === "poutine"
|
||||||
) {
|
) {
|
||||||
found.push(true);
|
found.push(true);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
assert.equal(found.length, 1);
|
|
||||||
});
|
});
|
||||||
|
assert.equal(found.length, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("remove words", assert => {
|
QUnit.test("remove words", async assert => {
|
||||||
visit("/admin/logs/watched_words/action/block");
|
await visit("/admin/logs/watched_words/action/block");
|
||||||
click(".show-words-checkbox");
|
await click(".show-words-checkbox");
|
||||||
|
|
||||||
let word = null;
|
let word = null;
|
||||||
andThen(() => {
|
|
||||||
_.each(find(".watched-words-list .watched-word"), i => {
|
_.each(find(".watched-words-list .watched-word"), i => {
|
||||||
if (
|
if (
|
||||||
$(i)
|
$(i)
|
||||||
.text()
|
.text()
|
||||||
.trim() === "anise"
|
.trim() === "anise"
|
||||||
) {
|
) {
|
||||||
word = i;
|
word = i;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
click("#" + $(word).attr("id"));
|
|
||||||
});
|
|
||||||
andThen(() => {
|
|
||||||
assert.equal(find(".watched-words-list .watched-word").length, 1);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await click("#" + $(word).attr("id"));
|
||||||
|
|
||||||
|
assert.equal(find(".watched-words-list .watched-word").length, 1);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user