2019-06-06 10:47:10 +02:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2018-06-15 17:03:24 +02:00
|
|
|
import componentTest from "helpers/component-test";
|
2017-10-19 12:51:08 -07:00
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
moduleForComponent("category-chooser", {
|
2017-12-22 13:08:12 +01:00
|
|
|
integration: true,
|
|
|
|
beforeEach: function() {
|
2018-06-15 17:03:24 +02:00
|
|
|
this.set("subject", selectKit());
|
2017-12-22 13:08:12 +01:00
|
|
|
}
|
|
|
|
});
|
2017-10-19 12:51:08 -07:00
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with value", {
|
|
|
|
template: "{{category-chooser value=2}}",
|
2017-10-19 12:51:08 -07:00
|
|
|
|
|
|
|
test(assert) {
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.header().value(), 2);
|
|
|
|
assert.equal(this.subject.header().title(), "feature");
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with excludeCategoryId", {
|
|
|
|
template: "{{category-chooser excludeCategoryId=2}}",
|
2017-10-19 12:51:08 -07:00
|
|
|
|
2018-07-24 20:12:09 +02:00
|
|
|
async test(assert) {
|
2019-05-27 10:15:39 +02:00
|
|
|
await this.subject.expand();
|
2018-06-15 17:03:24 +02:00
|
|
|
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.notOk(this.subject.rowByValue(2).exists());
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with scopedCategoryId", {
|
|
|
|
template: "{{category-chooser scopedCategoryId=2}}",
|
2017-10-19 12:51:08 -07:00
|
|
|
|
2018-07-24 20:12:09 +02:00
|
|
|
async test(assert) {
|
2019-05-27 10:15:39 +02:00
|
|
|
await this.subject.expand();
|
2018-07-24 20:12:09 +02:00
|
|
|
|
|
|
|
assert.equal(
|
2019-05-27 10:42:53 +02:00
|
|
|
this.subject.rowByIndex(0).title(),
|
2018-07-24 20:12:09 +02:00
|
|
|
"Discussion about features or potential features of Discourse: how they work, why they work, etc."
|
|
|
|
);
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.rowByIndex(0).value(), 2);
|
2018-07-24 20:12:09 +02:00
|
|
|
assert.equal(
|
2019-05-27 10:42:53 +02:00
|
|
|
this.subject.rowByIndex(1).title(),
|
2018-07-24 20:12:09 +02:00
|
|
|
"My idea here is to have mini specs for features we would like built but have no bandwidth to build"
|
|
|
|
);
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.rowByIndex(1).value(), 26);
|
2019-05-27 10:15:39 +02:00
|
|
|
assert.equal(this.subject.rows().length, 2);
|
2019-01-10 21:19:53 +05:30
|
|
|
|
2019-06-24 10:45:30 +02:00
|
|
|
await this.subject.fillInFilter("spec");
|
2019-01-10 21:19:53 +05:30
|
|
|
|
2019-06-24 10:45:30 +02:00
|
|
|
assert.equal(this.subject.rows().length, 1);
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with allowUncategorized=null", {
|
|
|
|
template: "{{category-chooser allowUncategorized=null}}",
|
2017-10-19 12:51:08 -07:00
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.allow_uncategorized_topics = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.header().value(), null);
|
|
|
|
assert.equal(this.subject.header().title(), "category");
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with allowUncategorized=null rootNone=true", {
|
|
|
|
template: "{{category-chooser allowUncategorized=null rootNone=true}}",
|
2017-10-19 12:51:08 -07:00
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.allow_uncategorized_topics = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.header().value(), null);
|
|
|
|
assert.equal(this.subject.header().title(), "category");
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with disallowed uncategorized, rootNone and rootNoneLabel", {
|
|
|
|
template:
|
|
|
|
'{{category-chooser allowUncategorized=null rootNone=true rootNoneLabel="test.root"}}',
|
2017-10-19 12:51:08 -07:00
|
|
|
|
|
|
|
beforeEach() {
|
2018-06-15 17:03:24 +02:00
|
|
|
I18n.translations[I18n.locale].js.test = { root: "root none label" };
|
2017-10-19 12:51:08 -07:00
|
|
|
this.siteSettings.allow_uncategorized_topics = false;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.header().value(), null);
|
|
|
|
assert.equal(this.subject.header().title(), "category");
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with allowed uncategorized", {
|
|
|
|
template: "{{category-chooser allowUncategorized=true}}",
|
2017-10-19 12:51:08 -07:00
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.allow_uncategorized_topics = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.header().value(), null);
|
|
|
|
assert.equal(this.subject.header().title(), "uncategorized");
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with allowed uncategorized and rootNone", {
|
|
|
|
template: "{{category-chooser allowUncategorized=true rootNone=true}}",
|
2017-10-19 12:51:08 -07:00
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
this.siteSettings.allow_uncategorized_topics = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.header().value(), null);
|
|
|
|
assert.equal(this.subject.header().title(), "(no category)");
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 17:03:24 +02:00
|
|
|
componentTest("with allowed uncategorized rootNone and rootNoneLabel", {
|
|
|
|
template:
|
|
|
|
'{{category-chooser allowUncategorized=true rootNone=true rootNoneLabel="test.root"}}',
|
2017-10-19 12:51:08 -07:00
|
|
|
|
|
|
|
beforeEach() {
|
2018-06-15 17:03:24 +02:00
|
|
|
I18n.translations[I18n.locale].js.test = { root: "root none label" };
|
2017-10-19 12:51:08 -07:00
|
|
|
this.siteSettings.allow_uncategorized_topics = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2019-05-27 10:42:53 +02:00
|
|
|
assert.equal(this.subject.header().value(), null);
|
|
|
|
assert.equal(this.subject.header().title(), "root none label");
|
2017-10-19 12:51:08 -07:00
|
|
|
}
|
|
|
|
});
|