Unverified Commit 1655ef7d authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #1807 from hypothesis/fix-spurious-color-contrast-failures

Assume white background by default in a11y tests
parents 3a573c8f d03dbf64
......@@ -77,8 +77,7 @@ describe('AnnotationDocumentInfo', () => {
assert.equal(domain.text(), '(www.example.com)');
});
// FIXME-A11Y
it.skip(
it(
'should pass a11y checks',
checkAccessibility({
content: () => {
......
......@@ -144,8 +144,7 @@ describe('AnnotationShareInfo', () => {
});
});
// FIXME-A11Y
it.skip(
it(
'should pass a11y checks',
checkAccessibility({
content: () => createAnnotationShareInfo(),
......
......@@ -185,8 +185,7 @@ describe('ShareAnnotationsPanel', () => {
});
});
// FIXME-A11Y
it.skip(
it(
'should pass a11y checks',
checkAccessibility({
content: () => createShareAnnotationsPanel(),
......
......@@ -9,10 +9,17 @@ import { isValidElement } from 'preact';
* @prop {() => import('preact').VNode|ReactWrapper} content -
* A function that returns the rendered output to test or an Enzyme wrapper
* created using Enzyme's `mount` function.
* @prop {string} [backgroundColor] -
* Background color onto which to render the element. This can affect the
* result of color contrast tests. Defaults to white.
*/
async function testScenario(elementOrWrapper) {
async function testScenario(
elementOrWrapper,
{ backgroundColor = 'white' } = {}
) {
const container = document.createElement('div');
container.style.backgroundColor = backgroundColor;
document.body.appendChild(container);
let wrapper;
......@@ -58,7 +65,7 @@ export function checkAccessibility(scenarios) {
}
return async () => {
for (let { name = 'default', content } of scenarios) {
for (let { name = 'default', content, ...config } of scenarios) {
if (typeof content !== 'function') {
throw new Error(
`"content" key for accessibility scenario "${name}" should be a function but is a ${typeof content}`
......@@ -76,7 +83,7 @@ export function checkAccessibility(scenarios) {
);
}
const violations = await testScenario(elementOrWrapper);
const violations = await testScenario(elementOrWrapper, config);
assert.deepEqual(
violations,
[],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment