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

Component accessibility testing #1352

Merged
merged 82 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
f0e0757
playwright ct & axebuilder install
xman343 Jun 9, 2023
60a5b51
fixed axebuilder install & started component test
xman343 Jun 9, 2023
856cd25
first pass at component spec tsx
xman343 Jun 12, 2023
8c74b62
workspace created
xman343 Jun 13, 2023
f1809b8
dependencies installed
xman343 Jun 13, 2023
fb95042
Merge branch 'dev'
xman343 Jun 13, 2023
f918533
fix component testing setup
mayank99 Jun 13, 2023
d44b57c
package cleanup
xman343 Jun 13, 2023
4cd6ddb
fixed yarn lock
xman343 Jun 13, 2023
9364985
test run error: failed to resolve entry
xman343 Jun 14, 2023
534be82
fixed package.json
xman343 Jun 14, 2023
6c3b1d1
yarn lock fix
xman343 Jun 14, 2023
47239aa
updated itwinui-react v in packages.json
xman343 Jun 14, 2023
f687ebe
testing a11y folders set-up
xman343 Jun 14, 2023
0c10e39
automated test file created
xman343 Jun 14, 2023
61ddbe0
Merge branch 'dev' of https://github.com/iTwin/iTwinUI into xander/co…
xman343 Jun 14, 2023
ff57ce8
yarn update to fix imports
xman343 Jun 14, 2023
b559c0f
renamed to a11y in yarn.lock turbo json
xman343 Jun 14, 2023
9bab9c7
still getting Carousel export error
xman343 Jun 14, 2023
24bffe2
uninstalled playwright from a11y
xman343 Jun 15, 2023
9f283d1
installed cypress into a11y
xman343 Jun 15, 2023
6efd792
cypress spec created
xman343 Jun 15, 2023
a2868ed
further cy changes
xman343 Jun 15, 2023
fa608e9
removed axe-core from a11y package.json
xman343 Jun 15, 2023
12d6360
moved itwinui-react dep to devDeps in a11y json
xman343 Jun 15, 2023
2da4b98
reverted changes to package.json
xman343 Jun 15, 2023
3e60a3f
base component test & attempt at css import
xman343 Jun 16, 2023
8af216d
css imports removed
xman343 Jun 16, 2023
96146e8
component-index.html css import attempt
xman343 Jun 16, 2023
c344363
Merge branch 'dev' of https://github.com/iTwin/iTwinUI into xander/co…
xman343 Jun 16, 2023
edb271d
testing node_modules refresh
xman343 Jun 16, 2023
76126ca
added imports to package.json
xman343 Jun 16, 2023
3eae1e2
updated gitignore
xman343 Jun 16, 2023
fe06a05
gitignore update 2
xman343 Jun 16, 2023
29aace4
Delete testing/a11y/.next directory
xman343 Jun 16, 2023
6465069
unneeded .next deleted
xman343 Jun 16, 2023
1151d6a
Merge branch 'xander/component-accessibility-testing' of https://gith…
xman343 Jun 16, 2023
c44d8a2
css import component.js edit
xman343 Jun 16, 2023
fed5ab0
cleaned up component-index.html and package.json
xman343 Jun 16, 2023
80ae22d
deleted vestigial test
xman343 Jun 16, 2023
bf8a313
Merge branch 'dev' of https://github.com/iTwin/iTwinUI into xander/co…
xman343 Jun 20, 2023
a349911
changed test filenames to reflect import origins
xman343 Jun 20, 2023
a95599e
css import fix
xman343 Jun 20, 2023
b8e0d70
css font fix
xman343 Jun 20, 2023
aa85bc3
cypress axe installation
xman343 Jun 20, 2023
82ea824
axe a11y tests added
xman343 Jun 20, 2023
65a17bd
redundant spec deleted
xman343 Jun 20, 2023
c4bf7b5
Merge branch 'dev' of https://github.com/iTwin/iTwinUI into xander/co…
xman343 Jun 21, 2023
b68a38f
examples compiled tsx to js - still exports tsx
xman343 Jun 22, 2023
2574071
examples refactoring and js compile fixes
xman343 Jun 23, 2023
82b04bb
Merge branch 'dev' of https://github.com/iTwin/iTwinUI into xander/co…
xman343 Jun 23, 2023
cb7d0a2
refactoring and package.json tsx restore
xman343 Jun 23, 2023
132a6ea
gave js examples own folder for easier export
xman343 Jun 23, 2023
a962813
js examples now work in cy tests
xman343 Jun 23, 2023
682e137
Merge branch 'dev' of https://github.com/iTwin/iTwinUI into xander/co…
xman343 Jun 26, 2023
663b359
non-component a11y violations ignored
xman343 Jun 26, 2023
8c8bb09
Created tests for all Alert examples
xman343 Jun 26, 2023
1d0b0ff
removed itwinuireact tests
xman343 Jun 26, 2023
e3f3af7
anchor & avatar tests
xman343 Jun 26, 2023
a2c0e9b
Merge branch 'dev' into xander/component-accessibility-testing
xman343 Jun 26, 2023
1938c72
Badge, Breadcrumbs, Button tests
xman343 Jun 26, 2023
7473ebe
deleted root cypress files
xman343 Jun 26, 2023
fcfb437
removed examples-js
xman343 Jun 26, 2023
04f4342
config fixes
xman343 Jun 26, 2023
48170c2
fixed index.html and component.js
xman343 Jun 26, 2023
a787c6e
updated examples package.json
xman343 Jun 26, 2023
a509bf7
more package.json fixes
xman343 Jun 26, 2023
14dfd8e
redoing cypress testing
xman343 Jun 26, 2023
20db291
all component test set up
xman343 Jun 26, 2023
48cd7d4
yarn lock
xman343 Jun 26, 2023
b7a2a5c
theme provider added
xman343 Jun 27, 2023
4141b82
Merge branch 'dev' into xander/component-accessibility-testing
xman343 Jun 28, 2023
ac7243e
cleanup
xman343 Jun 28, 2023
57e0762
added a11y test to build
xman343 Jun 28, 2023
39fa0fa
updated cypress
xman343 Jun 28, 2023
20b6de5
Merge branch 'dev' into xander/component-accessibility-testing
xman343 Jun 28, 2023
8ad20a0
changed build
xman343 Jun 28, 2023
e66fbca
build attempt 3
xman343 Jun 28, 2023
249e163
typo fix
xman343 Jun 29, 2023
1b12be3
component true
xman343 Jun 29, 2023
3930649
concise table
xman343 Jun 29, 2023
61ec359
update breadcrumbs test image
mayank99 Jun 29, 2023
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
28,431 changes: 28,431 additions & 0 deletions package-lock.json
mayank99 marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions packages/itwinui-react/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ storybook-static/*
# Yalc
.yalc/*
yalc.lock
node_modules/
/test-results/
/playwright-report/
/playwright/.cache/
39 changes: 39 additions & 0 deletions packages/itwinui-react/Component.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as AllExamples from 'examples';
import * as React from 'react';
import { test, expect } from '@playwright/experimental-ct-react';
import AxeBuilder from '@axe-core/playwright';
import type { HooksConfig } from '@playwright/test';
import type { Page } from 'playwright';

// Alert Test

test('Alert should meet WCAG criteria', async ({
mount,
page,
}: {
mount: (
jsx: JSX.Element,
config?: { hooksConfig?: HooksConfig },
) => Promise<void>;
page: Page;
}) => {
await mount(
<>
<AllExamples.AlertMainExample />
<AllExamples.AlertInformationalExample />
<AllExamples.AlertInlineExample />
<AllExamples.AlertNegativeExample />
<AllExamples.AlertPositiveExample />
<AllExamples.AlertStickyExample />
<AllExamples.AlertWarningExample />
</>,
);

// pass component to axebuilder

const accessibilityScanResults = await new AxeBuilder({ page })
.include('#navigation-menu-flyout')
.analyze();

expect(accessibilityScanResults.violations).toEqual([]);
});
7 changes: 6 additions & 1 deletion packages/itwinui-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,17 @@
"dev:esm": "swc src -d esm --watch",
"dev:cjs": "swc src -d cjs --watch -C module.type=commonjs",
"dev:types": "concurrently \"tsc -p tsconfig.cjs.json --emitDeclarationOnly --watch --preserveWatchOutput\" \"tsc -p tsconfig.esm.json --emitDeclarationOnly --watch --preserveWatchOutput\"",
"dev:styles": "concurrently \"yarn build:styles --watch\" \"yarn copy-styles\""
"dev:styles": "concurrently \"yarn build:styles --watch\" \"yarn copy-styles\"",
"test-ct": "playwright test -c playwright-ct.config.ts"
},
"dependencies": {
"@axe-core/playwright": "^4.7.2",
"@itwin/itwinui-illustrations-react": "^2.0.0",
"@playwright/test": "^1.35.0",
"@tippyjs/react": "^4.2.6",
"@types/react-table": "^7.0.18",
"classnames": "^2.2.6",
"react-router-dom": "^6.12.1",
"react-table": "^7.1.0",
"react-transition-group": "^4.4.2",
"tippy.js": "^6.3.7"
Expand All @@ -84,6 +88,7 @@
"@babel/core": "^7.12.10",
"@itwin/itwinui-css": "^2.0.0-dev.1",
"@itwin/itwinui-variables": "2.1.0-dev.0",
"@playwright/experimental-ct-react": "^1.35.0",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.3.21",
"@testing-library/jest-dom": "^5.16.4",
Expand Down
50 changes: 50 additions & 0 deletions packages/itwinui-react/playwright-ct.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import { defineConfig, devices } from '@playwright/experimental-ct-react';

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './',
/* The base directory, relative to the config file, for snapshot files created with toMatchSnapshot and toHaveScreenshot. */
snapshotDir: './__snapshots__',
/* Maximum time one test can run for. */
timeout: 10 * 1000,
/* 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',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

/* Port to use for Playwright component endpoint. */
ctPort: 3100,
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
],
});
12 changes: 12 additions & 0 deletions packages/itwinui-react/playwright/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Testing Page</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./index.tsx"></script>
</body>
</html>
2 changes: 2 additions & 0 deletions packages/itwinui-react/playwright/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Import styles, initialize component theme here.
// import '../src/common.css';
Loading