-
-
+
+
+
diff --git a/packages/main/test/pages/MultiInput.html b/packages/main/test/pages/MultiInput.html
index 4c5ad954eed5..937e4b60e29e 100644
--- a/packages/main/test/pages/MultiInput.html
+++ b/packages/main/test/pages/MultiInput.html
@@ -204,6 +204,16 @@ Multi Input - Error
Tokens
+ Multi Input without tokens
+
+
+
+
+ Add more tokens
+
+
+
+
Multi Input with 1 token
@@ -297,6 +307,10 @@ Test value-help-trigger with F4 and Alt + ArrowUp/Down
document.getElementById(id).appendChild(token);
}
+ document.getElementById("add-tokens").addEventListener("click", function(event) {
+ addTokenToMI(createTokenFromText("test"), "no-tokens");
+ });
+
document.getElementById("add-to-single").addEventListener("click", function(event) {
addTokenToMI(createTokenFromText("test"), "single-token");
});
diff --git a/packages/main/test/specs/MultiComboBox.spec.js b/packages/main/test/specs/MultiComboBox.spec.js
index d9fb6376cbfc..3861e9fe31d5 100644
--- a/packages/main/test/specs/MultiComboBox.spec.js
+++ b/packages/main/test/specs/MultiComboBox.spec.js
@@ -237,4 +237,60 @@ describe("MultiComboBox general interaction", () => {
icon.click();
});
});
+
+ describe("ARIA attributes", () => {
+ browser.url("http://localhost:8080/test-resources/pages/MultiComboBox.html");
+
+ it ("aria-describedby value according to the tokens count and the value state", () => {
+ const mcb = $("#mcb-error");
+ const innerInput = mcb.shadow$("input");
+ const invisibleText = mcb.shadow$(".ui5-hidden-text");
+ let tokens = mcb.shadow$$(".ui5-multi-combobox-token");
+ const tokensCountITextId = `${mcb.getProperty("_id")}-hiddenText-nMore`;
+ const valuestateITextId = `${mcb.getProperty("_id")}-valueStateDesc`;
+ const ariaDescribedBy = `${tokensCountITextId} ${valuestateITextId}`;
+
+ assert.strictEqual(tokens.length, 3, "should have three tokens");
+ assert.strictEqual(innerInput.getAttribute("aria-describedby"), ariaDescribedBy, "aria-describedby has a reference for the value state and the tokens count");
+ });
+
+ it ("aria-describedby value according to the tokens count", () => {
+ const mcb = $("#mcb-compact");
+ const innerInput = mcb.shadow$("input");
+ const invisibleText = mcb.shadow$(".ui5-hidden-text");
+ const inivisbleTextId = invisibleText.getProperty("id");
+ let tokens = mcb.shadow$$(".ui5-multi-combobox-token");
+ let resourceBundleText = null;
+
+ assert.strictEqual(tokens.length, 2, "should have two tokens");
+ assert.strictEqual(innerInput.getAttribute("aria-describedby"), inivisbleTextId, "aria-describedby reference is correct");
+ assert.strictEqual(invisibleText.getText(), "Contains 2 tokens", "aria-describedby text is correct");
+
+ mcb.scrollIntoView();
+ innerInput.click();
+ innerInput.keys("Backspace");
+ innerInput.keys("Backspace");
+
+ tokens = mcb.shadow$$(".ui5-multi-combobox-token");
+
+ resourceBundleText = browser.execute(() => {
+ const mcb = document.getElementById("mcb-compact");
+ return mcb.i18nBundle.getText("TOKENIZER_ARIA_CONTAIN_ONE_TOKEN");
+ });
+
+ assert.strictEqual(tokens.length, 1, "should have one token");
+ assert.strictEqual(invisibleText.getText(), resourceBundleText, "aria-describedby text is correct");
+
+ innerInput.keys("Backspace");
+
+ tokens = mcb.shadow$$(".ui5-multi-combobox-token");
+ resourceBundleText = browser.execute(() => {
+ const mcb = document.getElementById("mcb-compact");
+ return mcb.i18nBundle.getText("TOKENIZER_ARIA_CONTAIN_TOKEN");
+ });
+
+ assert.strictEqual(tokens.length, 0, "should not have tokens");
+ assert.strictEqual(invisibleText.getText(), resourceBundleText, "aria-describedby text is correct");
+ });
+ });
});
diff --git a/packages/main/test/specs/MultiInput.spec.js b/packages/main/test/specs/MultiInput.spec.js
index 0af0e8f482f4..0ab998547b55 100644
--- a/packages/main/test/specs/MultiInput.spec.js
+++ b/packages/main/test/specs/MultiInput.spec.js
@@ -124,3 +124,63 @@ describe("MultiInput general interaction", () => {
assert.strictEqual(mi.$$("ui5-token").length, 1, "a token is added after selection");
});
});
+
+describe("ARIA attributes", () => {
+ it ("aria-describedby value according to the tokens count", () => {
+ const mi = $("#no-tokens");
+ const innerInput = mi.shadow$("input");
+ const btn = $("#add-tokens");
+ const invisibleText = mi.shadow$(".ui5-hidden-text");
+ const inivisbleTextId = invisibleText.getProperty("id");
+ let resourceBundleText = null;
+
+ resourceBundleText = browser.execute(() => {
+ const mi = document.getElementById("no-tokens");
+ return mi.i18nBundle.getText("TOKENIZER_ARIA_CONTAIN_TOKEN");
+ });
+
+ assert.strictEqual(mi.$$("ui5-token").length, 0, "should not have tokens");
+ assert.strictEqual(innerInput.getAttribute("aria-describedby"), inivisbleTextId, "aria-describedby reference is correct");
+ assert.strictEqual(invisibleText.getText(), resourceBundleText, "aria-describedby text is correct");
+
+ $("#add-tokens").scrollIntoView();
+ btn.click();
+
+ resourceBundleText = browser.execute(() => {
+ const mi = document.getElementById("no-tokens");
+ return mi.i18nBundle.getText("TOKENIZER_ARIA_CONTAIN_ONE_TOKEN");
+ });
+
+ assert.strictEqual(mi.$$("ui5-token").length, 1, "should have one token");
+ assert.strictEqual(invisibleText.getText(), resourceBundleText, "aria-describedby text is correct");
+
+ btn.click();
+ assert.strictEqual(mi.$$("ui5-token").length, 2, "should have two tokens");
+ assert.strictEqual(invisibleText.getText(), "Contains 2 tokens", "aria-describedby text is correct");
+ });
+
+ it ("aria-describedby value according to the tokens and suggestions count", () => {
+ const mi = $("#suggestion-token");
+ const innerInput = mi.shadow$("input");
+ const tokensCountITextId = `${mi.getProperty("_id")}-hiddenText-nMore`;
+ const suggestionsITextId = `${mi.getProperty("_id")}-suggestionsText`;
+ const suggestionsCountITextId = `${mi.getProperty("_id")}-suggestionsCount`;
+ const ariaDescribedBy = `${tokensCountITextId} ${suggestionsITextId} ${suggestionsCountITextId}`;
+
+ $("#suggestion-token").scrollIntoView();
+ innerInput.click();
+ innerInput.keys("a");
+ innerInput.keys("ArrowDown");
+ innerInput.keys("Enter");
+
+ assert.strictEqual(innerInput.getAttribute("aria-describedby"), ariaDescribedBy, "aria-describedby attribute contains multiple references");
+ });
+
+ it ("aria-roledescription is set properly", () => {
+ const mi = $("#no-tokens");
+ const innerInput = mi.shadow$("input");
+
+ assert.strictEqual(innerInput.getAttribute("aria-roledescription"), "Multi Value Input", "aria-roledescription value is correct");
+ });
+});
+