discourse/test/javascripts/acceptance/admin-watched-words-test.js.es6

89 lines
2.2 KiB
Plaintext
Raw Normal View History

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(() => {
2018-06-15 23:03:24 +08:00
assert.ok(exists(".watched-words-list"));
assert.ok(
!exists(".watched-words-list .watched-word"),
"Don't show bad words by default."
);
});
2018-06-15 23:03:24 +08:00
fillIn(".admin-controls .controls input[type=text]", "li");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.equal(
find(".watched-words-list .watched-word").length,
1,
"When filtering, show words even if checkbox is unchecked."
);
});
2018-06-15 23:03:24 +08:00
fillIn(".admin-controls .controls input[type=text]", "");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
!exists(".watched-words-list .watched-word"),
"Clearing the filter hides words again."
);
});
2018-06-15 23:03:24 +08:00
click(".show-words-checkbox");
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.ok(
exists(".watched-words-list .watched-word"),
"Always show the words when checkbox is checked."
);
});
2018-06-15 23:03:24 +08:00
click(".nav-stacked .censor a");
andThen(() => {
2018-06-15 23:03:24 +08:00
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(() => {
2018-06-15 23:03:24 +08:00
click(".show-words-checkbox");
fillIn(".watched-word-form input", "poutine");
});
2018-06-15 23:03:24 +08:00
click(".watched-word-form button");
andThen(() => {
let found = [];
2018-06-15 23:03:24 +08:00
_.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");
2018-06-15 23:03:24 +08:00
click(".show-words-checkbox");
let word = null;
andThen(() => {
2018-06-15 23:03:24 +08:00
_.each(find(".watched-words-list .watched-word"), i => {
if (
$(i)
.text()
.trim() === "anise"
) {
word = i;
}
});
2018-06-15 23:03:24 +08:00
click("#" + $(word).attr("id"));
});
andThen(() => {
2018-06-15 23:03:24 +08:00
assert.equal(find(".watched-words-list .watched-word").length, 1);
});
});