A platform for community discussion. Free, open, simple.
FIX: ensures category chooser is case insensitive (#9850)
Joffrey JAFFEUX66960563ea9a
diff --git a/app/assets/javascripts/select-kit/addon/components/category-chooser.js b/app/assets/javascripts/select-kit/addon/components/category-chooser.jsindex f36e8be2d32..72d0167ac09 100644--- a/app/assets/javascripts/select-kit/addon/components/category-chooser.js+++ b/app/assets/javascripts/select-kit/addon/components/category-chooser.js@@ -67,6 +67,7 @@ export default ComboBoxComponent.extend({search(filter) {if (filter) {+ filter = filter.toLowerCase();return this.content.filter(item => {const category = Category.findById(this.getValue(item));const categoryName = this.getName(item);diff --git a/test/javascripts/acceptance/category-chooser-test.js b/test/javascripts/acceptance/category-chooser-test.jsindex b6772ab7710..2247c8cbee7 100644--- a/test/javascripts/acceptance/category-chooser-test.js+++ b/test/javascripts/acceptance/category-chooser-test.js@@ -29,3 +29,19 @@ QUnit.test("prefill category when category_id is set", async assert => {1);});++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);+});diff --git a/test/javascripts/helpers/select-kit-helper.js b/test/javascripts/helpers/select-kit-helper.jsindex 5d80b8f0b37..f7959913263 100644--- a/test/javascripts/helpers/select-kit-helper.js+++ b/test/javascripts/helpers/select-kit-helper.js@@ -32,6 +32,11 @@ async function selectKitFillInFilter(filter, selector) {);}+async function selectKitEmptyFilter(selector) {+ checkSelectKitIsNotCollapsed(selector);+ await fillIn(`${selector} .filter-input`, "");+}+async function selectKitSelectRowByValue(value, selector) {checkSelectKitIsNotCollapsed(selector);await click(`${selector} .select-kit-row[data-value='${value}']`);@@ -180,6 +185,10 @@ export default function selectKit(selector) {await selectKitFillInFilter(filter, selector);},+ async emptyFilter() {+ await selectKitEmptyFilter(selector);+ },+async keyboard(value, target) {await keyboardHelper(value, target, selector);},