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

Adding a11y test packages #15040

Merged
merged 71 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
7c2cce4
fixing navigation into cell which has multiple focusable elements
mituron Apr 3, 2020
62e28f2
updating changelog
mituron Apr 3, 2020
0c5c65b
Merge remote-tracking branch 'upstream/master'
mituron Apr 6, 2020
8eefec7
Merge remote-tracking branch 'upstream/master'
mituron Apr 7, 2020
832899a
Merge remote-tracking branch 'upstream/master'
mituron Apr 7, 2020
d95c074
adding table keyboard navigation tests
mituron Apr 7, 2020
071e0d7
deleting from master
mituron Apr 7, 2020
c21cdf2
adding table keyboard navigation tests
mituron Apr 7, 2020
df6e0bb
deleting files from master, pushed by mistaked
mituron Apr 7, 2020
a2168a7
Merge remote-tracking branch 'upstream/master'
mituron Apr 7, 2020
ab319d4
Merge remote-tracking branch 'upstream/master'
mituron Apr 14, 2020
f32733d
Merge remote-tracking branch 'upstream/master'
mituron Apr 16, 2020
be41933
Merge remote-tracking branch 'upstream/master'
mituron Apr 16, 2020
942446b
Merge remote-tracking branch 'upstream/master'
mituron Apr 16, 2020
6df8780
Merge remote-tracking branch 'upstream/master'
mituron Apr 17, 2020
58de7e9
Merge remote-tracking branch 'upstream/master'
mituron Apr 20, 2020
a041178
Merge remote-tracking branch 'upstream/master'
mituron Apr 22, 2020
761ed16
Merge remote-tracking branch 'upstream/master'
mituron Apr 23, 2020
0f83787
Merge remote-tracking branch 'upstream/master'
mituron Apr 24, 2020
65cf888
Merge remote-tracking branch 'upstream/master'
mituron Apr 24, 2020
8a2357f
Merge remote-tracking branch 'upstream/master'
mituron Apr 27, 2020
8ab96ed
Merge remote-tracking branch 'upstream/master'
mituron Apr 28, 2020
89b56d7
Merge remote-tracking branch 'upstream/master'
mituron Apr 30, 2020
5cd0ecb
Merge remote-tracking branch 'upstream/master'
mituron Apr 30, 2020
497f075
Merge remote-tracking branch 'upstream/master'
mituron Apr 30, 2020
fb2fa1c
Merge remote-tracking branch 'upstream/master'
mituron Apr 30, 2020
438db4e
Merge remote-tracking branch 'upstream/master'
mituron May 4, 2020
ee8be58
Merge remote-tracking branch 'upstream/master'
mituron May 6, 2020
1078f5c
Merge remote-tracking branch 'upstream/master'
mituron May 11, 2020
ccc74c6
Merge remote-tracking branch 'upstream/master'
mituron May 11, 2020
44a290b
Merge remote-tracking branch 'upstream/master'
mituron May 13, 2020
3a62193
Merge remote-tracking branch 'upstream/master'
mituron May 14, 2020
846af10
Merge remote-tracking branch 'upstream/master'
mituron May 19, 2020
d8c91dc
Merge remote-tracking branch 'upstream/master'
mituron May 21, 2020
be90740
Merge remote-tracking branch 'upstream/master'
mituron May 29, 2020
37bcc6a
Merge remote-tracking branch 'upstream/master'
mituron Jun 2, 2020
b11f922
Merge remote-tracking branch 'upstream/master'
mituron Jun 3, 2020
8541477
Merge remote-tracking branch 'upstream/master'
mituron Jun 5, 2020
5f31556
Merge remote-tracking branch 'upstream/master'
mituron Jun 9, 2020
8d8753d
Merge remote-tracking branch 'upstream/master'
mituron Jun 10, 2020
bb8576e
Merge remote-tracking branch 'upstream/master'
mituron Jun 11, 2020
cafc888
Merge remote-tracking branch 'upstream/master'
mituron Jun 12, 2020
fe42d56
Merge remote-tracking branch 'upstream/master'
mituron Jun 22, 2020
658aad4
Merge remote-tracking branch 'upstream/master'
mituron Jun 23, 2020
27fe33e
Merge remote-tracking branch 'upstream/master'
mituron Jun 23, 2020
16764ea
Merge remote-tracking branch 'upstream/master'
mituron Jun 24, 2020
9c14142
Merge remote-tracking branch 'upstream/master'
mituron Jun 25, 2020
0e7341a
Merge remote-tracking branch 'upstream/master'
mituron Jun 25, 2020
cbe6f02
Merge remote-tracking branch 'upstream/master'
mituron Jun 30, 2020
7ec71ee
Merge remote-tracking branch 'upstream/master'
mituron Jul 2, 2020
e8c0fc5
Merge remote-tracking branch 'upstream/master'
mituron Jul 3, 2020
96b542c
Merge remote-tracking branch 'upstream/master'
mituron Jul 31, 2020
609b183
Merge remote-tracking branch 'upstream/master'
mituron Sep 1, 2020
7b6c3fc
Merge remote-tracking branch 'upstream/master'
mituron Sep 1, 2020
11d0548
Merge remote-tracking branch 'upstream/master'
mituron Sep 2, 2020
29987e1
Merge remote-tracking branch 'upstream/master'
mituron Sep 3, 2020
14b4aac
Merge remote-tracking branch 'upstream/master'
mituron Sep 10, 2020
8a5fa60
Merge remote-tracking branch 'upstream/master'
mituron Sep 11, 2020
43f0b9f
Merge remote-tracking branch 'upstream/master'
mituron Sep 14, 2020
20a9bca
Merge remote-tracking branch 'upstream/master'
mituron Sep 14, 2020
446ee01
Merge remote-tracking branch 'upstream/master'
mituron Sep 15, 2020
acf0ac0
Merge remote-tracking branch 'upstream/master'
mituron Sep 15, 2020
8595de3
Merge branch 'master' of https://github.com/OfficeDev/office-ui-fabri…
mituron Sep 15, 2020
6931ecd
adding packages needed for a11y testing and generate documentation fo…
mituron Sep 15, 2020
e5feb75
Update packages/a11y-testing/LICENSE
kolaps33 Sep 15, 2020
bd5c5f2
Update packages/a11y-testing/package.json
kolaps33 Sep 15, 2020
7f255ef
improving based on review
mituron Sep 15, 2020
2f68d7c
Merge remote-tracking branch 'upstream/master'
mituron Sep 16, 2020
20dcdc8
Merge branch 'master' into mituron/adding-a11y-test-packages
mituron Sep 16, 2020
e53baf1
adressing comment regarding jest package
mituron Sep 16, 2020
45fa80d
impoving dependency package
mituron Sep 16, 2020
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
6 changes: 6 additions & 0 deletions packages/a11y-rules/just.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { preset, just } = require('@uifabric/build');
const { task } = just;

preset();

task('build', 'build:node-lib').cached();
20 changes: 20 additions & 0 deletions packages/a11y-rules/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@fluentui/a11y-rules",
"version": "0.1.0",
"description": "Fluent UI rules for a11y testing a generating doc for behaviors files.",
"private": true,
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/fluentui"
},
"license": "MIT",
"scripts": {
"build": "just-scripts build",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"just": "just-scripts",
"lint": "just-scripts lint"
}
}
2 changes: 2 additions & 0 deletions packages/a11y-rules/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './rules';
export * from './types';
109 changes: 109 additions & 0 deletions packages/a11y-rules/src/rules.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { Props, PropValue, Rule, Slot } from './types';

export class SlotRule implements Rule {
private data: Slot;

constructor(name: string) {
this.data = { name } as Slot;
}

public forProps = (props: Props | Props[]) => {
this.data.props = Array.isArray(props) ? props : [props];
return this;
};

public afterClick = () => {
this.data.checkClick = true;
return this;
};

public pressSpaceKey = () => {
this.data.checkSpaceKeyPressed = true;
return this;
};

public pressEnterKey = () => {
this.data.checkEnterKeyPressed = true;
return this;
};

public verifyOnclickExecution = () => {
this.data.checkOnClickWasExecuted = true;
return this;
};

public hasAttribute = (expectedAttribute: string, expectedValue?: PropValue) => {
this.data.expectedAttribute = expectedAttribute;
if (expectedValue) {
this.data.expectedValue = expectedValue;
}
this.data.expectAttribute = true;
return this;
};

public doesNotHaveAttribute = (expectedAttribute: string) => {
this.data.expectedAttribute = expectedAttribute;
this.data.expectedValue = undefined;
this.data.expectAttribute = false;
return this;
};

public description = (description: string) => {
this.data.description = description;
return this;
};

public hide = () => {
this.data.hidden = true;
return this;
};

public getData = () => this.data;

public stringify = () => {
return [
this.data.expectAttribute !== undefined && this.data.expectAttribute ? 'Adds' : 'Does not add attribute',
this.data.expectAttribute !== undefined &&
this._expectedAttributeAndValueFormat(
this.data.expectAttribute,
this.data.expectedAttribute,
this.data.expectedValue,
),
this.data.checkSpaceKeyPressed && `Triggers 'performClick' action with 'Space'`,
this.data.checkEnterKeyPressed && `Triggers 'performClick' action with 'Enter'`,
this.data.name && this.data.name !== 'root' && `to slot ${this.data.name}`,
this.data.description ? this.data.description : this.data.props && `for props ${this._stringifyProps()}`,
]
.filter(Boolean)
.join(' ');
};

private _stringifyProps = () => {
if (!this.data.props) {
return '';
}

return this.data.props.map(prop => JSON.stringify(prop)).join(' or ');
};

private _expectedAttributeAndValueFormat = (
expectAttribute: boolean,
expectedAttribute: string,
expectedValue: PropValue,
) => {
if (expectAttribute) {
return expectedValue ? `'${expectedAttribute}=${expectedValue}'` : `'${expectedAttribute}'`;
} else {
return `'${this.data.expectedAttribute}'`;
}
};
}

export class BehaviorRule {
public static slot = (name: string) => {
return new SlotRule(name);
};
public static root = () => {
return new SlotRule('root');
};
}
24 changes: 24 additions & 0 deletions packages/a11y-rules/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type PropValue = string | number | boolean | any;
export type Props = { [name: string]: PropValue };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AccessibilityBehavior = (props: Props) => any;

export interface Rule {
stringify: () => string;
}

export interface Slot {
name: string;
props: Props[];
expectAttribute: boolean;
expectedAttribute: string;
expectedValue: PropValue;
description: string;
hidden: boolean;
afterEventData: Event;
checkClick: boolean;
checkSpaceKeyPressed: boolean;
checkEnterKeyPressed: boolean;
checkOnClickWasExecuted: boolean;
}
23 changes: 23 additions & 0 deletions packages/a11y-rules/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "lib",
"target": "es6",
"module": "commonjs",
"jsx": "react",
"declaration": true,
"sourceMap": true,
"experimentalDecorators": true,
"importHelpers": true,
"noUnusedLocals": true,
"forceConsistentCasingInFileNames": true,
"strictNullChecks": true,
"noImplicitAny": true,
"moduleResolution": "node",
"skipLibCheck": true,
"preserveConstEnums": true,
"lib": ["es2017", "dom"],
"types": ["jest"]
},
"include": ["src"]
}
4 changes: 4 additions & 0 deletions packages/a11y-testing/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": ["plugin:@fluentui/eslint-plugin/node"],
"root": true
}
34 changes: 34 additions & 0 deletions packages/a11y-testing/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
*.api.json
*.config.js
*.log
*.nuspec
*.test.*
*.yml
.editorconfig
.eslintrc*
.eslintcache
.gitattributes
.gitignore
.vscode
coverage
dist-storybook
dist/*.stats.html
dist/*.stats.json
dist/demo*.*
fabric-test*
gulpfile.js
images
index.html
jsconfig.json
node_modules
results
src/**/*
!src/**/examples/*.tsx
!src/**/docs/**/*.md
!src/**/*.types.ts
temp
tsconfig.json
tsd.json
tslint.json
typings
visualtests
2 changes: 2 additions & 0 deletions packages/a11y-testing/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
registry=https://registry.npmjs.org/

15 changes: 15 additions & 0 deletions packages/a11y-testing/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@fluentui/react-button

Copyright (c) Microsoft Corporation

All rights reserved.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
3 changes: 3 additions & 0 deletions packages/a11y-testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @fluentui/a11y-testing

Tests for testing a11y conformance of compoenents and hooks, together with typings for creating custom definitions.
6 changes: 6 additions & 0 deletions packages/a11y-testing/just.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { preset, just } = require('@uifabric/build');
const { task } = just;

preset();

task('build', 'build:node-lib').cached();
34 changes: 34 additions & 0 deletions packages/a11y-testing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@fluentui/a11y-testing",
"version": "0.1.0",
"description": "Fluent UI tests for a11y patterns.",
"private": true,
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/microsoft/fluentui"
},
"license": "MIT",
"scripts": {
"build": "just-scripts build",
"clean": "just-scripts clean",
"code-style": "just-scripts code-style",
"just": "just-scripts",
"lint": "just-scripts lint"
},
"dependencies": {
"@fluentui/a11y-rules": "0.1.0",
"@fluentui/eslint-plugin": "^0.54.0",
"@types/enzyme": "3.10.3",
"@types/jest": "~24.9.0",
"@types/react": "16.8.25",
"@types/react-dom": "16.8.4",
"@uifabric/build": "^7.0.0",
"enzyme": "~3.10.0",
"jest": "~24.9.0",
"react": "16.8.6",
"react-dom": "16.8.6",
"tslib": "^1.10.0"
}
}
Loading