diff --git a/spec/e2e/accessibility_spec.js b/spec/e2e/accessibility_spec.js index 7e84f1ca3..6ee0f3a0e 100644 --- a/spec/e2e/accessibility_spec.js +++ b/spec/e2e/accessibility_spec.js @@ -19,22 +19,44 @@ describe('accessibility', () => { .map((url) => new URL(url).pathname) .filter((path) => !EXCLUDE_PATTERNS.some((pattern) => pattern.test(path))); - test.each(paths)( - '%s', - async (path) => { - await goto(path); - const results = await new AxePuppeteer(page) - .disableRules('frame-tested') - .exclude('iframe') - .exclude('.footer-nav') // See: LG-4038 (TODO: Remove with implementation of LG-4038) - .analyze(); - expect(results).toHaveNoViolations(); - - const links = await getLinks(page); - links.forEach((a) => { - expect(a).toNotHaveTargetBlank(); + /** @type {Record>} */ + const viewports = { + small: { width: 800, height: 600 }, + large: { width: 1280, height: 800 }, + }; + + for (const [label, viewport] of Object.entries(viewports)) { + describe(`${label} viewport`, () => { + /** @type {import('puppeteer').Viewport} */ + let originalViewport; + + beforeAll(async () => { + originalViewport = page.viewport(); + await page.setViewport(viewport); + }); + + afterAll(async () => { + await page.setViewport(originalViewport); }); - }, - TEST_TIMEOUT_MS, - ); + + test.each(paths)( + '%s', + async (path) => { + await goto(path); + const results = await new AxePuppeteer(page) + .disableRules('frame-tested') + .exclude('iframe') + .exclude('.footer-nav') // See: LG-4038 (TODO: Remove with implementation of LG-4038) + .analyze(); + expect(results).toHaveNoViolations(); + + const links = await getLinks(page); + links.forEach((a) => { + expect(a).toNotHaveTargetBlank(); + }); + }, + TEST_TIMEOUT_MS, + ); + }); + } });