FIX: ensures mini-tag-chooser is respecting max_tags_per_topic (#9018)

This commit is contained in:
Joffrey JAFFEUX
2020-02-21 12:16:05 +01:00
committed by GitHub
parent 8a031f19dc
commit e807dff6fc
2 changed files with 66 additions and 4 deletions

View File

@ -0,0 +1,63 @@
import componentTest from "helpers/component-test";
import { testSelectKitModule } from "./select-kit-test-helper";
testSelectKitModule("mini-tag-chooser");
function template() {
return `{{mini-tag-chooser value=value}}`;
}
componentTest("displays tags", {
template: template(),
beforeEach() {
this.set("value", ["foo", "bar"]);
},
async test(assert) {
assert.equal(this.subject.header().value(), "foo,bar");
}
});
componentTest("create a tag", {
template: template(),
beforeEach() {
this.set("value", ["foo", "bar"]);
},
async test(assert) {
assert.equal(this.subject.header().value(), "foo,bar");
await this.subject.expand();
await this.subject.fillInFilter("monkey");
await this.subject.keyboard("enter");
assert.equal(this.subject.header().value(), "foo,bar,monkey");
}
});
componentTest("max_tags_per_topic", {
template: template(),
beforeEach() {
this.set("value", ["foo", "bar"]);
this.siteSettings.max_tags_per_topic = 2;
},
async test(assert) {
assert.equal(this.subject.header().value(), "foo,bar");
await this.subject.expand();
await this.subject.fillInFilter("baz");
await this.subject.keyboard("enter");
const error = find(".select-kit-error").text();
assert.equal(
error,
I18n.t("select_kit.max_content_reached", {
count: this.siteSettings.max_tags_per_topic
})
);
}
});