-
Notifications
You must be signed in to change notification settings - Fork 0
Chore/workflows #9
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
Open
plumdumpling
wants to merge
3
commits into
main
Choose a base branch
from
chore/workflows
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−29
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,27 +1,61 @@ | ||
| name: Playwright Tests | ||
| name: Playwright Accessibility Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
| types: [opened, synchronize, reopened] | ||
|
|
||
| jobs: | ||
| test: | ||
| playwright: | ||
| name: Playwright | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 60 | ||
| outputs: | ||
| issue_count: ${{ steps.playwright.outputs.issue_count }} | ||
| steps: | ||
| - name: Checkout repository from GitHub | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Install Playwright Browsers | ||
| run: npx playwright install --with-deps | ||
|
|
||
| - name: Build app | ||
| run: npm run build | ||
|
|
||
| - name: Serve preview | ||
| run: npm run preview & npx wait-on http://localhost:4173 | ||
|
|
||
| - name: Run Playwright tests | ||
| run: npx playwright test || true | ||
|
|
||
| - name: Count Playwright accessibility issues | ||
| id: playwright | ||
| run: | | ||
| issue_count=$(jq '. | length' playwright-a11y-violations.json) | ||
| echo "issue_count=$issue_count" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Upload report artifact | ||
| uses: actions/upload-artifact@v4 | ||
| if: ${{ !cancelled() }} | ||
| with: | ||
| name: playwright-report | ||
| path: playwright-report/ | ||
| retention-days: 30 | ||
|
|
||
| comment-on-pr: | ||
| needs: playwright | ||
| if: needs.playwright.outputs.issue_count != '0' | ||
| 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 | ||
| - name: Comment on PR | ||
| uses: thollander/actions-comment-pull-request@v3 | ||
| with: | ||
| message: "♿ Playwright detected ${{ needs.playwright.outputs.issue_count }} accessibility issue(s) – please review [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})." | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -29,3 +29,4 @@ dist-ssr | |
| /blob-report/ | ||
| /playwright/.cache/ | ||
| /playwright/.auth/ | ||
| playwright-a11y-violations.json | ||
This file contains hidden or 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,13 +1,28 @@ | ||
| import fs from 'fs'; | ||
| import AxeBuilder from '@axe-core/playwright'; | ||
| import {test, expect} from '@playwright/test'; | ||
| import {test} from '@playwright/test'; | ||
|
|
||
| test.only('BASIC', async ({page}) => { | ||
| await page.goto('localhost:5173'); | ||
| test('BASIC', async ({page}, testInfo) => { | ||
| await page.goto('http://localhost:4173'); | ||
| await page.locator('#root').waitFor(); | ||
|
|
||
| // Check the whole page | ||
| const axeBuilder = await new AxeBuilder({page}) | ||
| .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']) | ||
| .withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa']) | ||
| .analyze(); | ||
| expect(axeBuilder.violations).toEqual([]); | ||
| const violations = axeBuilder.violations; | ||
|
|
||
| // Write violations to json file | ||
| fs.writeFileSync( | ||
| 'playwright-a11y-violations.json', | ||
| JSON.stringify(violations, null, 2) | ||
| ); | ||
plumdumpling marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // Add an info annotation if there are violations | ||
| if (violations.length > 0) { | ||
| testInfo.annotations.push({ | ||
| type: 'info', | ||
| description: `Accessibility violations found: ${violations.length}` | ||
| }); | ||
| } | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.