mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 01:45:07 +08:00
FIX: select-box improvments
- more tests for category-select-box - allows to clear selection - fix positioning on safari - focus on click - do not display uncategorized if not allowed in settings - fix component state impacting other specs - better texts - higher category-select-box on mobile
This commit is contained in:
26
test/javascripts/acceptance/category-select-box-test.js.es6
Normal file
26
test/javascripts/acceptance/category-select-box-test.js.es6
Normal file
@ -0,0 +1,26 @@
|
||||
import { acceptance } from "helpers/qunit-helpers";
|
||||
|
||||
acceptance("CategorySelectBox", {
|
||||
loggedIn: true,
|
||||
settings: {
|
||||
allow_uncategorized_topics: false
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.test("does not display uncategorized if not allowed", assert => {
|
||||
visit("/");
|
||||
click('#create-topic');
|
||||
|
||||
click(".category-select-box .select-box-header");
|
||||
andThen(() => {
|
||||
assert.ok(!exists('.category-select-box .select-box-row[title="uncategorized"]'));
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test("prefill category when category_id is set", assert => {
|
||||
visit("/new-topic?category_id=1");
|
||||
|
||||
andThen(() => {
|
||||
assert.equal(find('.category-select-box .current-selection').html().trim(), "bug");
|
||||
});
|
||||
});
|
@ -313,3 +313,25 @@ componentTest('static headerText', {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
componentTest('clearable selection', {
|
||||
template: '{{select-box value=1 content=content clearable=true}}',
|
||||
|
||||
beforeEach() {
|
||||
this.set("content", [{ id: 1, text: "robin" }, { id: 2, text: "regis" }]);
|
||||
},
|
||||
|
||||
test(assert) {
|
||||
click(".select-box-header");
|
||||
andThen(() => {
|
||||
assert.ok(exists(".select-box-row.is-highlighted"));
|
||||
assert.equal(find(".select-box-header .current-selection").html().trim(), "robin");
|
||||
});
|
||||
|
||||
click(".select-box-header .clear-selection");
|
||||
andThen(() => {
|
||||
assert.notOk(exists(".select-box-row.is-highlighted"));
|
||||
assert.equal(find(".select-box-header .current-selection").html().trim(), "Select...");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user