@uuv/a11y 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +24 -0
- package/README.md +199 -0
- package/bundle/uuv-a11y.bundle.js +3 -0
- package/bundle/uuv-a11y.bundle.js.LICENSE.txt +28 -0
- package/dist/README.md +199 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/lib/engine/engine.d.ts +12 -0
- package/dist/lib/engine/engine.js +123 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.js +19 -0
- package/dist/lib/model/checker.d.ts +14 -0
- package/dist/lib/model/checker.js +35 -0
- package/dist/lib/model/index.d.ts +4 -0
- package/dist/lib/model/index.js +20 -0
- package/dist/lib/model/reference.d.ts +55 -0
- package/dist/lib/model/reference.js +66 -0
- package/dist/lib/model/result.d.ts +57 -0
- package/dist/lib/model/result.js +144 -0
- package/dist/lib/model/rule.d.ts +99 -0
- package/dist/lib/model/rule.js +53 -0
- package/dist/lib/query/00-query.d.ts +4 -0
- package/dist/lib/query/00-query.js +2 -0
- package/dist/lib/query/accessible-name.query.d.ts +8 -0
- package/dist/lib/query/accessible-name.query.js +34 -0
- package/dist/lib/query/by-role.query.d.ts +8 -0
- package/dist/lib/query/by-role.query.js +27 -0
- package/dist/lib/query/by-tag.query.d.ts +7 -0
- package/dist/lib/query/by-tag.query.js +20 -0
- package/dist/lib/query/doctype.query.d.ts +5 -0
- package/dist/lib/query/doctype.query.js +15 -0
- package/dist/lib/query/form.query.d.ts +8 -0
- package/dist/lib/query/form.query.js +87 -0
- package/dist/lib/query/index.d.ts +6 -0
- package/dist/lib/query/index.js +22 -0
- package/dist/lib/reference/alix/alix-checker.d.ts +0 -0
- package/dist/lib/reference/alix/alix-checker.js +82 -0
- package/dist/lib/reference/alix/alix-rules.d.ts +0 -0
- package/dist/lib/reference/alix/alix-rules.js +1028 -0
- package/dist/lib/reference/alix/index.d.ts +0 -0
- package/dist/lib/reference/alix/index.js +3 -0
- package/dist/lib/reference/index.d.ts +1 -0
- package/dist/lib/reference/index.js +18 -0
- package/dist/lib/reference/rgaa/common.d.ts +2 -0
- package/dist/lib/reference/rgaa/common.js +5 -0
- package/dist/lib/reference/rgaa/coverage/coverage-helper.d.ts +2 -0
- package/dist/lib/reference/rgaa/coverage/coverage-helper.js +100 -0
- package/dist/lib/reference/rgaa/coverage/coverage-statement.json +90 -0
- package/dist/lib/reference/rgaa/index.d.ts +2 -0
- package/dist/lib/reference/rgaa/index.js +18 -0
- package/dist/lib/reference/rgaa/rgaa-checker.d.ts +8 -0
- package/dist/lib/reference/rgaa/rgaa-checker.js +31 -0
- package/dist/lib/reference/rgaa/rgaa-reference.d.ts +2 -0
- package/dist/lib/reference/rgaa/rgaa-reference.js +44 -0
- package/dist/lib/reference/rgaa/rgaa_4.1.criteres.json +4144 -0
- package/dist/lib/reference/rgaa/rules/1-image.d.ts +14 -0
- package/dist/lib/reference/rgaa/rules/1-image.js +644 -0
- package/dist/lib/reference/rgaa/rules/10-display.d.ts +2 -0
- package/dist/lib/reference/rgaa/rules/10-display.js +3 -0
- package/dist/lib/reference/rgaa/rules/11-form.d.ts +14 -0
- package/dist/lib/reference/rgaa/rules/11-form.js +16 -0
- package/dist/lib/reference/rgaa/rules/12-navigation.d.ts +2 -0
- package/dist/lib/reference/rgaa/rules/12-navigation.js +3 -0
- package/dist/lib/reference/rgaa/rules/13-visit.d.ts +2 -0
- package/dist/lib/reference/rgaa/rules/13-visit.js +3 -0
- package/dist/lib/reference/rgaa/rules/2-frame.d.ts +14 -0
- package/dist/lib/reference/rgaa/rules/2-frame.js +34 -0
- package/dist/lib/reference/rgaa/rules/3-color.d.ts +14 -0
- package/dist/lib/reference/rgaa/rules/3-color.js +50 -0
- package/dist/lib/reference/rgaa/rules/4-multimedia.d.ts +2 -0
- package/dist/lib/reference/rgaa/rules/4-multimedia.js +3 -0
- package/dist/lib/reference/rgaa/rules/5-table.d.ts +2 -0
- package/dist/lib/reference/rgaa/rules/5-table.js +3 -0
- package/dist/lib/reference/rgaa/rules/6-link.d.ts +2 -0
- package/dist/lib/reference/rgaa/rules/6-link.js +3 -0
- package/dist/lib/reference/rgaa/rules/7-script.d.ts +2 -0
- package/dist/lib/reference/rgaa/rules/7-script.js +3 -0
- package/dist/lib/reference/rgaa/rules/8-required-element.d.ts +14 -0
- package/dist/lib/reference/rgaa/rules/8-required-element.js +78 -0
- package/dist/lib/reference/rgaa/rules/9-structure.d.ts +2 -0
- package/dist/lib/reference/rgaa/rules/9-structure.js +3 -0
- package/dist/lib/reference/rgaa/selector-helper.d.ts +17 -0
- package/dist/lib/reference/rgaa/selector-helper.js +33 -0
- package/dist/package.json +63 -0
- package/package.json +63 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* jQuery JavaScript Library v3.7.1
|
|
3
|
+
* https://jquery.com/
|
|
4
|
+
*
|
|
5
|
+
* Copyright OpenJS Foundation and other contributors
|
|
6
|
+
* Released under the MIT license
|
|
7
|
+
* https://jquery.org/license
|
|
8
|
+
*
|
|
9
|
+
* Date: 2023-08-28T13:37Z
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @license
|
|
14
|
+
* Lodash <https://lodash.com/>
|
|
15
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
16
|
+
* Released under MIT license <https://lodash.com/license>
|
|
17
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
18
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** @license React v17.0.2
|
|
22
|
+
* react-is.production.min.js
|
|
23
|
+
*
|
|
24
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
25
|
+
*
|
|
26
|
+
* This source code is licensed under the MIT license found in the
|
|
27
|
+
* LICENSE file in the root directory of this source tree.
|
|
28
|
+
*/
|
package/dist/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
|
|
2
|
+
# @uuv/a11y
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="https://orange-opensource.github.io/uuv/">
|
|
5
|
+
<picture>
|
|
6
|
+
<img alt="UUV Logo" src="https://orange-opensource.github.io/uuv/img/uuv.png">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<h3 align="center">
|
|
12
|
+
Automated a11y validation
|
|
13
|
+
</h3>
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
@uuv/a11y is a solution for automated accessibility validations
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="https://www.npmjs.com/package/@uuv/commons" target="_blank">
|
|
21
|
+
<img src="https://img.shields.io/badge/available%20on%20npm-grey?logo=npm" alt="npm"/>
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://www.npmjs.com/package/@uuv/commons" target="_blank">
|
|
24
|
+
<img src="https://img.shields.io/badge/accessibility-yes-green" alt="accessibility"/>
|
|
25
|
+
</a>
|
|
26
|
+
<a href="https://jestjs.io/fr/" target="_blank">
|
|
27
|
+
<img src="https://img.shields.io/badge/tested%20with-jest-yellow?logo=jest" alt="jest"/>
|
|
28
|
+
</a>
|
|
29
|
+
<br />
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<div align="center">
|
|
33
|
+
<a href="https://www.npmjs.com/package/@uuv/cypress" target="_blank">
|
|
34
|
+
<img alt="@uuv/cypress npm library download count"
|
|
35
|
+
src="https://img.shields.io/npm/dt/%40uuv/cypress?logo=npm&label=%40uuv%2Fcypress"></img>
|
|
36
|
+
</a>
|
|
37
|
+
<a href="https://www.npmjs.com/package/@uuv/playwright" target="_blank">
|
|
38
|
+
<img alt="@uuv/playwright npm library download count"
|
|
39
|
+
src="https://img.shields.io/npm/dt/%40uuv/playwright?logo=npm&label=%40uuv%2Fplaywright"></img>
|
|
40
|
+
</a>
|
|
41
|
+
<a href="https://www.npmjs.com/package/@uuv/assistant" target="_blank">
|
|
42
|
+
<img alt="@uuv/assistant npm library download count"
|
|
43
|
+
src="https://img.shields.io/npm/dt/%40uuv/assistant?logo=npm&label=%40uuv%2Fassistant"></img>
|
|
44
|
+
</a>
|
|
45
|
+
<a href="https://www.npmjs.com/package/@uuv/a11y" target="_blank">
|
|
46
|
+
<img alt="@uuv/a11y npm library download count"
|
|
47
|
+
src="https://img.shields.io/npm/dt/%40uuv/a11y?logo=npm&label=%40uuv%2Fa11y"></img>
|
|
48
|
+
</a>
|
|
49
|
+
<a href="https://plugins.jetbrains.com/plugin/22437-uuv" target="_blank">
|
|
50
|
+
<img alt="JetBrains Plugin Downloads" src="https://img.shields.io/jetbrains/plugin/d/22437-uuv?logo=jetbrains&label=UUV%20plugin"></img>
|
|
51
|
+
</a>
|
|
52
|
+
<br />
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
## What is @uuv/a11y?
|
|
56
|
+
|
|
57
|
+
<p align="center">
|
|
58
|
+
|
|
59
|
+
The `@uuv` library (User centric Usecases Validator) is an accessibility driven solution to facilitate the writing and execution of end-to-end tests that are understandable to any human being.
|
|
60
|
+
|
|
61
|
+
`@uuv/a11y` is the part of this solution used to perform automated accessibility checks to guarantee non-regression.
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
## How it works ?
|
|
65
|
+
The following references are available :
|
|
66
|
+
|
|
67
|
+
### RGAA
|
|
68
|
+
|
|
69
|
+
For each criterion of the RGAA, the following algorithm is executed :
|
|
70
|
+
|
|
71
|
+

|
|
72
|
+
|
|
73
|
+
**Consult [this page](https://orange-opensource.github.io/uuv/docs/tools/uuv-a11y#rgaa) to find out which RGAA verifications are implemented in the library**
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
### With UNPKG
|
|
78
|
+
1. Add script tag to import @uuv/a11y in your html page :
|
|
79
|
+
```html
|
|
80
|
+
<script src="https://unpkg.com/@uuv/a11y/dist/bundle/uuv-a11y.bundle.js">
|
|
81
|
+
</script>
|
|
82
|
+
```
|
|
83
|
+
2. Add script tag to execute
|
|
84
|
+
```html
|
|
85
|
+
<script>
|
|
86
|
+
const rgaaChecker = new uuvA11y.RgaaChecker(url, enabledRules);
|
|
87
|
+
const result = await rgaaChecker.validate().toPromise();
|
|
88
|
+
// Print complete result
|
|
89
|
+
console.log(result);
|
|
90
|
+
// Print result summary group by criteria
|
|
91
|
+
console.log(result.summary());
|
|
92
|
+
</script>
|
|
93
|
+
```
|
|
94
|
+
[Stackblitz example](https://stackblitz.com/edit/web-platform-fihgra?file=index.html)
|
|
95
|
+
|
|
96
|
+
### As a dependency
|
|
97
|
+
1. Import @uuv/a11y npm dependency
|
|
98
|
+
```shell
|
|
99
|
+
npm install -D @uuv/a11y
|
|
100
|
+
```
|
|
101
|
+
2. Use it in your file
|
|
102
|
+
```typescript
|
|
103
|
+
import {
|
|
104
|
+
RgaaChecker,
|
|
105
|
+
A11yResult,
|
|
106
|
+
} from "@uuv/a11y";
|
|
107
|
+
|
|
108
|
+
const currentUrl = "<set your current url>";
|
|
109
|
+
const rgaaChecker = new RgaaChecker(currentUrl, enabledRules);
|
|
110
|
+
const result: A11yResult = await rgaaChecker.validate().toPromise();
|
|
111
|
+
// Print complete result
|
|
112
|
+
console.log(result);
|
|
113
|
+
// Print result summary group by criteria
|
|
114
|
+
console.log(result.summary());
|
|
115
|
+
```
|
|
116
|
+
### During E2E Testing (recommended usage car visualisation des noeuds)
|
|
117
|
+
1. add `@uuv/cypress` npm dependency :
|
|
118
|
+
```shell
|
|
119
|
+
npm install --save-dev @uuv/cypress
|
|
120
|
+
```
|
|
121
|
+
2. create the file `uuv/e2e/a11y.feature` in the project root with the following content and replace url `https://e2e-test-quest.github.io/simple-webapp/a11y-test.html` by yours :
|
|
122
|
+
```gherkin
|
|
123
|
+
Feature: A11y
|
|
124
|
+
|
|
125
|
+
Scenario: Default RGAA
|
|
126
|
+
When I visit path "https://e2e-test-quest.github.io/simple-webapp/a11y-test.html"
|
|
127
|
+
Then I should not have any rgaa accessibility issue
|
|
128
|
+
|
|
129
|
+
Scenario: RGAA with result
|
|
130
|
+
When I visit path "https://e2e-test-quest.github.io/simple-webapp/a11y-test.html"
|
|
131
|
+
Then I should have the following result based on the rgaa reference
|
|
132
|
+
"""json
|
|
133
|
+
{
|
|
134
|
+
"status": "error",
|
|
135
|
+
"criteria": {
|
|
136
|
+
"1.1": {
|
|
137
|
+
"status": "error"
|
|
138
|
+
},
|
|
139
|
+
"1.2": {
|
|
140
|
+
"status": "error"
|
|
141
|
+
},
|
|
142
|
+
"1.3": {
|
|
143
|
+
"status": "manual"
|
|
144
|
+
},
|
|
145
|
+
"1.4": {
|
|
146
|
+
"status": "manual"
|
|
147
|
+
},
|
|
148
|
+
"1.5": {
|
|
149
|
+
"status": "manual"
|
|
150
|
+
},
|
|
151
|
+
"1.6": {
|
|
152
|
+
"status": "success"
|
|
153
|
+
},
|
|
154
|
+
"2.1": {
|
|
155
|
+
"status": "error"
|
|
156
|
+
},
|
|
157
|
+
"8.1": {
|
|
158
|
+
"status": "error"
|
|
159
|
+
},
|
|
160
|
+
"8.3": {
|
|
161
|
+
"status": "success"
|
|
162
|
+
},
|
|
163
|
+
"8.4": {
|
|
164
|
+
"status": "manual"
|
|
165
|
+
},
|
|
166
|
+
"8.5": {
|
|
167
|
+
"status": "error"
|
|
168
|
+
},
|
|
169
|
+
"8.6": {
|
|
170
|
+
"status": "manual"
|
|
171
|
+
},
|
|
172
|
+
"8.10": {
|
|
173
|
+
"status": "error"
|
|
174
|
+
},
|
|
175
|
+
"11.1": {
|
|
176
|
+
"status": "success"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
"""
|
|
181
|
+
```
|
|
182
|
+
3. Then execute your tests :
|
|
183
|
+
```shell
|
|
184
|
+
npx uuv e2e
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
[<a href="https://github.com/Orange-OpenSource/uuv/blob/main/LICENSE">
|
|
191
|
+
<img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"/>
|
|
192
|
+
</a>](https://spdx.org/licenses/MIT.html)
|
|
193
|
+
|
|
194
|
+
This project is licensed under the terms of the [MIT license](https://github.com/Orange-OpenSource/uuv/blob/main/LICENSE).
|
|
195
|
+
|
|
196
|
+
## Authors
|
|
197
|
+
|
|
198
|
+
- [@luifr10](https://github.com/luifr10)
|
|
199
|
+
- [@stanlee974](https://github.com/stanlee974)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./lib";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./lib"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { A11yRule, A11yRuleResult, A11yReference } from "../model/";
|
|
3
|
+
export declare class Engine {
|
|
4
|
+
readonly targetUrl: string;
|
|
5
|
+
readonly reference: A11yReference;
|
|
6
|
+
constructor(targetUrl: string, reference: A11yReference);
|
|
7
|
+
buildCheckListItemFromRule(rule: A11yRule): Observable<A11yRuleResult>;
|
|
8
|
+
private getRuleResult;
|
|
9
|
+
private buildResultForAutoCheck;
|
|
10
|
+
private buildResultForManualCheck;
|
|
11
|
+
private getSelector;
|
|
12
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Engine = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const model_1 = require("../model/");
|
|
6
|
+
class Engine {
|
|
7
|
+
targetUrl;
|
|
8
|
+
reference;
|
|
9
|
+
constructor(targetUrl, reference) {
|
|
10
|
+
this.targetUrl = targetUrl;
|
|
11
|
+
this.reference = reference;
|
|
12
|
+
}
|
|
13
|
+
buildCheckListItemFromRule(rule) {
|
|
14
|
+
return new rxjs_1.Observable(observer => {
|
|
15
|
+
const foundElements = rule.query.execute();
|
|
16
|
+
const result = this.getRuleResult(rule, foundElements);
|
|
17
|
+
observer.next(result);
|
|
18
|
+
observer.complete();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
getRuleResult(rule, foundElements) {
|
|
22
|
+
if (rule.check === model_1.RuleCheckEnum.MANUAL) {
|
|
23
|
+
return this.buildResultForManualCheck(rule, foundElements);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
// Then we are considering rule as RuleCheckEnum.AUTO
|
|
27
|
+
return this.buildResultForAutoCheck(rule, foundElements);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
buildResultForAutoCheck(rule, $el) {
|
|
31
|
+
const a11YRuleresult = new model_1.A11yRuleResult(this.targetUrl, rule);
|
|
32
|
+
if (rule.shouldNotExist) {
|
|
33
|
+
if ($el?.length > 0) {
|
|
34
|
+
for (const element of $el) {
|
|
35
|
+
const selector = this.getSelector(element);
|
|
36
|
+
const validation = a11YRuleresult.getOrAddValidation(rule.criterion);
|
|
37
|
+
validation.errorNodes.push({
|
|
38
|
+
node: element,
|
|
39
|
+
selector: selector,
|
|
40
|
+
html: element.outerHTML
|
|
41
|
+
});
|
|
42
|
+
validation.status = model_1.A11yResultStatus.ERROR;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const validation = a11YRuleresult.getOrAddValidation(rule.criterion);
|
|
47
|
+
validation.status = model_1.A11yResultStatus.SUCCESS;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if ($el.length === 0 && !rule.elementType.includes("warning") && !rule.elementType.includes("obsolete")) {
|
|
52
|
+
const validation = a11YRuleresult.getOrAddValidation(rule.criterion);
|
|
53
|
+
validation.status = model_1.A11yResultStatus.ERROR;
|
|
54
|
+
validation.errorNodes.push({
|
|
55
|
+
selector: rule.query.getSelector(),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const validation = a11YRuleresult.getOrAddValidation(rule.criterion);
|
|
60
|
+
validation.status = model_1.A11yResultStatus.SUCCESS;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return a11YRuleresult;
|
|
64
|
+
}
|
|
65
|
+
buildResultForManualCheck(rule, $el) {
|
|
66
|
+
const a11YRuleresult = new model_1.A11yRuleResult(this.targetUrl, rule);
|
|
67
|
+
const validation = a11YRuleresult.getOrAddValidation(rule.criterion);
|
|
68
|
+
validation.status = model_1.A11yResultStatus.SUCCESS;
|
|
69
|
+
for (let i = 0; i < $el.length; i++) {
|
|
70
|
+
const selector = this.getSelector($el[i]);
|
|
71
|
+
const attributesToCheck = [];
|
|
72
|
+
rule.attributes.forEach((attribute) => {
|
|
73
|
+
const attributeFilledWithInformation = $el[i].getAttribute(attribute);
|
|
74
|
+
if (attributeFilledWithInformation) {
|
|
75
|
+
attributesToCheck.push(` ${attribute}=${attributeFilledWithInformation}`);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const manualValidation = a11YRuleresult.getOrAddValidation(rule.criterion);
|
|
79
|
+
manualValidation.status = model_1.A11yResultStatus.MANUAL;
|
|
80
|
+
manualValidation.nodesToCheckManually.push({
|
|
81
|
+
node: $el[i],
|
|
82
|
+
selector: selector,
|
|
83
|
+
attributes: attributesToCheck.toString(),
|
|
84
|
+
html: $el[i].outerHTML,
|
|
85
|
+
help: rule.id ? `${this.reference.getRuleUrl(rule.id)}` : ""
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return a11YRuleresult;
|
|
89
|
+
}
|
|
90
|
+
getSelector(element) {
|
|
91
|
+
const path = [];
|
|
92
|
+
while (element.nodeType === Node.ELEMENT_NODE) {
|
|
93
|
+
let selector = element.nodeName.toLowerCase();
|
|
94
|
+
if (element.id) {
|
|
95
|
+
selector += "#" + element.id;
|
|
96
|
+
path.unshift(selector);
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
else if (element.getAttribute("data-testid")) {
|
|
100
|
+
selector += `[data-testid=${element.getAttribute("data-testid")}]`;
|
|
101
|
+
path.unshift(selector);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
let sibling = element.previousSibling;
|
|
106
|
+
let index = 1;
|
|
107
|
+
while (sibling) {
|
|
108
|
+
if (sibling.nodeType === Node.ELEMENT_NODE && sibling.nodeName.toLowerCase() === selector) {
|
|
109
|
+
index++;
|
|
110
|
+
}
|
|
111
|
+
sibling = sibling.previousSibling;
|
|
112
|
+
}
|
|
113
|
+
if (index > 1 || element.nextSibling) {
|
|
114
|
+
selector += ":nth-of-type(" + index + ")";
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
path.unshift(selector);
|
|
118
|
+
element = element.parentNode;
|
|
119
|
+
}
|
|
120
|
+
return path.join(" > ");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.Engine = Engine;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./reference"), exports);
|
|
18
|
+
__exportStar(require("./model"), exports);
|
|
19
|
+
__exportStar(require("./query"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A11yReference } from "./reference";
|
|
2
|
+
import { Observable } from "rxjs";
|
|
3
|
+
import { A11yResult } from "./result";
|
|
4
|
+
import { A11yRule } from "./rule";
|
|
5
|
+
import { Engine } from "../engine/engine";
|
|
6
|
+
export declare abstract class A11yChecker {
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly engine: Engine;
|
|
9
|
+
readonly reference: A11yReference;
|
|
10
|
+
protected constructor(url: string, engine: Engine, reference: A11yReference);
|
|
11
|
+
abstract rules(): A11yRule[];
|
|
12
|
+
validate(): Observable<A11yResult>;
|
|
13
|
+
private buildCheckList;
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.A11yChecker = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const result_1 = require("./result");
|
|
6
|
+
class A11yChecker {
|
|
7
|
+
url;
|
|
8
|
+
engine;
|
|
9
|
+
reference;
|
|
10
|
+
constructor(url, engine, reference) {
|
|
11
|
+
this.url = url;
|
|
12
|
+
this.engine = engine;
|
|
13
|
+
this.reference = reference;
|
|
14
|
+
}
|
|
15
|
+
validate() {
|
|
16
|
+
const result = new result_1.A11yResult(this.url, this.reference);
|
|
17
|
+
const rules = this.rules();
|
|
18
|
+
const checkList = this.buildCheckList(rules);
|
|
19
|
+
return (0, rxjs_1.forkJoin)(checkList)
|
|
20
|
+
.pipe((0, rxjs_1.map)((ruleResults) => {
|
|
21
|
+
result.ruleResults = ruleResults;
|
|
22
|
+
result.computeStatus();
|
|
23
|
+
return result;
|
|
24
|
+
}), (0, rxjs_1.tap)(result => {
|
|
25
|
+
console.debug("result");
|
|
26
|
+
console.debug(result);
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
buildCheckList(rules) {
|
|
30
|
+
const checkList = [];
|
|
31
|
+
rules.forEach(rule => checkList.push(this.engine.buildCheckListItemFromRule(rule)));
|
|
32
|
+
return checkList;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.A11yChecker = A11yChecker;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./checker"), exports);
|
|
18
|
+
__exportStar(require("./reference"), exports);
|
|
19
|
+
__exportStar(require("./result"), exports);
|
|
20
|
+
__exportStar(require("./rule"), exports);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { A11yRule } from "./rule";
|
|
2
|
+
export interface A11yReference {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
rules: A11yRule[];
|
|
6
|
+
url: string;
|
|
7
|
+
/**
|
|
8
|
+
* Build complete coverage
|
|
9
|
+
*/
|
|
10
|
+
coverage(): A11yReferenceCoverage;
|
|
11
|
+
/**
|
|
12
|
+
* Returns online rule url related to a ruleId
|
|
13
|
+
* @param ruleId
|
|
14
|
+
*/
|
|
15
|
+
getRuleUrl(ruleId: string): string;
|
|
16
|
+
}
|
|
17
|
+
export declare enum A11yReferenceEnum {
|
|
18
|
+
RGAA = "RGAA",
|
|
19
|
+
WCAG_WEB = "WCAG-WEB",
|
|
20
|
+
WCAG_ANDROID = "WCAG-ANDROID",
|
|
21
|
+
WCAG_IOS = "WCAG-IOS"
|
|
22
|
+
}
|
|
23
|
+
export declare class Comments {
|
|
24
|
+
info?: string;
|
|
25
|
+
warning?: string;
|
|
26
|
+
danger?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare abstract class Coverage {
|
|
29
|
+
id: string;
|
|
30
|
+
name?: string;
|
|
31
|
+
auto: number;
|
|
32
|
+
partial: number;
|
|
33
|
+
wontBeImplemented: number;
|
|
34
|
+
manual: number;
|
|
35
|
+
inProgress: number;
|
|
36
|
+
testsCount: number;
|
|
37
|
+
comments?: Comments;
|
|
38
|
+
autoPercentage(): number;
|
|
39
|
+
}
|
|
40
|
+
export declare class A11yReferenceCoverage {
|
|
41
|
+
name: string;
|
|
42
|
+
topics: A11yReferenceTopicCoverage[];
|
|
43
|
+
constructor(name: string);
|
|
44
|
+
}
|
|
45
|
+
export declare class A11yReferenceTopicCoverage extends Coverage {
|
|
46
|
+
criterias: A11yReferenceCriteriaCoverage[];
|
|
47
|
+
constructor(id: any, name: any);
|
|
48
|
+
}
|
|
49
|
+
export declare class A11yReferenceCriteriaCoverage extends Coverage {
|
|
50
|
+
tests: A11yReferenceTestCoverage[];
|
|
51
|
+
constructor(id: any, name: any);
|
|
52
|
+
}
|
|
53
|
+
export declare class A11yReferenceTestCoverage extends Coverage {
|
|
54
|
+
constructor(id: any, name: any);
|
|
55
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.A11yReferenceTestCoverage = exports.A11yReferenceCriteriaCoverage = exports.A11yReferenceTopicCoverage = exports.A11yReferenceCoverage = exports.Coverage = exports.Comments = exports.A11yReferenceEnum = void 0;
|
|
4
|
+
var A11yReferenceEnum;
|
|
5
|
+
(function (A11yReferenceEnum) {
|
|
6
|
+
A11yReferenceEnum["RGAA"] = "RGAA";
|
|
7
|
+
A11yReferenceEnum["WCAG_WEB"] = "WCAG-WEB";
|
|
8
|
+
A11yReferenceEnum["WCAG_ANDROID"] = "WCAG-ANDROID";
|
|
9
|
+
A11yReferenceEnum["WCAG_IOS"] = "WCAG-IOS";
|
|
10
|
+
})(A11yReferenceEnum = exports.A11yReferenceEnum || (exports.A11yReferenceEnum = {}));
|
|
11
|
+
class Comments {
|
|
12
|
+
info;
|
|
13
|
+
warning;
|
|
14
|
+
danger;
|
|
15
|
+
}
|
|
16
|
+
exports.Comments = Comments;
|
|
17
|
+
class Coverage {
|
|
18
|
+
id;
|
|
19
|
+
name;
|
|
20
|
+
auto = 0;
|
|
21
|
+
partial = 0;
|
|
22
|
+
wontBeImplemented = 0;
|
|
23
|
+
manual = 0;
|
|
24
|
+
inProgress = 0;
|
|
25
|
+
testsCount = 0;
|
|
26
|
+
comments;
|
|
27
|
+
autoPercentage() {
|
|
28
|
+
return Math.round(this.auto /
|
|
29
|
+
(this.testsCount) * 100) || 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.Coverage = Coverage;
|
|
33
|
+
class A11yReferenceCoverage {
|
|
34
|
+
name;
|
|
35
|
+
topics = [];
|
|
36
|
+
constructor(name) {
|
|
37
|
+
this.name = name;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.A11yReferenceCoverage = A11yReferenceCoverage;
|
|
41
|
+
class A11yReferenceTopicCoverage extends Coverage {
|
|
42
|
+
criterias = [];
|
|
43
|
+
constructor(id, name) {
|
|
44
|
+
super();
|
|
45
|
+
this.id = id;
|
|
46
|
+
this.name = name;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.A11yReferenceTopicCoverage = A11yReferenceTopicCoverage;
|
|
50
|
+
class A11yReferenceCriteriaCoverage extends Coverage {
|
|
51
|
+
tests = [];
|
|
52
|
+
constructor(id, name) {
|
|
53
|
+
super();
|
|
54
|
+
this.id = id;
|
|
55
|
+
this.name = name;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.A11yReferenceCriteriaCoverage = A11yReferenceCriteriaCoverage;
|
|
59
|
+
class A11yReferenceTestCoverage extends Coverage {
|
|
60
|
+
constructor(id, name) {
|
|
61
|
+
super();
|
|
62
|
+
this.id = id;
|
|
63
|
+
this.name = name;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.A11yReferenceTestCoverage = A11yReferenceTestCoverage;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { A11yRule } from "./rule";
|
|
2
|
+
import { A11yReference } from "./reference";
|
|
3
|
+
export declare enum A11yResultStatus {
|
|
4
|
+
UNKNOWN = "unknown",
|
|
5
|
+
SUCCESS = "success",
|
|
6
|
+
MANUAL = "manual",
|
|
7
|
+
ERROR = "error"
|
|
8
|
+
}
|
|
9
|
+
export interface NonCompliantNode {
|
|
10
|
+
node?: HTMLElement;
|
|
11
|
+
selector: string;
|
|
12
|
+
html?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface NodeToCheckManually {
|
|
15
|
+
node: HTMLElement;
|
|
16
|
+
selector: string;
|
|
17
|
+
attributes: string;
|
|
18
|
+
html: string;
|
|
19
|
+
help: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class A11yRuleValidationResult {
|
|
22
|
+
readonly criteria: string;
|
|
23
|
+
status: A11yResultStatus;
|
|
24
|
+
errorNodes: NonCompliantNode[];
|
|
25
|
+
nodesToCheckManually: NodeToCheckManually[];
|
|
26
|
+
constructor(criteria: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class A11yRuleResult {
|
|
29
|
+
readonly url: string;
|
|
30
|
+
readonly rule: A11yRule;
|
|
31
|
+
status: A11yResultStatus;
|
|
32
|
+
validations: A11yRuleValidationResult[];
|
|
33
|
+
constructor(url: string, rule: A11yRule);
|
|
34
|
+
getOrAddValidation(criteria: string): A11yRuleValidationResult;
|
|
35
|
+
getErrorNodes(): NonCompliantNode[];
|
|
36
|
+
getNodesToCheckManually(): NodeToCheckManually[];
|
|
37
|
+
computeStatus(): void;
|
|
38
|
+
private getStatus;
|
|
39
|
+
}
|
|
40
|
+
export declare class A11yResult {
|
|
41
|
+
readonly url: string;
|
|
42
|
+
readonly reference: A11yReference;
|
|
43
|
+
status: A11yResultStatus;
|
|
44
|
+
ruleResults: A11yRuleResult[];
|
|
45
|
+
constructor(url: string, reference: A11yReference);
|
|
46
|
+
computeStatus(): void;
|
|
47
|
+
summary(): {
|
|
48
|
+
status: A11yResultStatus;
|
|
49
|
+
criteria: {};
|
|
50
|
+
};
|
|
51
|
+
private buildSummaryForCriterion;
|
|
52
|
+
private getPosition;
|
|
53
|
+
private groupRuleResultByLevel;
|
|
54
|
+
private getKeyOfLevel;
|
|
55
|
+
private groupRuleResultByCriterion;
|
|
56
|
+
private groupRuleResultByTestOfACriterion;
|
|
57
|
+
}
|