Skip to content

Commit 2ab19c1

Browse files
committed
fix: remove unused axe dep and add playwright axe tests
Refs: HAUKI-747
1 parent 1c18b3b commit 2ab19c1

4 files changed

Lines changed: 36 additions & 20 deletions

File tree

e2e/tests/accessibility.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// eslint-disable-next-line import/no-extraneous-dependencies
2+
import { test, expect } from '@playwright/test';
3+
// eslint-disable-next-line import/no-extraneous-dependencies
4+
import AxeBuilder from '@axe-core/playwright';
5+
import { getResourceUrl } from '../utils';
6+
7+
test('Frontpage has no wcag2a/wcag2aa violations', async ({ page }) => {
8+
await page.goto('');
9+
const results = await new AxeBuilder({ page })
10+
.withTags(['wcag2a', 'wcag2aa'])
11+
.analyze();
12+
expect(results.violations).toEqual([]);
13+
});
14+
15+
test('Resource page has no wcag2a/wcag2aa violations', async ({ page }) => {
16+
const resourceUrl = await getResourceUrl();
17+
await page.goto(resourceUrl);
18+
await expect(page.locator('body')).toContainText('Suomeksi');
19+
await page
20+
.getByRole('button', { name: 'Hyväksy vain välttämättömät evästeet' })
21+
.click();
22+
const results = await new AxeBuilder({ page })
23+
.withTags(['wcag2a', 'wcag2aa'])
24+
.analyze();
25+
expect(results.violations).toEqual([]);
26+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
},
99
"packageManager": "pnpm@11.1.2",
1010
"dependencies": {
11-
"@axe-core/react": "^4.11.3",
1211
"@eslint/js": "^9.39.1",
1312
"@nabla/vite-plugin-eslint": "^3.0.1",
1413
"@sentry/react": "^10.24.0",
@@ -83,6 +82,7 @@
8382
"devDependencies": {
8483
"@commitlint/cli": "^18.4.3",
8584
"@commitlint/config-conventional": "^18.4.3",
85+
"@axe-core/playwright": "^4.11.0",
8686
"@playwright/test": "^1.58.2",
8787
"@testing-library/dom": "^10.4.1",
8888
"@testing-library/jest-dom": "^6.4.2",

pnpm-lock.yaml

Lines changed: 9 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import React from 'react';
2-
import ReactDOM from 'react-dom';
31
import { createRoot } from 'react-dom/client';
42
import * as Sentry from '@sentry/react';
53
import './index.scss';
6-
import axe from '@axe-core/react';
74
import App from './App';
85

96
declare global {
@@ -33,10 +30,6 @@ if (
3330
});
3431
}
3532

36-
if (window._env_?.USE_AXE === 'true') {
37-
axe(React, ReactDOM, 1000);
38-
}
39-
4033
const container = document.getElementById('root');
4134
if (!container) {
4235
throw new Error('Root element not found');

0 commit comments

Comments
 (0)