Skip to content

Commit

Permalink
Merge pull request w3c#898 from bocoup/skip-failing
Browse files Browse the repository at this point in the history
Use ava '.failing' to skip known failures
  • Loading branch information
mcking65 authored Sep 24, 2018
2 parents 2b4d741 + 92c1189 commit e81e792
Show file tree
Hide file tree
Showing 7 changed files with 449 additions and 433 deletions.
19 changes: 18 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,35 @@ test.after.always(() => {
* Declare a test for a behavior documented on and demonstrated by an
* aria-practices examples page.
*
* @param {String} desc - short description of the test
* @param {String} page - path to the example file
* @param {String} testId - unique identifier for the documented behavior
* within the demonstration page
* @param {Function} body - script which implements the test
*/
const ariaTest = (desc, page, testId, body) => {
_ariaTest(desc, page, testId, body);
};

/**
* Mark a declared test as failing using ava's 'test.failing' functionality.
* If the test passes when it is expected to fail, a failure will be reported.
*
* See arguments for ariaTest.
*/
ariaTest.failing = (desc, page, testId, body) => {
_ariaTest(desc, page, testId, body, 'FAILING');
};

const _ariaTest = (desc, page, testId, body, failing) => {
const absPath = path.resolve(__dirname, '..', 'examples', ...page.split('/'));
const url = 'file://' + absPath;
const selector = '[data-test-id="' + testId + '"]';

const testName = page + ' ' + selector + ': ' + desc;
test.serial(testName, async function (t) {

let runTest = failing ? test.failing : test.serial;
runTest(testName, async function (t) {
t.context.url = url;
await t.context.session.get(url);

Expand Down
44 changes: 22 additions & 22 deletions test/tests/combobox-autocomplete-both.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,36 +232,36 @@ ariaTest('Test up key press with focus on textbox',
await assertAriaSelectedAndActivedescendant(t, ex.textboxSelector, ex.optionsSelector, numOptions - 1);
});


// This test fails due to bug: https://github.com/w3c/aria-practices/issues/821
// Uncomment when the bug is fixed.
ariaTest.failing('Test up key press with focus on listbox',
exampleFile, 'listbox-key-up-arrow', async (t) => {

// ariaTest('Test up key press with focus on listbox',
// exampleFile, 'listbox-key-up-arrow', async (t) => {
t.plan(3);

// t.plan(3);
// Send 'a' to text box, then send ARROW_UP to textbox to textbox to put focus in textbox
// Up arrow should move selection to the last item in the list
await t.context.session
.findElement(By.css(ex.textboxSelector))
.sendKeys('a', Key.ARROW_UP);

// // Send 'a' to text box, then send ARROW_UP to textbox to textbox to put focus in textbox
// // Up arrow should move selection to the last item in the list
// await t.context.session
// .findElement(By.css(ex.textboxSelector))
// .sendKeys('a', Key.ARROW_UP);
// Test that ARROW_UP moves active descendant focus up one item in the listbox
for (let index = ex.numAOptions - 1; index > 0 ; index--) {
let oldfocus = await t.context.session
.findElement(By.css(ex.textboxSelector))
.getAttribute('aria-activedescendant');

// // Test that ARROW_UP moves active descendant focus up one item in the listbox
// for (let index = ex.numAOptions - 1; index > 0 ; index--) {
// let oldfocus = await t.context.session
// .findElement(By.css(ex.textboxSelector))
// .getAttribute('aria-activedescendant');
// Send Key
await t.context.session
.findElement(By.css(ex.textboxSelector))
.sendKeys(Key.ARROW_UP);

// // Send Key
// await t.context.session
// .findElement(By.css(ex.textboxSelector))
// .sendKeys(Key.ARROW_UP);
await waitForFocusChange(t, ex.textboxSelector, oldfocus);

// await waitForFocusChange(t, ex.textboxSelector, oldfocus);
await assertAriaSelectedAndActivedescendant(t, ex.textboxSelector, ex.optionsSelector, index);
}
});

// await assertAriaSelectedAndActivedescendant(t, ex.textboxSelector, ex.optionsSelector, index);
// }
// });

ariaTest('Test enter key press with focus on textbox',
exampleFile, 'textbox-key-enter', async (t) => {
Expand Down
91 changes: 48 additions & 43 deletions test/tests/grid-combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,18 +206,17 @@ ariaTest('role "row" exists within grid element', exampleFile, 'row-role', async
});

// This test fails due to bug: https://github.com/w3c/aria-practices/issues/859
ariaTest.failing('"aria-selected" attribute on row element', exampleFile, 'row-aria-selected', async (t) => {
t.plan(2);

// ariaTest('"aria-selected" attribute on row element', exampleFile, 'row-aria-selected', async (t) => {
// t.plan(2);

// // Send key "a"
// await t.context.session.findElement(By.css(ex.textboxSelector)).sendKeys('a');
// await assertAttributeDNE(t, ex.rowSelector + ':nth-of-type(1)', 'aria-selected');
// Send key "a"
await t.context.session.findElement(By.css(ex.textboxSelector)).sendKeys('a');
await assertAttributeDNE(t, ex.rowSelector + ':nth-of-type(1)', 'aria-selected');

// // Send key ARROW_DOWN to selected first option
// await t.context.session.findElement(By.css(ex.textboxSelector)).sendKeys(Key.ARROW_DOWN);
// await assertAttributeValues(t, ex.rowSelector + ':nth-of-type(1)', 'aria-selected', 'true');
// });
// Send key ARROW_DOWN to selected first option
await t.context.session.findElement(By.css(ex.textboxSelector)).sendKeys(Key.ARROW_DOWN);
await assertAttributeValues(t, ex.rowSelector + ':nth-of-type(1)', 'aria-selected', 'true');
});

ariaTest('role "gridcell" exists within row element', exampleFile, 'gridcell-role', async (t) => {
t.plan(1);
Expand Down Expand Up @@ -259,7 +258,7 @@ ariaTest('Test down key press with focus on textbox',
.sendKeys('a', Key.ARROW_DOWN);

// Account for race condition
await waitForFocusChange(t, ex.textboxSelector, null);
await waitForFocusChange(t, ex.textboxSelector, '');

// Check that the grid is displayed
t.true(
Expand Down Expand Up @@ -381,7 +380,7 @@ ariaTest('Test up key press with focus on textbox',
.sendKeys('a', Key.ARROW_UP);

// Account for race condition
await waitForFocusChange(t, ex.textboxSelector, null);
await waitForFocusChange(t, ex.textboxSelector, '');

// Check that the grid is displayed
t.true(
Expand Down Expand Up @@ -550,38 +549,44 @@ ariaTest('Test escape key press with focus on textbox',
});

// This test fails due to bug: https://github.com/w3c/aria-practices/issues/860
ariaTest.failing('Test escape key press with focus on popup',
exampleFile, 'popup-key-escape', async (t) => {
t.plan(2);

// Send key "a" then key "ARROW_DOWN to put the focus on the grid,
// then key ESCAPE to the textbox

await t.context.session
.findElement(By.css(ex.textboxSelector))
.sendKeys('a', Key.ARROW_DOWN);

// ariaTest('Test escape key press with focus on popup',
// exampleFile, 'popup-key-escape', async (t) => {
// t.plan(2);

// // Send key "a" then key "ARROW_DOWN to put the focus on the grid,
// // then key ESCAPE to the textbox

// await t.context.session
// .findElement(By.css(ex.textboxSelector))
// .sendKeys('a', Key.ARROW_DOWN, Key.ESCAPE);

// // Wait for gridbox to close
// await t.context.session.wait(
// async function () {
// return ! (await t.context.session.findElement(By.css(ex.gridSelector)).isDisplayed());
// },
// t.context.waitTime,
// 'Timeout waiting for gridbox to close afer escape'
// );

// // Confirm the grid is closed and the textboxed is cleared
// await assertAttributeValues(t, ex.comboboxSelector, 'aria-expanded', 'false');
// t.is(
// await t.context.session
// .findElement(By.css(ex.textboxSelector))
// .getAttribute('value'),
// '',
// 'In grid key press "ESCAPE" should result in clearing of the textbox'
// );

// });
await waitForFocusChange(t, ex.textboxSelector, '');

await t.context.session
.findElement(By.css(ex.textboxSelector))
.sendKeys(Key.ESCAPE);

// Wait for gridbox to close
await t.context.session.wait(
async function () {
return !(await t.context.session.findElement(By.css(ex.gridSelector)).isDisplayed());
},
t.context.waitTime,
'Timeout waiting for gridbox to close afer escape'
);

// Confirm the grid is closed and the textboxed is cleared
await assertAttributeValues(t, ex.comboboxSelector, 'aria-expanded', 'false');

t.is(
await t.context.session
.findElement(By.css(ex.textboxSelector))
.getAttribute('value'),
'',
'In grid key press "ESCAPE" should result in clearing of the textbox'
);

});

ariaTest('left arrow from focus on list puts focus on grid and moves cursor right',
exampleFile, 'popup-key-left-arrow', async (t) => {
Expand Down
44 changes: 21 additions & 23 deletions test/tests/listbox-combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,35 +177,33 @@ ariaTest('Test aria-expanded on listbox correlates with listbox',
});

// This test fails due to bug: https://github.com/w3c/aria-practices/issues/785
// Uncomment when the bug is fixed.
ariaTest.failing('Test id attribute on textbox referred to by label element',
exampleFile, 'textbox-id', async (t) => {

// ariaTest('Test id attribute on textbox referred to by label element',
// exampleFile, 'textbox-id', async (t) => {

// t.plan(9);
t.plan(9);

// for (let exId in pageExamples) {
// let ex = pageExamples[exId];
for (let exId in pageExamples) {
let ex = pageExamples[exId];

// const labelEl = await t.context.session.findElement(By.css('#' + exId + ' label'));
// const textboxEl = await t.context.session.findElement(By.css(ex.textboxSelector));
const labelEl = await t.context.session.findElement(By.css('#' + exId + ' label'));
const textboxEl = await t.context.session.findElement(By.css(ex.textboxSelector));

// t.truthy(
// await labelEl.getAttribute('for'),
// 'Attribute "for" should exist on label element in example: ' + exId
// );
t.truthy(
await labelEl.getAttribute('for'),
'Attribute "for" should exist on label element in example: ' + exId
);

// t.truthy(
// await textboxEl.getAttribute('id'),
// 'Attribute "id" should exist on textbox element: ' + exId
// );
t.truthy(
await textboxEl.getAttribute('id'),
'Attribute "id" should exist on textbox element: ' + exId
);

// t.true(
// await labelEl.getAttribute('for') === await textboxEl.getAttribute('id'),
// 'Attribute "for" on label element should match the "id" on the textbox element in example:' + exId
// );
// }
// });
t.true(
await labelEl.getAttribute('for') === await textboxEl.getAttribute('id'),
'Attribute "for" on label element should match the "id" on the textbox element in example:' + exId
);
}
});

ariaTest('Test aria-autocomplete="list" attribute on textbox',
exampleFile, 'aria-autocomplete-list', async (t) => {
Expand Down
Loading

0 comments on commit e81e792

Please sign in to comment.