2017-06-28 16:56:44 -04:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
acceptance("Admin - Watched Words", { loggedIn: true });
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("list words in groups", async (assert) => {
|
|
|
|
await visit("/admin/logs/watched_words/action/block");
|
2017-06-28 16:56:44 -04:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.ok(exists(".watched-words-list"));
|
|
|
|
assert.ok(
|
|
|
|
!exists(".watched-words-list .watched-word"),
|
|
|
|
"Don't show bad words by default."
|
|
|
|
);
|
2017-06-28 16:56:44 -04:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
await fillIn(".admin-controls .controls input[type=text]", "li");
|
2017-06-28 16:56:44 -04:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.equal(
|
|
|
|
find(".watched-words-list .watched-word").length,
|
|
|
|
1,
|
|
|
|
"When filtering, show words even if checkbox is unchecked."
|
|
|
|
);
|
2017-06-28 16:56:44 -04:00
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
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.");
|
2017-06-28 16:56:44 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
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 = [];
|
2018-11-20 08:46:58 -05:00
|
|
|
$.each(find(".watched-words-list .watched-word"), (index, elem) => {
|
2018-07-19 05:35:10 -04:00
|
|
|
if ($(elem).text().trim() === "poutine") {
|
|
|
|
found.push(true);
|
|
|
|
}
|
2017-06-28 16:56:44 -04:00
|
|
|
});
|
2018-07-19 05:35:10 -04:00
|
|
|
assert.equal(found.length, 1);
|
2017-06-28 16:56:44 -04:00
|
|
|
});
|
|
|
|
|
2018-07-19 05:35:10 -04:00
|
|
|
QUnit.test("remove words", async (assert) => {
|
|
|
|
await visit("/admin/logs/watched_words/action/block");
|
|
|
|
await click(".show-words-checkbox");
|
2017-06-28 16:56:44 -04:00
|
|
|
|
|
|
|
let word = null;
|
2018-07-19 05:35:10 -04:00
|
|
|
|
2018-11-20 08:46:58 -05:00
|
|
|
$.each(find(".watched-words-list .watched-word"), (index, elem) => {
|
2018-07-19 05:35:10 -04:00
|
|
|
if ($(elem).text().trim() === "anise") {
|
2018-11-20 08:46:58 -05:00
|
|
|
word = elem;
|
2018-07-19 05:35:10 -04:00
|
|
|
}
|
2017-06-28 16:56:44 -04:00
|
|
|
});
|
2018-07-19 05:35:10 -04:00
|
|
|
|
|
|
|
await click("#" + $(word).attr("id"));
|
|
|
|
|
2019-07-15 04:38:54 -04:00
|
|
|
assert.equal(find(".watched-words-list .watched-word").length, 2);
|
2017-06-28 16:56:44 -04:00
|
|
|
});
|