2017-06-29 04:56:44 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
acceptance("Admin - Watched Words", { loggedIn: true });
|
|
|
|
|
|
|
|
QUnit.test("list words in groups", assert => {
|
2017-08-01 05:06:26 +08:00
|
|
|
visit("/admin/logs/watched_words/action/block");
|
2017-06-29 04:56:44 +08:00
|
|
|
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."
|
|
|
|
);
|
2017-06-29 04:56:44 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
fillIn(".admin-controls .controls input[type=text]", "li");
|
2017-06-29 04:56:44 +08:00
|
|
|
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."
|
|
|
|
);
|
2017-06-29 04:56:44 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
fillIn(".admin-controls .controls input[type=text]", "");
|
2017-06-29 04:56:44 +08:00
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.ok(
|
|
|
|
!exists(".watched-words-list .watched-word"),
|
|
|
|
"Clearing the filter hides words again."
|
|
|
|
);
|
2017-06-29 04:56:44 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
click(".show-words-checkbox");
|
2017-06-29 04:56:44 +08:00
|
|
|
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."
|
|
|
|
);
|
2017-06-29 04:56:44 +08:00
|
|
|
});
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
click(".nav-stacked .censor a");
|
2017-06-29 04:56:44 +08:00
|
|
|
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.");
|
2017-06-29 04:56:44 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("add words", assert => {
|
2017-08-01 05:06:26 +08:00
|
|
|
visit("/admin/logs/watched_words/action/block");
|
2017-06-29 04:56:44 +08:00
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
click(".show-words-checkbox");
|
|
|
|
fillIn(".watched-word-form input", "poutine");
|
2017-06-29 04:56:44 +08:00
|
|
|
});
|
2018-06-15 23:03:24 +08:00
|
|
|
click(".watched-word-form button");
|
2017-06-29 04:56:44 +08:00
|
|
|
andThen(() => {
|
|
|
|
let found = [];
|
2018-06-15 23:03:24 +08:00
|
|
|
_.each(find(".watched-words-list .watched-word"), i => {
|
|
|
|
if (
|
|
|
|
$(i)
|
|
|
|
.text()
|
|
|
|
.trim() === "poutine"
|
|
|
|
) {
|
2017-06-29 04:56:44 +08:00
|
|
|
found.push(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
assert.equal(found.length, 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.test("remove words", assert => {
|
2017-08-01 05:06:26 +08:00
|
|
|
visit("/admin/logs/watched_words/action/block");
|
2018-06-15 23:03:24 +08:00
|
|
|
click(".show-words-checkbox");
|
2017-06-29 04:56:44 +08:00
|
|
|
|
|
|
|
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"
|
|
|
|
) {
|
2017-06-29 04:56:44 +08:00
|
|
|
word = i;
|
|
|
|
}
|
|
|
|
});
|
2018-06-15 23:03:24 +08:00
|
|
|
click("#" + $(word).attr("id"));
|
2017-06-29 04:56:44 +08:00
|
|
|
});
|
|
|
|
andThen(() => {
|
2018-06-15 23:03:24 +08:00
|
|
|
assert.equal(find(".watched-words-list .watched-word").length, 1);
|
2017-06-29 04:56:44 +08:00
|
|
|
});
|
|
|
|
});
|