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 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 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
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
27 changes: 27 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
name: playwright-report
path: playwright-report/
retention-days: 30
Binary file modified bun.lockb
Binary file not shown.
6 changes: 6 additions & 0 deletions packages/vue/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
src/components/_tests/reports/
4 changes: 2 additions & 2 deletions packages/vue/.storybook/styles/accordion.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
[data-scope="accordion"][data-part="item-content"] {
overflow: hidden;
max-width: 400px;
background-color: cadetblue;
color:white;
background-color: #004c4c;
color: white;
}

[data-scope="accordion"][data-part="item-content"][data-state="open"] {
Expand Down
11 changes: 8 additions & 3 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
"lint": "echo 'No linting configured for this package.'",
"test": "vitest",
"test:ci": "vitest --run",
"test:pw": "playwright test",
"test:pw:ui": "playwright test --ui",
"typecheck": "vue-tsc",
"storybook": "histoire dev",
"release-it": "release-it --config ../../release-it.json",
Expand Down Expand Up @@ -180,10 +182,10 @@
"@zag-js/dom-query": "0.77.1",
"@zag-js/editable": "0.77.1",
"@zag-js/file-upload": "0.77.1",
"@zag-js/file-utils": "0.77.1",
"@zag-js/highlight-word": "0.77.1",
"@zag-js/hover-card": "0.77.1",
"@zag-js/i18n-utils": "0.77.1",
"@zag-js/file-utils": "0.77.1",
"@zag-js/menu": "0.77.1",
"@zag-js/number-input": "0.77.1",
"@zag-js/pagination": "0.77.1",
Expand All @@ -198,6 +200,8 @@
"@zag-js/signature-pad": "0.77.1",
"@zag-js/slider": "0.77.1",
"@zag-js/splitter": "0.77.1",
"@zag-js/steps": "0.77.1",
"@zag-js/store": "0.77.1",
"@zag-js/switch": "0.77.1",
"@zag-js/tabs": "0.77.1",
"@zag-js/tags-input": "0.77.1",
Expand All @@ -209,19 +213,20 @@
"@zag-js/tree-view": "0.77.1",
"@zag-js/types": "0.77.1",
"@zag-js/utils": "0.77.1",
"@zag-js/steps": "0.77.1",
"@zag-js/store": "0.77.1",
"@zag-js/vue": "0.77.1"
},
"devDependencies": {
"@axe-core/playwright": "^4.10.1",
"@biomejs/biome": "1.9.4",
"@histoire/plugin-vue": "0.17.17",
"@playwright/test": "^1.49.0",
"@release-it/keep-a-changelog": "5.0.0",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.3",
"@testing-library/user-event": "14.5.2",
"@testing-library/vue": "8.0.3",
"@types/jsdom": "21.1.7",
"@types/node": "^22.10.1",
"@vitejs/plugin-vue": "5.2.0",
"@vitejs/plugin-vue-jsx": "4.1.0",
"@vue/compiler-sfc": "3.5.13",
Expand Down
81 changes: 81 additions & 0 deletions packages/vue/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { defineConfig, devices } from '@playwright/test'

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './src/components/_tests',
testMatch: '**/*.pw.test.ts',
snapshotPathTemplate: '{testDir}/{testFileDir}/__snapshots__/{projectName}/{arg}{ext}',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [['html', { outputFolder: './src/components/_tests/reports' }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: 'http://localhost:6006', // Histoire

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
})
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading