-
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 keyboard nav test
Breadcrumb
(#14639)
* test: added keyboard navigation test * Apply suggestions from code review * test: changed test name * test: added timeout to avoid github action fail * test: increase time by 50s * test: added timeout * test: changed expected test * test: checking if the link is enabled --------- Co-authored-by: Taylor Jones <[email protected]>
- Loading branch information
1 parent
33f414f
commit 616e981
Showing
2 changed files
with
111 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/** | ||
* 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'; | ||
|
||
import { expect, test } from '@playwright/test'; | ||
import { visitStory } from '../../test-utils/storybook'; | ||
|
||
test.describe('breadcrumb @avt', () => { | ||
test('@avt-default-state', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'Breadcrumb', | ||
id: 'components-breadcrumb--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations('Breadcrumb'); | ||
}); | ||
|
||
test('@avt-advanced-states with overflow menu', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'Breadcrumb', | ||
id: 'components-breadcrumb--breadcrumb-with-overflow-menu', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations('Breadcrumb-with-overflow-menu'); | ||
}); | ||
|
||
test('@avt-advanced-states skeleton', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'Breadcrumb', | ||
id: 'components-breadcrumb--skeleton', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page).toHaveNoACViolations('Breadcrumb-skeleton'); | ||
}); | ||
|
||
test('@avt-keyboard-nav default', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'Breadcrumb', | ||
id: 'components-breadcrumb--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page.getByText('Breadcrumb 1')).toBeVisible(); | ||
await page.keyboard.press('Tab'); | ||
await expect(page.getByText('Breadcrumb 1')).toBeFocused(); | ||
// Checking if the link is enabled to be clicked on | ||
await expect(page.getByText('Breadcrumb 1')).toBeEnabled(); | ||
}); | ||
|
||
test('@avt-keyboard-nav - item without href prop', async ({ page }) => { | ||
await visitStory(page, { | ||
component: 'Breadcrumb', | ||
id: 'components-breadcrumb--default', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
await expect(page.getByText('Breadcrumb 3')).toBeVisible(); | ||
await page.keyboard.press('Tab'); | ||
await page.keyboard.press('Tab'); | ||
await page.keyboard.press('Tab'); | ||
await expect(page.getByText('Breadcrumb 3')).toBeFocused(); | ||
|
||
// The Breadcrumb 4 should not be focusable | ||
await page.keyboard.press('Tab'); | ||
await expect(page.getByText('Breadcrumb 4')).not.toBeFocused(); | ||
}); | ||
|
||
test('@avt-keyboard-nav with overflow menu keyboard navigation', async ({ | ||
page, | ||
}) => { | ||
await visitStory(page, { | ||
component: 'Breadcrumb', | ||
id: 'components-breadcrumb--breadcrumb-with-overflow-menu', | ||
globals: { | ||
theme: 'white', | ||
}, | ||
}); | ||
|
||
await expect(page.getByText('Breadcrumb 1')).toBeVisible(); | ||
await page.keyboard.press('Tab'); | ||
await page.keyboard.press('Tab'); | ||
await page.keyboard.press('Tab'); | ||
|
||
// Verify icon-description | ||
await expect(page.getByText('Options')).toBeVisible(); | ||
|
||
// Entering and navigating the options | ||
await page.keyboard.press('Enter'); | ||
await expect( | ||
page.locator('button', { hasText: 'Breadcrumb 3' }) | ||
).toBeFocused(); | ||
await page.keyboard.press('ArrowDown'); | ||
await expect( | ||
page.locator('button', { hasText: 'Breadcrumb 4' }) | ||
).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