2019-06-06 16:47:10 +08:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2017-12-22 20:08:12 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
2017-08-28 20:34:04 +08:00
|
|
|
|
2017-12-22 20:08:12 +08:00
|
|
|
acceptance("CategoryChooser", {
|
2017-08-28 20:34:04 +08:00
|
|
|
loggedIn: true,
|
|
|
|
settings: {
|
|
|
|
allow_uncategorized_topics: false
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-19 17:40:42 +08:00
|
|
|
QUnit.test("does not display uncategorized if not allowed", async assert => {
|
2017-12-22 20:08:12 +08:00
|
|
|
const categoryChooser = selectKit(".category-chooser");
|
|
|
|
|
2018-07-19 17:40:42 +08:00
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
2017-08-28 20:34:04 +08:00
|
|
|
|
2018-07-30 04:51:32 +08:00
|
|
|
await categoryChooser.expand();
|
2017-10-20 03:51:08 +08:00
|
|
|
|
2018-07-19 17:40:42 +08:00
|
|
|
assert.ok(categoryChooser.rowByIndex(0).name() !== "uncategorized");
|
2017-08-28 20:34:04 +08:00
|
|
|
});
|
|
|
|
|
2019-05-02 01:24:29 +08:00
|
|
|
QUnit.test("prefill category when category_id is set", async assert => {
|
2019-03-22 07:09:11 +08:00
|
|
|
await visit("/new-topic?category_id=1");
|
2017-08-28 20:34:04 +08:00
|
|
|
|
2019-03-22 07:09:11 +08:00
|
|
|
assert.equal(
|
|
|
|
selectKit(".category-chooser")
|
|
|
|
.header()
|
|
|
|
.value(),
|
|
|
|
1
|
|
|
|
);
|
|
|
|
});
|
2020-05-23 12:56:13 +08:00
|
|
|
|
|
|
|
QUnit.test("filter is case insensitive", async assert => {
|
|
|
|
const categoryChooser = selectKit(".category-chooser");
|
|
|
|
|
|
|
|
await visit("/");
|
|
|
|
await click("#create-topic");
|
|
|
|
await categoryChooser.expand();
|
|
|
|
await categoryChooser.fillInFilter("bug");
|
|
|
|
|
|
|
|
assert.ok(categoryChooser.rows().length, 1);
|
|
|
|
|
|
|
|
await categoryChooser.emptyFilter();
|
|
|
|
await categoryChooser.fillInFilter("Bug");
|
|
|
|
|
|
|
|
assert.ok(categoryChooser.rows().length, 1);
|
|
|
|
});
|