Skip to content

Commit 0aa9abf

Browse files
committed
tests: Move to snapshots for accessiblity tests
Signed-off-by: Julius Knorr <jus@bitgrid.net>
1 parent 0cfa233 commit 0aa9abf

8 files changed

+95
-15
lines changed

playwright/e2e/accessibility.spec.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { test as uploadFileTest } from '../support/fixtures/upload-file'
1010
import {
1111
formatViolations,
1212
getAccessibilitySummary,
13+
violationFingerprints,
1314
} from '../support/utils/accessibility'
1415

1516
const test = mergeTests(accessibilityTest, editorTest, uploadFileTest)
@@ -41,11 +42,11 @@ test.describe('Editor Accessibility', () => {
4142
contentType: 'application/json',
4243
})
4344

44-
// Expect no violations
45+
// Snapshot test for violations to track changes over time
4546
expect(
46-
accessibilityScanResults.violations,
47+
violationFingerprints(accessibilityScanResults),
4748
formatViolations(accessibilityScanResults),
48-
).toEqual([])
49+
).toMatchSnapshot('accessibility-violations.json')
4950
})
5051

5152
test('should not have accessibility violations in the editor content area', async ({
@@ -71,9 +72,9 @@ test.describe('Editor Accessibility', () => {
7172
})
7273

7374
expect(
74-
accessibilityScanResults.violations,
75+
violationFingerprints(accessibilityScanResults),
7576
formatViolations(accessibilityScanResults),
76-
).toEqual([])
77+
).toMatchSnapshot('editor-content-violations.json')
7778
})
7879

7980
test('should not have accessibility violations in the menu bar', async ({
@@ -97,9 +98,9 @@ test.describe('Editor Accessibility', () => {
9798
})
9899

99100
expect(
100-
accessibilityScanResults.violations,
101+
violationFingerprints(accessibilityScanResults),
101102
formatViolations(accessibilityScanResults),
102-
).toEqual([])
103+
).toMatchSnapshot('menubar-violations.json')
103104
})
104105

105106
test('should have proper keyboard navigation support', async ({
@@ -125,9 +126,9 @@ test.describe('Editor Accessibility', () => {
125126

126127
// Check that interactive elements are keyboard accessible
127128
expect(
128-
accessibilityScanResults.violations,
129+
violationFingerprints(accessibilityScanResults),
129130
formatViolations(accessibilityScanResults),
130-
).toEqual([])
131+
).toMatchSnapshot('keyboard-navigation-violations.json')
131132
})
132133

133134
test('should have proper ARIA labels on interactive elements', async ({
@@ -156,9 +157,9 @@ test.describe('Editor Accessibility', () => {
156157
})
157158

158159
expect(
159-
accessibilityScanResults.violations,
160+
violationFingerprints(accessibilityScanResults),
160161
formatViolations(accessibilityScanResults),
161-
).toEqual([])
162+
).toMatchSnapshot('aria-labels-violations.json')
162163
})
163164

164165
test('should maintain accessibility after text formatting', async ({
@@ -191,8 +192,8 @@ test.describe('Editor Accessibility', () => {
191192
})
192193

193194
expect(
194-
accessibilityScanResults.violations,
195+
violationFingerprints(accessibilityScanResults),
195196
formatViolations(accessibilityScanResults),
196-
).toEqual([])
197+
).toMatchSnapshot('formatted-content-violations.json')
197198
})
198199
})
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"rule": "aria-input-field-name",
4+
"description": "Ensure every ARIA input field has an accessible name",
5+
"targets": [
6+
[
7+
".tiptap"
8+
]
9+
],
10+
"impact": "serious"
11+
},
12+
{
13+
"rule": "label",
14+
"description": "Ensure every form element has a label",
15+
"targets": [
16+
[
17+
"input[data-cy-upload-picker-input=\"\"]"
18+
]
19+
],
20+
"impact": "critical"
21+
}
22+
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[
2+
{
3+
"rule": "aria-input-field-name",
4+
"description": "Ensure every ARIA input field has an accessible name",
5+
"targets": [
6+
[
7+
".tiptap"
8+
]
9+
],
10+
"impact": "serious"
11+
},
12+
{
13+
"rule": "label",
14+
"description": "Ensure every form element has a label",
15+
"targets": [
16+
[
17+
"input[data-cy-upload-picker-input=\"\"]"
18+
]
19+
],
20+
"impact": "critical"
21+
}
22+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"rule": "aria-input-field-name",
4+
"description": "Ensure every ARIA input field has an accessible name",
5+
"targets": [
6+
[
7+
".tiptap"
8+
]
9+
],
10+
"impact": "serious"
11+
}
12+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"rule": "aria-input-field-name",
4+
"description": "Ensure every ARIA input field has an accessible name",
5+
"targets": [
6+
[
7+
".tiptap"
8+
]
9+
],
10+
"impact": "serious"
11+
}
12+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[
2+
{
3+
"rule": "label",
4+
"description": "Ensure every form element has a label",
5+
"targets": [
6+
[
7+
"form > input[multiple=\"multiple\"]"
8+
]
9+
],
10+
"impact": "critical"
11+
}
12+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

playwright/support/fixtures/accessibility.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ export const test = base.extend<AxeFixture>({
2020
// See: https://github.com/dequelabs/axe-core-npm/blob/develop/packages/playwright/error-handling.md
2121
.setLegacyMode()
2222

23-
// TODO: Fix these accessibility issues in the application
24-
.exclude('input[data-cy-upload-picker-input]') // Upload input needs proper label
2523

2624
await use(makeAxeBuilder)
2725
},

0 commit comments

Comments
 (0)