Skip to content

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

DEV: migrate acceptance tests to async await - admin, about, account created (#6111)

Maja Komel6aa2eb19d42d
diff --git a/test/javascripts/acceptance/about-test.js.es6 b/test/javascripts/acceptance/about-test.js.es6
index 9393c068a3b..3c2d39a6853 100644
--- a/test/javascripts/acceptance/about-test.js.es6
+++ b/test/javascripts/acceptance/about-test.js.es6
@@ -1,12 +1,11 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("About");
-QUnit.test("viewing", assert => {
- visit("/about");
- andThen(() => {
- assert.ok($("body.about-page").length, "has body class");
- assert.ok(exists(".about.admins .user-info"), "has admins");
- assert.ok(exists(".about.moderators .user-info"), "has moderators");
- assert.ok(exists(".about.stats tr td"), "has stats");
- });
+QUnit.test("viewing", async assert => {
+ await visit("/about");
+
+ assert.ok($("body.about-page").length, "has body class");
+ assert.ok(exists(".about.admins .user-info"), "has admins");
+ assert.ok(exists(".about.moderators .user-info"), "has moderators");
+ assert.ok(exists(".about.stats tr td"), "has stats");
});
diff --git a/test/javascripts/acceptance/account-created-test.js.es6 b/test/javascripts/acceptance/account-created-test.js.es6
index a009024bb42..e9d57d9389a 100644
--- a/test/javascripts/acceptance/account-created-test.js.es6
+++ b/test/javascripts/acceptance/account-created-test.js.es6
@@ -3,97 +3,90 @@ import PreloadStore from "preload-store";
acceptance("Account Created");
-QUnit.test("account created - message", assert => {
+QUnit.test("account created - message", async assert => {
PreloadStore.store("accountCreated", {
message: "Hello World"
});
- visit("/u/account-created");
-
- andThen(() => {
- assert.ok(exists(".account-created"));
- assert.equal(
- find(".account-created .ac-message")
- .text()
- .trim(),
- "Hello World",
- "it displays the message"
- );
- assert.notOk(exists(".activation-controls"));
- });
+ 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"
+ );
+ assert.notOk(exists(".activation-controls"));
});
-QUnit.test("account created - resend email", assert => {
+QUnit.test("account created - resend email", async assert => {
PreloadStore.store("accountCreated", {
message: "Hello World",
username: "eviltrout",
show_controls: true
});
- visit("/u/account-created");
-
- andThen(() => {
- assert.ok(exists(".account-created"));
- assert.equal(
- find(".account-created .ac-message")
- .text()
- .trim(),
- "Hello World",
- "it displays the message"
- );
- });
- click(".activation-controls .resend");
- andThen(() => {
- assert.equal(currentPath(), "account-created.resent");
- const email = find(".account-created .ac-message b").text();
- assert.equal(email, "[email protected]");
- });
+ 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"
+ );
+
+ await click(".activation-controls .resend");
+
+ assert.equal(currentPath(), "account-created.resent");
+ const email = find(".account-created .ac-message b").text();
+ assert.equal(email, "[email protected]");
});
-QUnit.test("account created - update email - cancel", assert => {
+QUnit.test("account created - update email - cancel", async assert => {
PreloadStore.store("accountCreated", {
message: "Hello World",
username: "eviltrout",
show_controls: true
});
- visit("/u/account-created");
- click(".activation-controls .edit-email");
- andThen(() => {
- assert.equal(currentPath(), "account-created.edit-email");
- assert.ok(find(".activation-controls .btn-primary:disabled").length);
- });
+ await visit("/u/account-created");
- click(".activation-controls .edit-cancel");
- andThen(() => {
- assert.equal(currentPath(), "account-created.index");
- });
+ await click(".activation-controls .edit-email");
+
+ 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", {
message: "Hello World",
username: "eviltrout",
show_controls: true
});
- visit("/u/account-created");
- click(".activation-controls .edit-email");
- andThen(() => {
- assert.ok(find(".activation-controls .btn-primary:disabled").length);
- });
+ await visit("/u/account-created");
- fillIn(".activate-new-email", "[email protected]");
- andThen(() => {
- assert.notOk(find(".activation-controls .btn-primary:disabled").length);
- });
+ await click(".activation-controls .edit-email");
- click(".activation-controls .btn-primary");
- andThen(() => {
- assert.equal(currentPath(), "account-created.resent");
- const email = find(".account-created .ac-message b").text();
- assert.equal(email, "[email protected]");
- });
+ assert.ok(find(".activation-controls .btn-primary:disabled").length);
+
+ await fillIn(".activate-new-email", "[email protected]");
+
+ 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, "[email protected]");
});
diff --git a/test/javascripts/acceptance/admin-flags-test.js.es6 b/test/javascripts/acceptance/admin-flags-test.js.es6
index 29405e1a0c5..b50280d4243 100644
--- a/test/javascripts/acceptance/admin-flags-test.js.es6
+++ b/test/javascripts/acceptance/admin-flags-test.js.es6
@@ -1,139 +1,128 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Flagging", { loggedIn: true });
-QUnit.test("flagged posts", assert => {
- visit("/admin/flags/active");
- andThen(() => {
- assert.equal(find(".flagged-posts .flagged-post").length, 1);
- assert.equal(
- find(".flagged-post .flag-user").length,
- 1,
- "shows who flagged it"
- );
- 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-user-details .username").length,
- 1,
- "shows the flagged username"
- );
- });
+QUnit.test("flagged posts", async assert => {
+ await visit("/admin/flags/active");
+
+ assert.equal(find(".flagged-posts .flagged-post").length, 1);
+ assert.equal(
+ find(".flagged-post .flag-user").length,
+ 1,
+ "shows who flagged it"
+ );
+ 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-user-details .username").length,
+ 1,
+ "shows the flagged username"
+ );
});
-QUnit.test("flagged posts - agree", assert => {
+QUnit.test("flagged posts - agree", async assert => {
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(
- find(".admin-flags .flagged-post").length,
- 0,
- "post was removed"
- );
- });
+ assert.equal(
+ find(".admin-flags .flagged-post").length,
+ 0,
+ "post was removed"
+ );
});
-QUnit.test("flagged posts - agree + hide", assert => {
+QUnit.test("flagged posts - agree + hide", async assert => {
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(
- find(".admin-flags .flagged-post").length,
- 0,
- "post was removed"
- );
- });
+ assert.equal(
+ find(".admin-flags .flagged-post").length,
+ 0,
+ "post was removed"
+ );
});
-QUnit.test("flagged posts - agree + deleteSpammer", assert => {
+QUnit.test("flagged posts - agree + deleteSpammer", async assert => {
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(
- find(".admin-flags .flagged-post").length,
- 0,
- "post was removed"
- );
- });
+ assert.equal(
+ find(".admin-flags .flagged-post").length,
+ 0,
+ "post was removed"
+ );
});
-QUnit.test("flagged posts - disagree", assert => {
- visit("/admin/flags/active");
- click(".disagree-flag");
- andThen(() => {
- assert.equal(find(".admin-flags .flagged-post").length, 0);
- });
+QUnit.test("flagged posts - disagree", async assert => {
+ await visit("/admin/flags/active");
+ await click(".disagree-flag");
+
+ assert.equal(find(".admin-flags .flagged-post").length, 0);
});
-QUnit.test("flagged posts - defer", assert => {
- visit("/admin/flags/active");
- click(".defer-flag");
- andThen(() => {
- assert.equal(find(".admin-flags .flagged-post").length, 0);
- });
+QUnit.test("flagged posts - defer", async assert => {
+ await visit("/admin/flags/active");
+ await click(".defer-flag");
+
+ 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");
- 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");
- 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");
- 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 => {
- 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");
- andThen(() => {
- assert.equal(currentURL(), "/admin/flags/topics/280");
- });
+QUnit.test("topics with flags", async assert => {
+ await visit("/admin/flags/topics");
+
+ 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);
+
+ await click(".flagged-topic .show-details");
+
+ assert.equal(currentURL(), "/admin/flags/topics/280");
});
diff --git a/test/javascripts/acceptance/admin-search-log-term-test.js.es6 b/test/javascripts/acceptance/admin-search-log-term-test.js.es6
index 36c78642159..29fce43b875 100644
--- a/test/javascripts/acceptance/admin-search-log-term-test.js.es6
+++ b/test/javascripts/acceptance/admin-search-log-term-test.js.es6
@@ -1,11 +1,10 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Search Log Term", { loggedIn: true });
-QUnit.test("show search log term details", assert => {
- visit("/admin/logs/search_logs/term/ruby");
- andThen(() => {
- 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("div.header-search-results"), "has header search results");
- });
+QUnit.test("show search log term details", async assert => {
+ await visit("/admin/logs/search_logs/term/ruby");
+
+ 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("div.header-search-results"), "has header search results");
});
diff --git a/test/javascripts/acceptance/admin-search-logs-test.js.es6 b/test/javascripts/acceptance/admin-search-logs-test.js.es6
index 1dfff67720f..78b69a2dae7 100644
--- a/test/javascripts/acceptance/admin-search-logs-test.js.es6
+++ b/test/javascripts/acceptance/admin-search-logs-test.js.es6
@@ -1,13 +1,12 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Search Logs", { loggedIn: true });
-QUnit.test("show search logs", assert => {
- visit("/admin/logs/search_logs");
- andThen(() => {
- assert.ok($("table.search-logs-list.grid").length, "has the div class");
- assert.ok(
- exists(".search-logs-list .admin-list-item .col"),
- "has a list of search logs"
- );
- });
+QUnit.test("show search logs", async assert => {
+ await visit("/admin/logs/search_logs");
+
+ assert.ok($("table.search-logs-list.grid").length, "has the div class");
+ assert.ok(
+ exists(".search-logs-list .admin-list-item .col"),
+ "has a list of search logs"
+ );
});
diff --git a/test/javascripts/acceptance/admin-site-text-test.js.es6 b/test/javascripts/acceptance/admin-site-text-test.js.es6
index 3146e0db41e..766dd1d745a 100644
--- a/test/javascripts/acceptance/admin-site-text-test.js.es6
+++ b/test/javascripts/acceptance/admin-site-text-test.js.es6
@@ -2,51 +2,44 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Site Texts", { loggedIn: true });
-QUnit.test("search for a key", assert => {
- visit("/admin/customize/site_texts");
+QUnit.test("search for a key", async assert => {
+ await visit("/admin/customize/site_texts");
- fillIn(".site-text-search", "Test");
- andThen(() => {
- assert.ok(exists(".site-text"));
- assert.ok(exists(".site-text:not(.overridden)"));
- assert.ok(exists(".site-text.overridden"));
- });
+ await fillIn(".site-text-search", "Test");
+
+ assert.ok(exists(".site-text"));
+ assert.ok(exists(".site-text:not(.overridden)"));
+ assert.ok(exists(".site-text.overridden"));
// Only show overridden
- click(".extra-options input");
- andThen(() => {
- assert.ok(!exists(".site-text:not(.overridden)"));
- assert.ok(exists(".site-text.overridden"));
- });
+ await click(".extra-options input");
+
+ assert.ok(!exists(".site-text:not(.overridden)"));
+ assert.ok(exists(".site-text.overridden"));
});
-QUnit.test("edit and revert a site text by key", assert => {
- visit("/admin/customize/site_texts/site.test");
- andThen(() => {
- assert.equal(find(".title h3").text(), "site.test");
- assert.ok(!exists(".save-messages .saved"));
- assert.ok(!exists(".save-messages .saved"));
- assert.ok(!exists(".revert-site-text"));
- });
+QUnit.test("edit and revert a site text by key", async assert => {
+ await visit("/admin/customize/site_texts/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(".revert-site-text"));
// Change the value
- fillIn(".site-text-value", "New Test Value");
- click(".save-changes");
+ await fillIn(".site-text-value", "New Test Value");
+ await click(".save-changes");
- andThen(() => {
- assert.ok(exists(".save-messages .saved"));
- assert.ok(exists(".revert-site-text"));
- });
+ assert.ok(exists(".save-messages .saved"));
+ assert.ok(exists(".revert-site-text"));
// Revert the changes
- click(".revert-site-text");
- andThen(() => {
- assert.ok(exists(".bootbox.modal"));
- });
- click(".bootbox.modal .btn-primary");
-
- andThen(() => {
- assert.ok(!exists(".save-messages .saved"));
- assert.ok(!exists(".revert-site-text"));
- });
+ await click(".revert-site-text");
+
+ assert.ok(exists(".bootbox.modal"));
+
+ await click(".bootbox.modal .btn-primary");
+
+ assert.ok(!exists(".save-messages .saved"));
+ assert.ok(!exists(".revert-site-text"));
});
diff --git a/test/javascripts/acceptance/admin-suspend-user-test.js.es6 b/test/javascripts/acceptance/admin-suspend-user-test.js.es6
index 055d890c051..3107ac9eab7 100644
--- a/test/javascripts/acceptance/admin-suspend-user-test.js.es6
+++ b/test/javascripts/acceptance/admin-suspend-user-test.js.es6
@@ -22,60 +22,52 @@ acceptance("Admin - Suspend User", {
}
});
-QUnit.test("suspend a user - cancel", assert => {
- visit("/admin/users/1234/regular");
- click(".suspend-user");
-
- andThen(() => {
- assert.equal(find(".suspend-user-modal:visible").length, 1);
- });
-
- click(".d-modal-cancel");
- andThen(() => {
- assert.equal(find(".suspend-user-modal:visible").length, 0);
- });
+QUnit.test("suspend a user - cancel", async assert => {
+ await visit("/admin/users/1234/regular");
+ await click(".suspend-user");
+
+ assert.equal(find(".suspend-user-modal:visible").length, 1);
+
+ await click(".d-modal-cancel");
+
+ 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");
- 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(
- find(".perform-suspend[disabled]").length,
- 1,
- "disabled by default"
- );
- });
+ assert.equal(
+ find(".perform-suspend[disabled]").length,
+ 1,
+ "disabled by default"
+ );
- suspendUntilCombobox.expand().selectRowByValue("tomorrow");
+ suspendUntilCombobox.expandAwait();
+ suspendUntilCombobox.selectRowByValueAwait("tomorrow");
- fillIn(".suspend-reason", "for breaking the rules");
- 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");
- andThen(() => {
- assert.ok(!exists(".suspension-info"));
- });
+ await fillIn(".suspend-reason", "for breaking the rules");
+ await fillIn(".suspend-message", "this is an email reason why");
+
+ assert.equal(
+ find(".perform-suspend[disabled]").length,
+ 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"));
});
diff --git a/test/javascripts/acceptance/admin-users-list-test.js.es6 b/test/javascripts/acceptance/admin-users-list-test.js.es6
index 20fd19f20ef..0bbfb491daa 100644
--- a/test/javascripts/acceptance/admin-users-list-test.js.es6
+++ b/test/javascripts/acceptance/admin-users-list-test.js.es6
@@ -2,10 +2,9 @@ import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Users List", { loggedIn: true });
-QUnit.test("lists users", assert => {
- visit("/admin/users/list/active");
- andThen(() => {
- assert.ok(exists(".users-list .user"));
- assert.ok(!exists(".user:eq(0) .email small"), "escapes email");
- });
+QUnit.test("lists users", async assert => {
+ await visit("/admin/users/list/active");
+
+ assert.ok(exists(".users-list .user"));
+ assert.ok(!exists(".user:eq(0) .email small"), "escapes email");
});
diff --git a/test/javascripts/acceptance/admin-watched-words-test.js.es6 b/test/javascripts/acceptance/admin-watched-words-test.js.es6
index 9554705ce48..6e5773b1db7 100644
--- a/test/javascripts/acceptance/admin-watched-words-test.js.es6
+++ b/test/javascripts/acceptance/admin-watched-words-test.js.es6
@@ -1,88 +1,81 @@
import { acceptance } from "helpers/qunit-helpers";
acceptance("Admin - Watched Words", { loggedIn: true });
-QUnit.test("list words in groups", assert => {
- 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."
- );
- });
+QUnit.test("list words in groups", async assert => {
+ await visit("/admin/logs/watched_words/action/block");
- fillIn(".admin-controls .controls input[type=text]", "li");
- andThen(() => {
- assert.equal(
- find(".watched-words-list .watched-word").length,
- 1,
- "When filtering, show words even if checkbox is unchecked."
- );
- });
+ 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]", "");
- andThen(() => {
- assert.ok(
- !exists(".watched-words-list .watched-word"),
- "Clearing the filter hides words again."
- );
- });
+ await fillIn(".admin-controls .controls input[type=text]", "li");
- click(".show-words-checkbox");
- andThen(() => {
- assert.ok(
- exists(".watched-words-list .watched-word"),
- "Always show the words when checkbox is checked."
- );
- });
+ assert.equal(
+ find(".watched-words-list .watched-word").length,
+ 1,
+ "When filtering, show words even if checkbox is unchecked."
+ );
- click(".nav-stacked .censor a");
- andThen(() => {
- assert.ok(exists(".watched-words-list"));
- assert.ok(!exists(".watched-words-list .watched-word"), "Empty word list.");
- });
+ await fillIn(".admin-controls .controls input[type=text]", "");
+
+ assert.ok(
+ !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 => {
- visit("/admin/logs/watched_words/action/block");
- andThen(() => {
- click(".show-words-checkbox");
- fillIn(".watched-word-form input", "poutine");
- });
- click(".watched-word-form button");
- andThen(() => {
- let found = [];
- _.each(find(".watched-words-list .watched-word"), i => {
- if (
- $(i)
- .text()
- .trim() === "poutine"
- ) {
- found.push(true);
- }
- });
- assert.equal(found.length, 1);
+QUnit.test("add words", async assert => {
+ await visit("/admin/logs/watched_words/action/block");
+
+ click(".show-words-checkbox");
+ fillIn(".watched-word-form input", "poutine");
+
+ await click(".watched-word-form button");
+
+ let found = [];
+ _.each(find(".watched-words-list .watched-word"), i => {
+ if (
+ $(i)
+ .text()
+ .trim() === "poutine"
+ ) {
+ found.push(true);
+ }
});
+ assert.equal(found.length, 1);
});
-QUnit.test("remove words", assert => {
- visit("/admin/logs/watched_words/action/block");
- click(".show-words-checkbox");
+QUnit.test("remove words", async assert => {
+ await visit("/admin/logs/watched_words/action/block");
+ await click(".show-words-checkbox");
let word = null;
- andThen(() => {
- _.each(find(".watched-words-list .watched-word"), i => {
- if (
- $(i)
- .text()
- .trim() === "anise"
- ) {
- word = i;
- }
- });
- click("#" + $(word).attr("id"));
- });
- andThen(() => {
- assert.equal(find(".watched-words-list .watched-word").length, 1);
+
+ _.each(find(".watched-words-list .watched-word"), i => {
+ if (
+ $(i)
+ .text()
+ .trim() === "anise"
+ ) {
+ word = i;
+ }
});
+
+ await click("#" + $(word).attr("id"));
+
+ assert.equal(find(".watched-words-list .watched-word").length, 1);
});