Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feat: Add Playwright Test for Vue components #3115

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
99bad87
feat(playwright): inital setup playwright for vue
carwack Nov 28, 2024
176731e
chore(pw): add pw reports to git ignore
carwack Dec 4, 2024
a3e5e31
refactor(avatar): add id for story and variants for clean Histoire url
carwack Dec 4, 2024
ce048e2
test(avatar): add first pw test
carwack Dec 4, 2024
e98db6a
feat(pw): create gotoStory util function
carwack Dec 4, 2024
d646141
test(avatar): add more tests
carwack Dec 4, 2024
38a8de8
test(avatar): add snapshot testing with screenshots in pw
carwack Dec 7, 2024
e43596c
refactor(avatar): update examples to use all same github user avatar url
carwack Dec 7, 2024
95ee07d
test(avatar): add screenshots for pw avatar tests
carwack Dec 7, 2024
1125d25
feat(playwright): add axe core playwright dep
carwack Dec 7, 2024
b4b3737
test(avatar): add a11y violations pw tests
carwack Dec 7, 2024
0aff18d
test(avatar): add attach a11y scan results in pw tests
carwack Dec 7, 2024
28df346
refactor(pw): remove example tests
carwack Dec 7, 2024
89f017b
feat(playwright): add util to test a11y and attach results
carwack Dec 7, 2024
effaaa3
test(avatar): refactor to use the util fn in pw tests
carwack Dec 7, 2024
7a2eb71
chore: remove unwanted changes
carwack Dec 10, 2024
fd69531
feat(ci): add github playwright flow
carwack Dec 26, 2024
568542c
test(accordion): add playwright tests for basic variant of accordion
carwack Dec 26, 2024
126a1e6
test(utils): remove the color contrast rule from a11y pw scans
carwack Jan 26, 2025
74ff06e
feat(accordion): update render prop examle with unique text for item …
carwack Jan 26, 2025
97029cc
test(accordion): add pw tests and screenshots for render prop variant
carwack Jan 26, 2025
6930731
test(accordion): add pw tests for collapsible variant
carwack Jan 26, 2025
d3abcf7
test(accordion): add multiple variant pw tests
carwack Jan 26, 2025
86097e8
test(accordion): add pw tests for controlled variant
carwack Jan 26, 2025
97ca73b
test(accordion): add pw tests for disabled variant
carwack Jan 26, 2025
5e69dab
test(accordion): add pw tests for the closed variant
carwack Jan 26, 2025
718d9e2
test(accordion): add pw tests for vertical variant
carwack Jan 26, 2025
ad5a1c6
test(accordion): add pw tests for horizontal variant
carwack Jan 26, 2025
9f42492
test(accordion): add pw tests for root provider variant
carwack Jan 26, 2025
ac90c8d
test(accordion): add pw tests for context focused value variant
carwack Jan 26, 2025
580ad84
test(accordion): add pw tests about context value variant
carwack Jan 26, 2025
8f9e6b0
test(accordion): add pw tests for context set value variant
carwack Jan 26, 2025
fb8e0fd
test(accordion): add pw tests for the context get item state value va…
carwack Jan 26, 2025
b286157
test(accordion): use toBeVisible instead of toHaveText
carwack Jan 26, 2025
5c11cdb
feat(playwright): update configs
carwack Feb 8, 2025
eeb1ab6
feat(playwrite): update configs
carwack Feb 8, 2025
33b3fb9
fix(playwright): add awaits before expects to fix random behavior
carwack Feb 8, 2025
a7edc05
test(components): update pw snapshots
carwack Feb 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(accordion): add multiple variant pw tests
carwack committed Jan 26, 2025
commit d3abcf79b06765ad5a9b1bc38d4b95f26b798bb2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions packages/vue/src/components/_tests/accordion/accordion.pw.test.ts
Original file line number Diff line number Diff line change
@@ -147,4 +147,67 @@ test.describe('collapsible variant', () => {
expect(page.getByText('Solid is a JavaScript library for building user interfaces.')).toBeVisible()
expect(page).toHaveScreenshot()
})
})

// Multiple items variant tests
test.describe('multiple variant', () => {
test.beforeEach(async ({ page }) => {
await gotoStory('accordion', 'multiple', page)
await page.getByRole('button', { name: 'What is React?' }).waitFor()
})
test('has first item content about React closed', async ({ page }) => {
expect(page.getByRole('button', { name: 'What is React?' })).toHaveAttribute(
'data-state',
'closed',
)
expect(page).toHaveScreenshot()
})
test('has no a11y violations in closed state', async ({ page }, testInfo) => {
const accessibilityScanResults = await testA11yWithAttachedResults(page, testInfo, 'accordion')
expect(accessibilityScanResults.violations).toEqual([])
})
test('has no a11y violations in open state', async ({ page }, testInfo) => {
await page.getByRole('button', { name: 'What is React?' }).click()
const accessibilityScanResults = await testA11yWithAttachedResults(page, testInfo, 'accordion')
expect(accessibilityScanResults.violations).toEqual([])
})
test('opens the content of the first item when clicking on the accordion item trigger', async ({ page }) => {
await page.getByRole('button', { name: 'What is React?' }).click()
expect(page.getByRole('button', { name: 'What is React?' })).toHaveAttribute(
'data-state',
'open',
)
expect(page.getByText('React is a JavaScript library for building user interfaces.')).toBeVisible()
expect(page).toHaveScreenshot()
})
test('closes the content of the first item when clicking on the accordion item trigger again', async ({ page }) => {
await page.getByRole('button', { name: 'What is React?' }).click()
expect(page.getByRole('button', { name: 'What is React?' })).toHaveAttribute(
'data-state',
'open',
)
await page.getByRole('button', { name: 'What is React?' }).click()
expect(page.getByRole('button', { name: 'What is React?' })).toHaveAttribute(
'data-state',
'closed',
)
expect(page.getByText('React is a JavaScript library for building user interfaces.')).not.toBeVisible()
expect(page).toHaveScreenshot()
})
test('opens multiple content items of the accordion', async ({ page }) => {
await page.getByRole('button', { name: 'What is React?' }).click()
await page.getByRole('button', { name: 'What is Solid?' }).click()

expect(page.getByRole('button', { name: 'What is React?' })).toHaveAttribute(
'data-state',
'open',
)
expect(page.getByRole('button', { name: 'What is Solid?' })).toHaveAttribute(
'data-state',
'open',
)
expect(page.getByText('React is a JavaScript library for building user interfaces.')).toBeVisible()
expect(page.getByText('Solid is a JavaScript library for building user interfaces.')).toBeVisible()
expect(page).toHaveScreenshot()
})
})