Skip to content

Commit 74a742e

Browse files
authored
fix(map): exclude Google map iframe from Sa11y tests (#5044)
1 parent 9b527ae commit 74a742e

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

__tests__/a11y/ava.test-template.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const browserPromise = playwright.chromium.launch();
77

88
// Will be replaced by ava.generate-tests.js
99
const portNum = process.env.a11yPort || 9002;
10-
const stories = []; //[{name,id,type},...]
10+
const stories = []; // [{name,id,type},...]
1111

1212
// required macro to allow Playwright tests to run efficiently when using the AVA test runner
1313
async function pageMacro(t, callback) {
@@ -21,30 +21,31 @@ async function pageMacro(t, callback) {
2121
}
2222
}
2323

24-
const prettyPrintObject = (obj) =>
25-
Object.keys(obj).map(key=>`${key}: ${obj[key]}`);
24+
const prettyPrintObject = (obj) =>
25+
Object.keys(obj).map(key => `${key}: ${obj[key]}`);
2626

27-
const generateNodeDescription = ({html, target, failureSummary}) =>
28-
prettyPrintObject({html,target,failureSummary});
27+
const generateNodeDescription = ({ html, target, failureSummary }) =>
28+
prettyPrintObject({ html, target, failureSummary });
2929

30-
const generateDescription = ({id,impact,nodes}, i) =>
30+
const generateDescription = ({ id, impact, nodes }, i) =>
3131
[
32-
`\nRULE ${i+1}:`,
33-
prettyPrintObject({id,impact}).join('\n'),
34-
'\nViolation:',
35-
nodes.map(generateNodeDescription).map(x=>x.join('\n')).flat().join('\n\n'),
32+
`\nRULE ${i + 1}:`,
33+
prettyPrintObject({ id, impact }).join('\n'),
34+
'\nViolation:',
35+
nodes.map(generateNodeDescription).map(x => x.join('\n')).flat().join('\n\n'),
3636
'\nFor more info run these tests locally with `npm run test:a11y`\n'
3737
];
3838

3939
const generateLink = (address) =>
40-
`To view this error, run \`npm start\` and then click this link ${address}`
40+
`To view this error, run \`npm start\` and then click this link ${address}`
4141

4242
// repeatable function to run accessibility(a11y) tests for a story
4343
async function axeTest(t, page, story, address) {
4444
try {
4545
const results = await new AxeBuilder({ page })
4646
.options(sa11yPresetRules.recommended)
4747
.include('#root')
48+
.exclude('#GoogleMapID')
4849
.analyze();
4950

5051
const numViolations = results.violations.length;
@@ -73,14 +74,14 @@ async function axeTest(t, page, story, address) {
7374
t.fail('!! Error occurred: ' + e);
7475
}
7576
}
76-
77+
7778
const runTest = (story) => test(`» a11y: ${story.kind}/${story.name}`, pageMacro, async (t, page) => {
7879
const address = `http://localhost:${portNum}/iframe.html?id=${story.id}&args=&viewMode=story`;
7980
await page.goto(address, { timeout: 0 });
8081
await axeTest(t, page, story, address);
8182
});
8283

8384
// init
84-
(()=>{
85-
stories.forEach(runTest)
86-
})()
85+
(() => {
86+
stories.forEach(runTest)
87+
})()

0 commit comments

Comments
 (0)