forked from mozilla/bedrock
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a11y test for side menu component
- Loading branch information
1 parent
53c52ca
commit 774684a
Showing
8 changed files
with
270 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const openPage = require('../../../scripts/open-page'); | ||
const { createReport, scanPageElement } = require('../includes/helpers'); | ||
const { footerLocator } = require('../includes/locators'); | ||
const { test, expect } = require('@playwright/test'); | ||
const testURL = '/en-US/'; | ||
|
||
test.describe( | ||
'Footer (desktop)', | ||
{ | ||
tag: '@a11y' | ||
}, | ||
() => { | ||
test.beforeEach(async ({ page, browserName }) => { | ||
await openPage(testURL, page, browserName); | ||
}); | ||
|
||
test('should not have any detectable a11y issues', async ({ page }) => { | ||
const results = await scanPageElement(page, footerLocator); | ||
createReport('component', 'footer-desktop', results); | ||
expect(results.violations.length).toEqual(0); | ||
}); | ||
} | ||
); | ||
|
||
test.describe( | ||
'Footer (mobile)', | ||
{ | ||
tag: '@a11y' | ||
}, | ||
() => { | ||
test.use({ viewport: { width: 360, height: 780 } }); | ||
|
||
test.beforeEach(async ({ page, browserName }) => { | ||
await openPage(testURL, page, browserName); | ||
}); | ||
|
||
test('should not have any detectable a11y issues', async ({ page }) => { | ||
const footerHeadingCompany = page.getByTestId( | ||
'footer-heading-company' | ||
); | ||
const footerListCompany = page.getByTestId('footer-list-company'); | ||
|
||
// Open Company section | ||
await expect(footerListCompany).not.toBeVisible(); | ||
await footerHeadingCompany.click(); | ||
await expect(footerListCompany).toBeVisible(); | ||
|
||
const results = await scanPageElement(page, footerLocator); | ||
createReport('component', 'footer-mobile', results); | ||
expect(results.violations.length).toEqual(0); | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const openPage = require('../../../scripts/open-page'); | ||
const { createReport, scanPageElement } = require('../includes/helpers'); | ||
const { navigationLocator } = require('../includes/locators'); | ||
const { test, expect } = require('@playwright/test'); | ||
const testURL = '/en-US/'; | ||
|
||
test.describe( | ||
'Navigation (desktop)', | ||
{ | ||
tag: '@a11y' | ||
}, | ||
() => { | ||
test.beforeEach(async ({ page, browserName }) => { | ||
await openPage(testURL, page, browserName); | ||
}); | ||
|
||
test('should not have any detectable a11y issues', async ({ page }) => { | ||
const firefoxLink = page.getByTestId('navigation-link-firefox'); | ||
const firefoxMenu = page.getByTestId('navigation-menu-firefox'); | ||
|
||
// Hover over Firefox link to open menu | ||
await expect(firefoxMenu).not.toBeVisible(); | ||
await firefoxLink.hover(); | ||
await expect(firefoxMenu).toBeVisible(); | ||
|
||
const results = await scanPageElement(page, navigationLocator); | ||
createReport('component', 'navigation-desktop', results); | ||
expect(results.violations.length).toEqual(0); | ||
}); | ||
} | ||
); | ||
|
||
test.describe( | ||
'Navigation (mobile)', | ||
{ | ||
tag: '@a11y' | ||
}, | ||
() => { | ||
test.use({ viewport: { width: 360, height: 780 } }); | ||
|
||
test.beforeEach(async ({ page, browserName }) => { | ||
await openPage(testURL, page, browserName); | ||
}); | ||
|
||
test('should not have any detectable a11y issues', async ({ page }) => { | ||
const navigationMenuButton = page.getByTestId( | ||
'navigation-menu-button' | ||
); | ||
const navigationMenuItems = page.getByTestId( | ||
'navigation-menu-items' | ||
); | ||
const firefoxLink = page.getByTestId('navigation-link-firefox'); | ||
const firefoxMenu = page.getByTestId('navigation-menu-firefox'); | ||
|
||
// Open navigation menu | ||
await expect(navigationMenuItems).not.toBeVisible(); | ||
await navigationMenuButton.click(); | ||
await expect(navigationMenuItems).toBeVisible(); | ||
|
||
// Open Firefox menu | ||
await expect(firefoxMenu).not.toBeVisible(); | ||
await firefoxLink.click(); | ||
await expect(firefoxMenu).toBeVisible(); | ||
|
||
const results = await scanPageElement(page, navigationLocator); | ||
createReport('component', 'navigation-mobile', results); | ||
expect(results.violations.length).toEqual(0); | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const openPage = require('../../../scripts/open-page'); | ||
const { createReport, scanPageElement } = require('../includes/helpers'); | ||
const { sideMenuLocator } = require('../includes/locators'); | ||
const { test, expect } = require('@playwright/test'); | ||
const testURL = '/en-US/privacy/'; | ||
|
||
test.describe( | ||
'Side Menu (desktop)', | ||
{ | ||
tag: '@a11y' | ||
}, | ||
() => { | ||
test.beforeEach(async ({ page, browserName }) => { | ||
await openPage(testURL, page, browserName); | ||
}); | ||
|
||
test('should not have any detectable a11y issues', async ({ page }) => { | ||
const results = await scanPageElement(page, sideMenuLocator); | ||
createReport('component', 'side-menu-desktop', results); | ||
expect(results.violations.length).toEqual(0); | ||
}); | ||
} | ||
); | ||
|
||
test.describe( | ||
'Side Menu (mobile)', | ||
{ | ||
tag: '@a11y' | ||
}, | ||
() => { | ||
test.use({ viewport: { width: 360, height: 780 } }); | ||
|
||
test.beforeEach(async ({ page, browserName }) => { | ||
await openPage(testURL, page, browserName); | ||
}); | ||
|
||
test('should not have any detectable a11y issues', async ({ page }) => { | ||
const sidebarMenuToggle = page.getByTestId('sidebar-menu-toggle'); | ||
const sidebarMenuMain = page.getByTestId('sidebar-menu-main'); | ||
|
||
// Open side menu panel | ||
await expect(sidebarMenuMain).not.toBeVisible(); | ||
await sidebarMenuToggle.click(); | ||
await expect(sidebarMenuMain).toBeVisible(); | ||
|
||
const results = await scanPageElement(page, sideMenuLocator); | ||
createReport('component', 'side-menu-mobile', results); | ||
expect(results.violations.length).toEqual(0); | ||
}); | ||
} | ||
); |
Oops, something went wrong.