-
Notifications
You must be signed in to change notification settings - Fork 193
[tests-only] [full-ci] test: [OCISDEV-417] add a11y playwright tests #13268
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
Merged
Merged
Changes from all commits
Commits
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
Some comments aren't visible on the classic Files Changed page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| --- | ||
| title: 'Accessibility' | ||
| date: 2025-11-10T00:00:00+00:00 | ||
| weight: 60 | ||
| geekdocRepo: https://github.com/owncloud/web | ||
| geekdocEditPath: edit/master/docs/testing | ||
| geekdocFilePath: accessibility.md | ||
| --- | ||
|
|
||
| {{< toc >}} | ||
|
|
||
| ## Introduction | ||
|
|
||
| Accessibility is a crucial aspect of web development. It ensures that web applications are usable by everyone, including people with disabilities. | ||
|
|
||
| ## What Tools We Use | ||
|
|
||
| ### eslint-plugin-vuejs-accessibility | ||
|
|
||
| We use [eslint-plugin-vuejs-accessibility](https://github.com/vue-a11y/eslint-plugin-vuejs-accessibility) to quickly catch accessibility issues in the codebase. This plugin is used in the [@ownclouders/eslint-config](https://www.npmjs.com/package/@ownclouders/eslint-config). | ||
|
|
||
| ### @axe-core/playwright | ||
|
|
||
| We use [@axe-core/playwright](https://github.com/dequelabs/axe-core-npm) to automatically test the accessibility of the ownCloud Web client. All tests are run automatically on every PR and on commits to the `master` branch. We are not running dedicated accessibility tests and instead make them part of the E2E tests. This way we do not have to maintain duplicate tests and we can granularly add accessibility tests to the specific steps of the tests. The tests are considered failed if any `serious` or `critical` accessibility violations are found. | ||
|
|
||
| #### Running Accessibility Tests | ||
|
|
||
| To run the accessibility tests, you can simply run our existing E2E tests using the following command: | ||
|
|
||
| ```bash | ||
| pnpm test:e2e:cucumber | ||
| ``` | ||
|
|
||
| #### Skipping Accessibility Tests Locally | ||
|
|
||
| If you want to skip the accessibility tests, you can add the `SKIP_A11Y_TESTS` environment variable to your command. | ||
|
|
||
| ```bash | ||
| SKIP_A11Y_TESTS=true pnpm test:e2e:cucumber | ||
| ``` | ||
|
|
||
| #### Skipping Accessibility Tests in CI | ||
|
|
||
| If you want to skip the accessibility tests in CI, you can add the `[skip-a11y]` flag into the title of the PR. | ||
|
|
||
| #### Accessibility Report | ||
|
|
||
| After the tests are run, a JSON accessibility report is generated in the `reports/e2e/a11y-report.json` file. This report contains detailed information about the accessibility violations found in the tests. |
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
7 changes: 1 addition & 6 deletions
7
packages/web-app-files/src/components/SideBar/Shares/ExpirationDateIndicator.vue
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| import type { | ||
| Reporter, | ||
| FullConfig, | ||
| Suite, | ||
| TestCase, | ||
| TestResult, | ||
| FullResult | ||
| } from '@playwright/test/reporter' | ||
| import { AxeResults } from 'axe-core' | ||
| import * as fs from 'fs/promises' | ||
| import * as path from 'path' | ||
|
|
||
| interface A11yTestResult { | ||
| test: string | ||
| file: string | ||
| line: number | ||
| status: string | ||
| duration: number | ||
| url?: string | ||
| violations: AxeResults['violations'] | ||
| violationCount: number | ||
| passCount: number | ||
| incompleteCount: number | ||
| } | ||
|
|
||
| interface A11yReport { | ||
| summary: { | ||
| totalTests: number | ||
| totalViolations: number | ||
| totalPasses: number | ||
| totalIncomplete: number | ||
| timestamp: string | ||
| duration: number | ||
| } | ||
| tests: A11yTestResult[] | ||
| } | ||
|
|
||
| class A11yReporter implements Reporter { | ||
| private results: A11yTestResult[] = [] | ||
| private outputFile: string | ||
| private startTime: number = 0 | ||
|
|
||
| constructor(options: { outputFile?: string } = {}) { | ||
| this.outputFile = options.outputFile || 'a11y-report.json' | ||
| } | ||
|
|
||
| onBegin(_config: FullConfig, _suite: Suite): void { | ||
LukasHirt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.startTime = Date.now() | ||
| } | ||
|
|
||
| onTestEnd(test: TestCase, result: TestResult): void { | ||
| result.attachments.forEach((attachment) => { | ||
| if (attachment.name !== 'accessibility-scan') { | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| let axeResults: AxeResults | ||
|
|
||
| if (attachment.body) { | ||
| axeResults = JSON.parse(attachment.body.toString('utf-8')) | ||
| } else if (attachment.path) { | ||
| const content = require('fs').readFileSync(attachment.path, 'utf-8') | ||
| axeResults = JSON.parse(content) | ||
| } else { | ||
| throw new Error('No accessibility scan attachment found') | ||
| } | ||
|
|
||
| this.results.push({ | ||
| test: test.title, | ||
| file: path.relative(process.cwd(), test.location.file), | ||
| line: test.location.line, | ||
| status: result.status, | ||
| duration: result.duration, | ||
| url: axeResults.url, | ||
| violations: axeResults.violations || [], | ||
| violationCount: axeResults.violations?.length || 0, | ||
| passCount: axeResults.passes?.length || 0, | ||
| incompleteCount: axeResults.incomplete?.length || 0 | ||
| }) | ||
| } catch (error) { | ||
| console.error(`Error parsing accessibility results for test "${test.title}":`, error) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| async onEnd(_result: FullResult): Promise<void> { | ||
| const duration = Date.now() - this.startTime | ||
| const totalViolations = this.results.reduce((sum, test) => sum + test.violationCount, 0) | ||
|
|
||
| const report: A11yReport = { | ||
| summary: { | ||
| totalTests: this.results.length, | ||
| totalViolations, | ||
| totalPasses: this.results.reduce((sum, test) => sum + test.passCount, 0), | ||
| totalIncomplete: this.results.reduce((sum, test) => sum + test.incompleteCount, 0), | ||
| timestamp: new Date().toISOString(), | ||
| duration | ||
| }, | ||
| tests: this.results | ||
| } | ||
|
|
||
| try { | ||
| const outputDir = path.dirname(this.outputFile) | ||
| await fs.mkdir(outputDir, { recursive: true }) | ||
|
|
||
| await fs.writeFile(this.outputFile, JSON.stringify(report, null, 2), 'utf-8') | ||
|
|
||
| console.info(`\n📊 Accessibility Report Generated:`) | ||
| console.info(` File: ${this.outputFile}`) | ||
| console.info(` Tests: ${report.summary.totalTests}`) | ||
| console.warn(` Violations: ${report.summary.totalViolations}`) | ||
|
|
||
| if (totalViolations > 0) { | ||
| console.warn(`\n⚠️ Found ${totalViolations} accessibility violations`) | ||
| } else { | ||
| console.info(`\n✅ No accessibility violations found`) | ||
| } | ||
| } catch (error) { | ||
| console.error('Error writing accessibility report:', error) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default A11yReporter | ||
Oops, something went wrong.
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.