-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AVT]: Added avt tests for OverflowMenu (#14250)
* test: added avt testing for overflowmenu * test: change id to data-testid * test: added the missing test for custom icon * test: removed data-testid * test: checking if the menu is open * test: fixed the test for menu --------- Co-authored-by: Andrea N. Cardona <[email protected]>
- Loading branch information
1 parent
2ccf23b
commit 99470fb
Showing
2 changed files
with
106 additions
and
24 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
e2e/components/OverflowMenu/OverflowMenu-test.avt.e2e.js
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,104 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2023 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const { expect, test } = require('@playwright/test'); | ||
const { visitStory } = require('../../test-utils/storybook'); | ||
|
||
test.describe('OverflowMenu @avt', () => { | ||
test('accessibility-checker', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'OverflowMenu', | ||
id: 'components-overflowmenu--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations('OverflowMenu'); | ||
}); | ||
|
||
test('accessibility-checker render custom icon', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'OverflowMenu', | ||
id: 'components-overflowmenu--render-custom-icon', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations('OverflowMenu-custom-icon'); | ||
}); | ||
|
||
test('accessibility-checker open menu', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'OverflowMenu', | ||
id: 'components-overflowmenu--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page.getByRole('button')).toBeVisible(); | ||
|
||
// Tab and open the toggle button for the OverflowMenu | ||
await page.keyboard.press('Tab'); | ||
const toggleButton = page.getByRole('button'); | ||
await expect(toggleButton).toBeFocused(); | ||
await page.keyboard.press('Enter'); | ||
await expect(page.getByRole('menu')).toBeVisible(); | ||
|
||
await expect(page).toHaveNoACViolations('OverflowMenu-open'); | ||
}); | ||
|
||
test('accessibility-checker render custom icon open', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'OverflowMenu', | ||
id: 'components-overflowmenu--render-custom-icon', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page.getByRole('button')).toBeVisible(); | ||
|
||
// Tab and open the toggle button for the OverflowMenu | ||
await page.keyboard.press('Tab'); | ||
const toggleButton = page.getByRole('button'); | ||
await expect(toggleButton).toBeFocused(); | ||
await page.keyboard.press('Enter'); | ||
await expect(page.getByRole('menu')).toBeVisible(); | ||
|
||
await expect(page).toHaveNoACViolations('OverflowMenu-custom-icon-open'); | ||
}); | ||
|
||
test('overflow-menu - keyboard nav', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'OverflowMenu', | ||
id: 'components-overflowmenu--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page.getByRole('button')).toBeVisible(); | ||
|
||
// Tab and open the OverflowMenu | ||
await page.keyboard.press('Tab'); | ||
const toggleButton = page.getByRole('button'); | ||
await expect(toggleButton).toBeFocused(); | ||
await page.keyboard.press('Enter'); | ||
await expect(page.getByRole('menu')).toBeVisible(); | ||
// Navigation inside the menu | ||
await expect( | ||
page.locator('button').filter({ hasText: 'Stop app' }) | ||
).toBeFocused(); | ||
await page.keyboard.press('ArrowDown'); | ||
await expect( | ||
page.locator('button').filter({ hasText: 'Restart app' }) | ||
).toBeFocused(); | ||
await page.keyboard.press('Enter'); | ||
// focus comes back to the toggle button | ||
await expect(toggleButton).toBeFocused(); | ||
}); | ||
}); |
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