-
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.
Merge branch 'main' into renovate/downshift-8.x
- Loading branch information
Showing
11 changed files
with
196 additions
and
24 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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# Percy config | ||
version: 2 | ||
snapshot: | ||
widths: | ||
|
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 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,137 @@ | ||
/** | ||
* Copyright IBM Corp. 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('MenuButton @avt', () => { | ||
test('@avt-default-state MenuButton', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'MenuButton', | ||
id: 'components-menubutton--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations('MenuButton'); | ||
}); | ||
|
||
test('@avt-advanced-states MenuButton with danger', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'MenuButton', | ||
id: 'components-menubutton--with-danger', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations('MenuButton-with-danger'); | ||
}); | ||
|
||
test('@avt-advanced-states MenuButton with dividers', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'MenuButton', | ||
id: 'components-menubutton--with-dividers', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations('MenuButton-with-dividers'); | ||
}); | ||
|
||
test('@avt-keyboard-nav MenuButton', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'MenuButton', | ||
id: 'components-menubutton--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
|
||
const actionButton = page.getByRole('button', { name: 'Action' }); | ||
await expect(actionButton).toBeVisible(); | ||
|
||
await page.keyboard.press('Tab'); | ||
await expect(actionButton).toBeFocused(); | ||
|
||
// Entering the menu button | ||
await page.keyboard.press('Enter'); | ||
await expect(page.getByRole('menuitem').first()).toBeFocused(); | ||
await page.keyboard.press('ArrowDown'); | ||
await expect(page.getByRole('menuitem').nth(1)).toBeFocused(); | ||
// Skip the disabled item and come back to the first item | ||
await page.keyboard.press('ArrowDown'); | ||
await expect(page.getByRole('menuitem').first()).toBeFocused(); | ||
|
||
// Closing by selecting an item and focusing on the action button | ||
await page.keyboard.press('Enter'); | ||
await expect(actionButton).toBeFocused(); | ||
}); | ||
|
||
test('@avt-keyboard-nav MenuButton with danger', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'MenuButton', | ||
id: 'components-menubutton--with-danger', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
|
||
const actionButton = page.getByRole('button', { name: 'Action' }); | ||
await expect(actionButton).toBeVisible(); | ||
|
||
await page.keyboard.press('Tab'); | ||
await expect(actionButton).toBeFocused(); | ||
|
||
// Entering the menu button | ||
await page.keyboard.press('Enter'); | ||
await expect(page.getByRole('menuitem').first()).toBeFocused(); | ||
await page.keyboard.press('ArrowDown'); | ||
await page.keyboard.press('ArrowDown'); | ||
await page.keyboard.press('ArrowDown'); | ||
|
||
// Validate danger button | ||
await expect(page.getByRole('menuitem').last()).toBeFocused(); | ||
await expect(page.getByText('Danger action')).toBeVisible(); | ||
|
||
// Closing by selecting an item and focusing on the action button | ||
await page.keyboard.press('Enter'); | ||
await expect(actionButton).toBeFocused(); | ||
}); | ||
|
||
test('@avt-keyboard-nav MenuButton with dividers', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'MenuButton', | ||
id: 'components-menubutton--with-dividers', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
|
||
const actionButton = page.getByRole('button', { name: 'Action' }); | ||
await expect(actionButton).toBeVisible(); | ||
|
||
await page.keyboard.press('Tab'); | ||
await expect(actionButton).toBeFocused(); | ||
|
||
// Entering the menu button | ||
await page.keyboard.press('Enter'); | ||
await expect(page.getByRole('menuitem').first()).toBeFocused(); | ||
await page.keyboard.press('ArrowDown'); | ||
await page.keyboard.press('ArrowDown'); | ||
await page.keyboard.press('ArrowDown'); | ||
await page.keyboard.press('ArrowDown'); | ||
await page.keyboard.press('ArrowDown'); | ||
await expect(page.getByRole('menuitem').last()).toBeFocused(); | ||
expect(page.getByRole('separator')).toBeTruthy(); | ||
|
||
// Closing by selecting an item and focusing on the action button | ||
await page.keyboard.press('Enter'); | ||
await expect(actionButton).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
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 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 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 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 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 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