Skip to content

Commit

Permalink
issue 1619: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Valerie Young committed Jan 12, 2021
1 parent a32a1a6 commit 733c67f
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions test/tests/combobox_autocomplete-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ex = {
optionsSelector: '#ex1 [role="option"]',
buttonSelector: '#ex1 button',
numAOptions: 5,
exampleHeadingSelector: '.example-header',
};

const waitForFocusChange = async (t, textboxSelector, originalFocus) => {
Expand Down Expand Up @@ -850,6 +851,92 @@ ariaTest(
}
);

ariaTest(
'Clicking outside of textbox and listbox when focus is on listbox closes listbox',
exampleFile,
'test-additional-behavior',
async (t) => {
// Send key "a" to open listbox then key "ARROW_DOWN" to put the focus on the listbox
await t.context.session
.findElement(By.css(ex.textboxSelector))
.sendKeys('a', Key.ARROW_DOWN);

// click outside the listbox
await t.context.session
.findElement(By.css(ex.exampleHeadingSelector))
.click();

await t.context.session.wait(
async function () {
let listbox = await t.context.session.findElement(
By.css(ex.listboxSelector)
);
return !(await listbox.isDisplayed());
},
t.context.waitTime,
'Error waiting for listbox to close after outside click'
);

// Confirm the listbox is closed and the textboxed is cleared
await assertAttributeValues(
t,
ex.textboxSelector,
'aria-expanded',
'false'
);
t.is(
await t.context.session
.findElement(By.css(ex.textboxSelector))
.getAttribute('value'),
'a',
'Click outside of a textbox will close the testbox without selecting the highlighted value'
);
}
);

ariaTest(
'Clicking outside of textbox and listbox when focus is on textbox closes listbox',
exampleFile,
'test-additional-behavior',
async (t) => {
// Send key "a" to open listbox to put focus on textbox
await t.context.session
.findElement(By.css(ex.textboxSelector))
.sendKeys('a');

// click outside the listbox
await t.context.session
.findElement(By.css(ex.exampleHeadingSelector))
.click();

await t.context.session.wait(
async function () {
let listbox = await t.context.session.findElement(
By.css(ex.listboxSelector)
);
return !(await listbox.isDisplayed());
},
t.context.waitTime,
'Error waiting for listbox to close after outside click'
);

// Confirm the listbox is closed and the textboxed is cleared
await assertAttributeValues(
t,
ex.textboxSelector,
'aria-expanded',
'false'
);
t.is(
await t.context.session
.findElement(By.css(ex.textboxSelector))
.getAttribute('value'),
'a',
'Click outside of a textbox will close the testbox without selecting the highlighted value'
);
}
);

ariaTest(
'left arrow from focus on list puts focus on listbox and moves cursor right',
exampleFile,
Expand Down

0 comments on commit 733c67f

Please sign in to comment.