@uuv/a11y 1.0.0-beta.7 → 1.0.0-beta.70

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +684 -0
  2. package/LICENSE +0 -2
  3. package/README.md +7 -7
  4. package/bundle/uuv-a11y.bundle.js +2 -2
  5. package/bundle/uuv-a11y.bundle.js.LICENSE.txt +12 -0
  6. package/dist/CHANGELOG.md +683 -0
  7. package/dist/README.md +7 -7
  8. package/dist/lib/engine/engine.js +17 -7
  9. package/dist/lib/model/checker.d.ts +3 -12
  10. package/dist/lib/model/checker.js +0 -33
  11. package/dist/lib/model/checklist-checker.d.ts +15 -0
  12. package/dist/lib/model/checklist-checker.js +61 -0
  13. package/dist/lib/model/index.d.ts +2 -1
  14. package/dist/lib/model/index.js +2 -1
  15. package/dist/lib/model/reference.js +1 -1
  16. package/dist/lib/model/result.js +1 -1
  17. package/dist/lib/model/rule.d.ts +8 -8
  18. package/dist/lib/model/rule.js +3 -3
  19. package/dist/lib/model/uuv-a11y-result.d.ts +54 -0
  20. package/dist/lib/model/uuv-a11y-result.js +17 -0
  21. package/dist/lib/query/accessible-name.query.d.ts +2 -0
  22. package/dist/lib/query/accessible-name.query.js +8 -2
  23. package/dist/lib/query/compliant-attributes/attribut-specification.d.ts +24 -2
  24. package/dist/lib/query/compliant-attributes/attribut-specification.js +64 -2
  25. package/dist/lib/query/compliant-attributes/attribute-checker.d.ts +24 -0
  26. package/dist/lib/query/compliant-attributes/attribute-checker.js +36 -0
  27. package/dist/lib/reference/index.d.ts +1 -0
  28. package/dist/lib/reference/index.js +1 -0
  29. package/dist/lib/reference/rgaa/coverage/coverage-helper.js +18 -9
  30. package/dist/lib/reference/rgaa/coverage/coverage-statement.json +39 -2
  31. package/dist/lib/reference/rgaa/rgaa-checker.d.ts +3 -3
  32. package/dist/lib/reference/rgaa/rgaa-checker.js +2 -2
  33. package/dist/lib/reference/rgaa/rules/1-image.d.ts +4 -4
  34. package/dist/lib/reference/rgaa/rules/1-image.js +2 -2
  35. package/dist/lib/reference/rgaa/rules/11-form.d.ts +4 -4
  36. package/dist/lib/reference/rgaa/rules/2-frame.d.ts +4 -4
  37. package/dist/lib/reference/rgaa/rules/3-color.d.ts +4 -4
  38. package/dist/lib/reference/rgaa/rules/5-table.d.ts +12 -1
  39. package/dist/lib/reference/rgaa/rules/5-table.js +292 -1
  40. package/dist/lib/reference/rgaa/rules/6-link.d.ts +12 -1
  41. package/dist/lib/reference/rgaa/rules/6-link.js +147 -1
  42. package/dist/lib/reference/rgaa/rules/8-required-element.d.ts +4 -4
  43. package/dist/lib/reference/rgaa/rules/8-required-element.js +57 -3
  44. package/dist/lib/reference/rgaa/selector-helper.d.ts +36 -0
  45. package/dist/lib/reference/rgaa/selector-helper.js +73 -1
  46. package/dist/lib/reference/wcag/index.d.ts +1 -0
  47. package/dist/lib/reference/wcag/index.js +17 -0
  48. package/dist/lib/reference/wcag/wcag-checker.d.ts +14 -0
  49. package/dist/lib/reference/wcag/wcag-checker.js +86 -0
  50. package/dist/lib/reference/wcag/wcag-helper.d.ts +9 -0
  51. package/dist/lib/reference/wcag/wcag-helper.js +73 -0
  52. package/dist/package.json +17 -13
  53. package/package.json +15 -11
package/dist/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
 
2
2
  # @uuv/a11y
3
3
  <div align="center">
4
- <a href="https://orange-opensource.github.io/uuv/">
4
+ <a href="https://e2e-test-quest.github.io/uuv/">
5
5
  <picture>
6
- <img alt="UUV Logo" src="https://orange-opensource.github.io/uuv/img/uuv.png">
6
+ <img alt="UUV Logo" src="https://e2e-test-quest.github.io/uuv/img/uuv.png">
7
7
  </picture>
8
8
  </a>
9
9
  </div>
@@ -70,7 +70,7 @@ For each criterion of the RGAA, the following algorithm is executed :
70
70
 
71
71
  ![Diagram a11Y RGAA](https://unpkg.com/@uuv/a11y/docs/diagram-a11y-rgaa.png)
72
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**
73
+ **Consult [this page](https://e2e-test-quest.github.io/uuv/docs/tools/uuv-a11y#rgaa) to find out which RGAA verifications are implemented in the library**
74
74
  </p>
75
75
 
76
76
  ## Usage
@@ -156,22 +156,22 @@ For each criterion of the RGAA, the following algorithm is executed :
156
156
  }
157
157
  """
158
158
  ```
159
- You can also see the [French example](https://github.com/Orange-OpenSource/uuv/blob/main/example/fr-rgaa.feature) or the complete [English example](https://github.com/Orange-OpenSource/uuv/blob/main/example/en-rgaa.feature).
159
+ You can also see the [French example](https://github.com/e2e-test-quest/uuv/blob/main/example/fr-rgaa.feature) or the complete [English example](https://github.com/e2e-test-quest/uuv/blob/main/example/en-rgaa.feature).
160
160
  3. Then execute your tests :
161
161
  ```shell
162
162
  npx uuv e2e
163
163
  ```
164
164
 
165
165
  ## Want to contribute ?
166
- Your help is welcome, see the [Contributors guide](https://github.com/Orange-OpenSource/uuv/blob/main/packages/a11y/CONTRIBUTING.md).
166
+ Your help is welcome, see the [Contributors guide](https://github.com/e2e-test-quest/uuv/blob/main/packages/a11y/CONTRIBUTING.md).
167
167
 
168
168
  ## License
169
169
 
170
- [<a href="https://github.com/Orange-OpenSource/uuv/blob/main/LICENSE">
170
+ [<a href="https://github.com/e2e-test-quest/uuv/blob/main/LICENSE">
171
171
  <img src="https://img.shields.io/badge/license-MIT-blue" alt="MIT license"/>
172
172
  </a>](https://spdx.org/licenses/MIT.html)
173
173
 
174
- This project is licensed under the terms of the [MIT license](https://github.com/Orange-OpenSource/uuv/blob/main/LICENSE).
174
+ This project is licensed under the terms of the [MIT license](https://github.com/e2e-test-quest/uuv/blob/main/LICENSE).
175
175
 
176
176
  ## Authors
177
177
 
@@ -67,22 +67,32 @@ class Engine {
67
67
  const a11YRuleResult = new model_1.A11yRuleResult(this.targetUrl, rule);
68
68
  const validation = a11YRuleResult.getOrAddValidation(rule.criterion);
69
69
  validation.status = model_1.A11yResultStatus.SUCCESS;
70
- for (let i = 0; i < queryResults.length; i++) {
71
- const domNode = queryResults[i].domNode;
70
+ for (const element of queryResults) {
71
+ const domNode = element.domNode;
72
72
  const selector = this.getSelector(domNode);
73
73
  const attributesToCheck = [];
74
74
  rule.attributes.forEach((attribute) => {
75
- const attributeFilledWithInformation = domNode.getAttribute(attribute);
76
- if (attributeFilledWithInformation) {
77
- attributesToCheck.push(` ${attribute}=${attributeFilledWithInformation}`);
75
+ const childData = attribute.split(":");
76
+ if (childData.length > 1) {
77
+ domNode.childNodes.forEach((childNode) => {
78
+ if (childNode.nodeName === childData[1]) {
79
+ attributesToCheck.push(`${attribute}=${childNode.textContent}`);
80
+ }
81
+ });
82
+ }
83
+ else {
84
+ const attributeFilledWithInformation = domNode.getAttribute(attribute);
85
+ if (attributeFilledWithInformation) {
86
+ attributesToCheck.push(`${attribute}=${attributeFilledWithInformation}`);
87
+ }
78
88
  }
79
89
  });
80
90
  const manualValidation = a11YRuleResult.getOrAddValidation(rule.criterion);
81
91
  manualValidation.status = model_1.A11yResultStatus.MANUAL;
82
92
  manualValidation.nodesToCheckManually.push({
83
- node: queryResults[i],
93
+ node: element,
84
94
  selector: selector,
85
- attributes: attributesToCheck.toString(),
95
+ attributes: attributesToCheck.join(", "),
86
96
  html: domNode.outerHTML,
87
97
  help: rule.id ? `${this.reference.getRuleUrl(rule.id)}` : ""
88
98
  });
@@ -1,14 +1,5 @@
1
- import { A11yReference } from "./reference";
2
1
  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;
2
+ import { UuvA11yResultUsecase, UuvA11yResultUsecaseLocation } from "./uuv-a11y-result";
3
+ export interface A11yChecker {
4
+ validate(name: string, script: string, location: UuvA11yResultUsecaseLocation): Observable<UuvA11yResultUsecase>;
14
5
  }
@@ -1,35 +1,2 @@
1
1
  "use strict";
2
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,15 @@
1
+ import { A11yReference } from "./reference";
2
+ import { Observable } from "rxjs";
3
+ import { A11yRule } from "./rule";
4
+ import { Engine } from "../engine/engine";
5
+ import { A11yChecker } from "./checker";
6
+ import { UuvA11yResultUsecase, UuvA11yResultUsecaseLocation } from "./uuv-a11y-result";
7
+ export declare abstract class A11yChecklistChecker implements A11yChecker {
8
+ readonly url: string;
9
+ readonly engine: Engine;
10
+ readonly reference: A11yReference;
11
+ protected constructor(url: string, engine: Engine, reference: A11yReference);
12
+ abstract rules(): A11yRule[];
13
+ validate(name: string, script: string, location: UuvA11yResultUsecaseLocation): Observable<UuvA11yResultUsecase>;
14
+ private buildCheckList;
15
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.A11yChecklistChecker = void 0;
4
+ const reference_1 = require("./reference");
5
+ const rxjs_1 = require("rxjs");
6
+ const result_1 = require("./result");
7
+ const uuv_a11y_result_1 = require("./uuv-a11y-result");
8
+ class A11yChecklistChecker {
9
+ url;
10
+ engine;
11
+ reference;
12
+ constructor(url, engine, reference) {
13
+ this.url = url;
14
+ this.engine = engine;
15
+ this.reference = reference;
16
+ }
17
+ validate(name, script, location) {
18
+ const result = new result_1.A11yResult(this.url, this.reference);
19
+ const rules = this.rules();
20
+ const checkList = this.buildCheckList(rules);
21
+ return (0, rxjs_1.forkJoin)(checkList)
22
+ .pipe((0, rxjs_1.map)((ruleResults) => {
23
+ result.ruleResults = ruleResults;
24
+ result.computeStatus();
25
+ const issues = ruleResults.map(ruleResult => {
26
+ return {
27
+ type: uuv_a11y_result_1.IssueType.Error,
28
+ code: ruleResult.rule.id,
29
+ message: ruleResult.rule.description || "",
30
+ selector: ruleResult.getErrorNodes().map(error => error.selector).join(", "),
31
+ runnerExtras: {
32
+ rule: ruleResult.rule,
33
+ validations: ruleResult.validations,
34
+ errorNodes: ruleResult.getErrorNodes()
35
+ }
36
+ };
37
+ });
38
+ return {
39
+ name,
40
+ script,
41
+ location,
42
+ result: {
43
+ date: (new Date()).getTime(),
44
+ reference: reference_1.A11yReferenceEnum.WCAG_WEB,
45
+ issues,
46
+ rawResult: result,
47
+ status: result.status
48
+ },
49
+ };
50
+ }), (0, rxjs_1.tap)(result => {
51
+ console.debug("result");
52
+ console.debug(result);
53
+ }));
54
+ }
55
+ buildCheckList(rules) {
56
+ const checkList = [];
57
+ rules.forEach(rule => checkList.push(this.engine.buildCheckListItemFromRule(rule)));
58
+ return checkList;
59
+ }
60
+ }
61
+ exports.A11yChecklistChecker = A11yChecklistChecker;
@@ -1,4 +1,5 @@
1
- export * from "./checker";
2
1
  export * from "./reference";
2
+ export * from "./checker";
3
3
  export * from "./result";
4
+ export * from "./uuv-a11y-result";
4
5
  export * from "./rule";
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./checker"), exports);
18
17
  __exportStar(require("./reference"), exports);
18
+ __exportStar(require("./checker"), exports);
19
19
  __exportStar(require("./result"), exports);
20
+ __exportStar(require("./uuv-a11y-result"), exports);
20
21
  __exportStar(require("./rule"), exports);
@@ -7,7 +7,7 @@ var A11yReferenceEnum;
7
7
  A11yReferenceEnum["WCAG_WEB"] = "WCAG-WEB";
8
8
  A11yReferenceEnum["WCAG_ANDROID"] = "WCAG-ANDROID";
9
9
  A11yReferenceEnum["WCAG_IOS"] = "WCAG-IOS";
10
- })(A11yReferenceEnum = exports.A11yReferenceEnum || (exports.A11yReferenceEnum = {}));
10
+ })(A11yReferenceEnum || (exports.A11yReferenceEnum = A11yReferenceEnum = {}));
11
11
  class Comments {
12
12
  info;
13
13
  warning;
@@ -7,7 +7,7 @@ var A11yResultStatus;
7
7
  A11yResultStatus["SUCCESS"] = "success";
8
8
  A11yResultStatus["MANUAL"] = "manual";
9
9
  A11yResultStatus["ERROR"] = "error";
10
- })(A11yResultStatus = exports.A11yResultStatus || (exports.A11yResultStatus = {}));
10
+ })(A11yResultStatus || (exports.A11yResultStatus = A11yResultStatus = {}));
11
11
  class A11yRuleValidationResult {
12
12
  criteria;
13
13
  status = A11yResultStatus.UNKNOWN;
@@ -33,15 +33,15 @@ export declare class AutoCheckA11yRule implements A11yRule {
33
33
  help?: string | string[];
34
34
  shouldNotExist?: boolean;
35
35
  }): AutoCheckA11yRule & {
36
- attributes?: string[] | undefined;
36
+ attributes?: string[];
37
37
  criterion: string;
38
38
  wcag: string;
39
39
  id: string;
40
40
  elementType: string;
41
41
  query: Query;
42
- description?: string | undefined;
43
- help?: string | string[] | undefined;
44
- shouldNotExist?: boolean | undefined;
42
+ description?: string;
43
+ help?: string | string[];
44
+ shouldNotExist?: boolean;
45
45
  };
46
46
  }
47
47
  export declare class ManualCheckA11yRule implements A11yRule {
@@ -66,15 +66,15 @@ export declare class ManualCheckA11yRule implements A11yRule {
66
66
  help?: string;
67
67
  shouldNotExist?: boolean;
68
68
  }): ManualCheckA11yRule & {
69
- attributes?: string[] | undefined;
69
+ attributes?: string[];
70
70
  criterion: string;
71
71
  wcag: string;
72
72
  id: string;
73
73
  elementType: string;
74
74
  query: Query;
75
- description?: string | undefined;
76
- help?: string | undefined;
77
- shouldNotExist?: boolean | undefined;
75
+ description?: string;
76
+ help?: string;
77
+ shouldNotExist?: boolean;
78
78
  };
79
79
  }
80
80
  export declare enum RuleCheckEnum {
@@ -37,15 +37,15 @@ var RuleCheckEnum;
37
37
  (function (RuleCheckEnum) {
38
38
  RuleCheckEnum["MANUAL"] = "MANUAL";
39
39
  RuleCheckEnum["AUTO"] = "AUTO";
40
- })(RuleCheckEnum = exports.RuleCheckEnum || (exports.RuleCheckEnum = {}));
40
+ })(RuleCheckEnum || (exports.RuleCheckEnum = RuleCheckEnum = {}));
41
41
  var CustomFilter;
42
42
  (function (CustomFilter) {
43
43
  CustomFilter["DOCTYPE"] = "$DOCTYPE";
44
44
  CustomFilter["FORM_FIELD"] = "$FORMFIELD";
45
- })(CustomFilter = exports.CustomFilter || (exports.CustomFilter = {}));
45
+ })(CustomFilter || (exports.CustomFilter = CustomFilter = {}));
46
46
  var RuleTypeEnum;
47
47
  (function (RuleTypeEnum) {
48
48
  RuleTypeEnum["TAG"] = "TAG";
49
49
  RuleTypeEnum["ROLE"] = "ROLE";
50
50
  RuleTypeEnum["COLOR"] = "COLOR";
51
- })(RuleTypeEnum = exports.RuleTypeEnum || (exports.RuleTypeEnum = {}));
51
+ })(RuleTypeEnum || (exports.RuleTypeEnum = RuleTypeEnum = {}));
@@ -0,0 +1,54 @@
1
+ import { A11yReferenceEnum } from "./reference";
2
+ import { A11yResultStatus } from "./result";
3
+ export declare enum IssueType {
4
+ Warning = "warning",
5
+ Error = "error",
6
+ Notice = "notice"
7
+ }
8
+ export type UuvA11yResultApp = {
9
+ name: string;
10
+ description: string;
11
+ usecases: UuvA11yResultUsecase[];
12
+ };
13
+ export type UuvA11yResultUsecase = {
14
+ name: string;
15
+ script: string;
16
+ location: UuvA11yResultUsecaseLocation;
17
+ result: UuvA11yResultExecution;
18
+ };
19
+ export type UuvA11yResultUsecaseLocation = {
20
+ file: string;
21
+ line: number;
22
+ column: number;
23
+ };
24
+ export type UuvA11yResultExecution = {
25
+ date: number;
26
+ reference: A11yReferenceEnum;
27
+ issues: AccessibilityIssue[];
28
+ status: A11yResultStatus;
29
+ rawResult?: any;
30
+ };
31
+ export type AccessibilityIssue = {
32
+ type: IssueType;
33
+ code: string;
34
+ message: string;
35
+ selector: string;
36
+ htmlElement?: Element | null;
37
+ runnerExtras: RunnerExtras | any;
38
+ };
39
+ export type RunnerExtras = {
40
+ description: string;
41
+ impact: IssueImpact;
42
+ help: string;
43
+ helpUrl: string;
44
+ };
45
+ export declare enum IssueImpact {
46
+ Minor = "minor",
47
+ Moderate = "moderate",
48
+ Serious = "serious",
49
+ Critical = "critical",
50
+ Unknown = "unknown"
51
+ }
52
+ export type UuvA11yResult = {
53
+ app: UuvA11yResultApp;
54
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IssueImpact = exports.IssueType = void 0;
4
+ var IssueType;
5
+ (function (IssueType) {
6
+ IssueType["Warning"] = "warning";
7
+ IssueType["Error"] = "error";
8
+ IssueType["Notice"] = "notice";
9
+ })(IssueType || (exports.IssueType = IssueType = {}));
10
+ var IssueImpact;
11
+ (function (IssueImpact) {
12
+ IssueImpact["Minor"] = "minor";
13
+ IssueImpact["Moderate"] = "moderate";
14
+ IssueImpact["Serious"] = "serious";
15
+ IssueImpact["Critical"] = "critical";
16
+ IssueImpact["Unknown"] = "unknown";
17
+ })(IssueImpact || (exports.IssueImpact = IssueImpact = {}));
@@ -4,5 +4,7 @@ export declare class AccessibleNameQuery implements Query {
4
4
  readonly shouldBeEmpty: boolean;
5
5
  constructor(subQuery: Query, shouldBeEmpty: boolean);
6
6
  execute(): QueryResult[];
7
+ private isNullOrEmpty;
8
+ private isNotNullAndNotEmpty;
7
9
  getSelector(): string;
8
10
  }
@@ -13,10 +13,10 @@ class AccessibleNameQuery {
13
13
  execute() {
14
14
  return this.subQuery.execute().filter(element => {
15
15
  const accessibleName = (0, dom_accessibility_api_1.computeAccessibleName)(element.domNode);
16
- if (this.shouldBeEmpty && (0, lodash_1.isEmpty)(accessibleName)) {
16
+ if (this.shouldBeEmpty && this.isNullOrEmpty(accessibleName)) {
17
17
  return true;
18
18
  }
19
- else if (!this.shouldBeEmpty && !(0, lodash_1.isEmpty)(accessibleName)) {
19
+ else if (!this.shouldBeEmpty && this.isNotNullAndNotEmpty(accessibleName)) {
20
20
  return true;
21
21
  }
22
22
  else {
@@ -24,6 +24,12 @@ class AccessibleNameQuery {
24
24
  }
25
25
  });
26
26
  }
27
+ isNullOrEmpty(accessibleName) {
28
+ return (0, lodash_1.isNull)(accessibleName) || (0, lodash_1.isEmpty)(accessibleName);
29
+ }
30
+ isNotNullAndNotEmpty(accessibleName) {
31
+ return !(0, lodash_1.isNull)(accessibleName) && !(0, lodash_1.isEmpty)(accessibleName);
32
+ }
27
33
  getSelector() {
28
34
  return `AccessibleName: ${this.subQuery.getSelector()}`;
29
35
  }
@@ -1,12 +1,34 @@
1
+ export interface IAttributeSpecification {
2
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
3
+ }
1
4
  export declare class EmptyAttributeSpecification implements IAttributeSpecification {
2
5
  isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
3
6
  }
4
7
  export declare class NotEmptyAttributeSpecification implements IAttributeSpecification {
5
8
  isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
6
9
  }
7
- export interface IAttributeSpecification {
10
+ export declare class EmptyElementWithIdSpecification implements IAttributeSpecification {
8
11
  isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
9
12
  }
10
- export declare class EmptyElementWithIdSpecification implements IAttributeSpecification {
13
+ export declare class NotUniqueIdAttributeSpecification implements IAttributeSpecification {
14
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
15
+ }
16
+ export declare class NotEqualsAttributeSpecification implements IAttributeSpecification {
17
+ private expectedValueList;
18
+ constructor(expectedValueList: string[]);
19
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
20
+ }
21
+ export declare class EqualsAttributeSpecification implements IAttributeSpecification {
22
+ private expectedValueList;
23
+ constructor(expectedValueList: string[]);
24
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
25
+ }
26
+ export declare class AccessibleNameNotContainsVisibleTextSpecification implements IAttributeSpecification {
27
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
28
+ }
29
+ export declare class EmptyInnerTextSpecification implements IAttributeSpecification {
30
+ isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
31
+ }
32
+ export declare class NotEmptyInnerTextSpecification implements IAttributeSpecification {
11
33
  isSatisfiedBy(element: HTMLElement, attributeName: string): boolean;
12
34
  }
@@ -3,10 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.EmptyElementWithIdSpecification = exports.NotEmptyAttributeSpecification = exports.EmptyAttributeSpecification = void 0;
6
+ exports.NotEmptyInnerTextSpecification = exports.EmptyInnerTextSpecification = exports.AccessibleNameNotContainsVisibleTextSpecification = exports.EqualsAttributeSpecification = exports.NotEqualsAttributeSpecification = exports.NotUniqueIdAttributeSpecification = exports.EmptyElementWithIdSpecification = exports.NotEmptyAttributeSpecification = exports.EmptyAttributeSpecification = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  // eslint-disable-next-line @typescript-eslint/no-var-requires
9
9
  const $ = require("jquery/dist/jquery.min");
10
+ const dom_accessibility_api_1 = require("dom-accessibility-api");
10
11
  class EmptyAttributeSpecification {
11
12
  isSatisfiedBy(element, attributeName) {
12
13
  const attributeValue = element.getAttribute(attributeName);
@@ -24,7 +25,7 @@ exports.NotEmptyAttributeSpecification = NotEmptyAttributeSpecification;
24
25
  class EmptyElementWithIdSpecification {
25
26
  isSatisfiedBy(element, attributeName) {
26
27
  const attributeValue = element.getAttribute(attributeName);
27
- if (lodash_1.default.isEmpty(attributeValue) || lodash_1.default.isNull(attributeValue)) {
28
+ if (attributeValue === null || lodash_1.default.isEmpty(attributeValue)) {
28
29
  return true;
29
30
  }
30
31
  const bindingNodeId = $(`#${attributeValue.replaceAll(".", "\\.")}`).text();
@@ -32,3 +33,64 @@ class EmptyElementWithIdSpecification {
32
33
  }
33
34
  }
34
35
  exports.EmptyElementWithIdSpecification = EmptyElementWithIdSpecification;
36
+ class NotUniqueIdAttributeSpecification {
37
+ isSatisfiedBy(element, attributeName) {
38
+ if (lodash_1.default.isNull(element.id) || lodash_1.default.isEmpty(element.id)) {
39
+ return true;
40
+ }
41
+ return $(`[id=${element.id}]`).length > 1;
42
+ }
43
+ }
44
+ exports.NotUniqueIdAttributeSpecification = NotUniqueIdAttributeSpecification;
45
+ class NotEqualsAttributeSpecification {
46
+ expectedValueList;
47
+ constructor(expectedValueList) {
48
+ this.expectedValueList = expectedValueList;
49
+ }
50
+ isSatisfiedBy(element, attributeName) {
51
+ const attributeValue = element.getAttribute(attributeName);
52
+ if (attributeValue === null) {
53
+ return true;
54
+ }
55
+ return !this.expectedValueList.includes(attributeValue);
56
+ }
57
+ }
58
+ exports.NotEqualsAttributeSpecification = NotEqualsAttributeSpecification;
59
+ class EqualsAttributeSpecification {
60
+ expectedValueList;
61
+ constructor(expectedValueList) {
62
+ this.expectedValueList = expectedValueList;
63
+ }
64
+ isSatisfiedBy(element, attributeName) {
65
+ const attributeValue = element.getAttribute(attributeName);
66
+ if (attributeValue === null) {
67
+ return false;
68
+ }
69
+ return this.expectedValueList.includes(attributeValue);
70
+ }
71
+ }
72
+ exports.EqualsAttributeSpecification = EqualsAttributeSpecification;
73
+ class AccessibleNameNotContainsVisibleTextSpecification {
74
+ isSatisfiedBy(element, attributeName) {
75
+ const visibleText = element.textContent;
76
+ if (visibleText === null || lodash_1.default.isEmpty(visibleText)) {
77
+ return false;
78
+ }
79
+ const accessibleName = (0, dom_accessibility_api_1.computeAccessibleName)(element);
80
+ console.debug("visibleText", visibleText, "accessibleName", accessibleName);
81
+ return accessibleName?.toLowerCase().indexOf(visibleText.toLowerCase()) === -1;
82
+ }
83
+ }
84
+ exports.AccessibleNameNotContainsVisibleTextSpecification = AccessibleNameNotContainsVisibleTextSpecification;
85
+ class EmptyInnerTextSpecification {
86
+ isSatisfiedBy(element, attributeName) {
87
+ return lodash_1.default.isEmpty(element.textContent);
88
+ }
89
+ }
90
+ exports.EmptyInnerTextSpecification = EmptyInnerTextSpecification;
91
+ class NotEmptyInnerTextSpecification {
92
+ isSatisfiedBy(element, attributeName) {
93
+ return !lodash_1.default.isEmpty(element.textContent);
94
+ }
95
+ }
96
+ exports.NotEmptyInnerTextSpecification = NotEmptyInnerTextSpecification;
@@ -20,4 +20,28 @@ export declare class AttributeChecker {
20
20
  * @param attributeName : HTMLElement attribute name
21
21
  */
22
22
  static emptyHtmlNodeTargetedByTheAttribute(attributeName: string): CompliantSpecification;
23
+ /**
24
+ * Check that id attribute is not unique in current page
25
+ */
26
+ static notUniqueId(): CompliantSpecification;
27
+ /**
28
+ * Check that html element does not have the expected value
29
+ */
30
+ static notEquals(attributeName: string, expectedValueList: string[]): CompliantSpecification;
31
+ /**
32
+ * Check that html element have the expected value
33
+ */
34
+ static equals(attributeName: string, expectedValueList: string[]): CompliantSpecification;
35
+ /**
36
+ * Check that html element accessible name contains visible text ignoring case
37
+ */
38
+ static accessibleNameNotContainsVisibleText(): CompliantSpecification;
39
+ /**
40
+ * Check that html element have empty text
41
+ */
42
+ static emptyText(): CompliantSpecification;
43
+ /**
44
+ * Check that html element have not empty text
45
+ */
46
+ static notEmptyText(): CompliantSpecification;
23
47
  }
@@ -33,5 +33,41 @@ class AttributeChecker {
33
33
  static emptyHtmlNodeTargetedByTheAttribute(attributeName) {
34
34
  return new CompliantSpecification(attributeName, new attribut_specification_1.EmptyElementWithIdSpecification());
35
35
  }
36
+ /**
37
+ * Check that id attribute is not unique in current page
38
+ */
39
+ static notUniqueId() {
40
+ return new CompliantSpecification("id", new attribut_specification_1.NotUniqueIdAttributeSpecification());
41
+ }
42
+ /**
43
+ * Check that html element does not have the expected value
44
+ */
45
+ static notEquals(attributeName, expectedValueList) {
46
+ return new CompliantSpecification(attributeName, new attribut_specification_1.NotEqualsAttributeSpecification(expectedValueList));
47
+ }
48
+ /**
49
+ * Check that html element have the expected value
50
+ */
51
+ static equals(attributeName, expectedValueList) {
52
+ return new CompliantSpecification(attributeName, new attribut_specification_1.EqualsAttributeSpecification(expectedValueList));
53
+ }
54
+ /**
55
+ * Check that html element accessible name contains visible text ignoring case
56
+ */
57
+ static accessibleNameNotContainsVisibleText() {
58
+ return new CompliantSpecification("accessibleName", new attribut_specification_1.AccessibleNameNotContainsVisibleTextSpecification());
59
+ }
60
+ /**
61
+ * Check that html element have empty text
62
+ */
63
+ static emptyText() {
64
+ return new CompliantSpecification("text", new attribut_specification_1.EmptyInnerTextSpecification());
65
+ }
66
+ /**
67
+ * Check that html element have not empty text
68
+ */
69
+ static notEmptyText() {
70
+ return new CompliantSpecification("text", new attribut_specification_1.NotEmptyInnerTextSpecification());
71
+ }
36
72
  }
37
73
  exports.AttributeChecker = AttributeChecker;
@@ -1 +1,2 @@
1
1
  export * from "./rgaa";
2
+ export * from "./wcag";
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // export * from './alix';
18
18
  __exportStar(require("./rgaa"), exports);
19
+ __exportStar(require("./wcag"), exports);