DEV: add site setting type group_list for a list of groups

Add a js test
This commit is contained in:
Neil Lalonde 2019-04-18 13:44:58 -04:00
parent 526e76ced2
commit 1ba72ccab8
7 changed files with 78 additions and 2 deletions

View File

@ -0,0 +1,8 @@
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Component.extend({
@computed()
groupChoices() {
return this.site.get('groups').map(g => g.name);
}
});

View File

@ -13,7 +13,8 @@ const CUSTOM_TYPES = [
"uploaded_image_list",
"compact_list",
"secret_list",
"upload"
"upload",
"group_list"
];
export default Ember.Mixin.create({

View File

@ -0,0 +1,3 @@
{{list-setting settingValue=value choices=groupChoices settingName=setting.setting}}
{{setting-validation-message message=validationMessage}}
<div class='desc'>{{{unbound setting.description}}}</div>

View File

@ -4106,6 +4106,7 @@ en:
clear_filter: "Clear"
add_url: "add URL"
add_host: "add host"
add_group: "add group"
uploaded_image_list:
label: "Edit list"
empty: "There are no pictures yet. Please upload one."

View File

@ -33,6 +33,7 @@ class SiteSettings::TypeSupervisor
uploaded_image_list: 17,
upload: 18,
group: 19,
group_list: 20,
)
end

View File

@ -72,10 +72,15 @@ describe SiteSettings::TypeSupervisor do
it "'uploaded_image_list' should be at 17th position" do
expect(SiteSettings::TypeSupervisor.types[:uploaded_image_list]).to eq(17)
end
it "'upload' should be at the right position" do
expect(SiteSettings::TypeSupervisor.types[:upload]).to eq(18)
end
it "'group' should be at the right position" do
expect(SiteSettings::TypeSupervisor.types[:group]).to eq(19)
end
it "'group_list' should be at the right position" do
expect(SiteSettings::TypeSupervisor.types[:group_list]).to eq(20)
end
end
end

View File

@ -0,0 +1,57 @@
import componentTest from "helpers/component-test";
moduleForComponent("group-list", { integration: true });
componentTest("default", {
template: "{{site-setting setting=setting}}",
beforeEach() {
this.site.groups = [
{
id: 1,
name: "Donuts"
},
{
id: 2,
name: "Cheese cake"
}
];
this.set(
"setting",
Ember.Object.create({
allowsNone: undefined,
category: "foo",
default: "",
description: "Choose groups",
overridden: false,
placeholder: null,
preview: null,
secret: false,
setting: "foo_bar",
type: "group_list",
validValues: undefined,
value: "Donuts"
})
);
},
async test(assert) {
const subject = selectKit(".list-setting");
assert.equal(
subject.header().value(),
"Donuts",
"it selects the setting's value"
);
await subject.expand();
await subject.selectRowByValue("Cheese cake");
assert.equal(
subject.header().value(),
"Donuts,Cheese cake",
"it allows to select a setting from the list of choices"
);
}
});