@uuv/a11y 0.0.1 → 1.0.0-beta.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +1 -1
  3. package/bundle/uuv-a11y.bundle.js +1 -1
  4. package/dist/README.md +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +17 -17
  7. package/dist/lib/engine/engine.d.ts +12 -12
  8. package/dist/lib/engine/engine.js +123 -123
  9. package/dist/lib/index.d.ts +3 -3
  10. package/dist/lib/index.js +19 -19
  11. package/dist/lib/model/checker.d.ts +14 -14
  12. package/dist/lib/model/checker.js +35 -35
  13. package/dist/lib/model/index.d.ts +4 -4
  14. package/dist/lib/model/index.js +20 -20
  15. package/dist/lib/model/reference.d.ts +55 -55
  16. package/dist/lib/model/reference.js +66 -66
  17. package/dist/lib/model/result.d.ts +57 -57
  18. package/dist/lib/model/result.js +144 -144
  19. package/dist/lib/model/rule.d.ts +99 -99
  20. package/dist/lib/model/rule.js +53 -53
  21. package/dist/lib/query/00-query.d.ts +4 -4
  22. package/dist/lib/query/00-query.js +2 -2
  23. package/dist/lib/query/accessible-name.query.d.ts +8 -8
  24. package/dist/lib/query/accessible-name.query.js +34 -34
  25. package/dist/lib/query/by-role.query.d.ts +8 -8
  26. package/dist/lib/query/by-role.query.js +27 -27
  27. package/dist/lib/query/by-tag.query.d.ts +7 -7
  28. package/dist/lib/query/by-tag.query.js +20 -20
  29. package/dist/lib/query/doctype.query.d.ts +5 -5
  30. package/dist/lib/query/doctype.query.js +15 -15
  31. package/dist/lib/query/form.query.d.ts +8 -8
  32. package/dist/lib/query/form.query.js +87 -87
  33. package/dist/lib/query/index.d.ts +6 -6
  34. package/dist/lib/query/index.js +22 -22
  35. package/dist/lib/reference/alix/alix-checker.js +82 -82
  36. package/dist/lib/reference/alix/alix-rules.js +1028 -1028
  37. package/dist/lib/reference/alix/index.js +3 -3
  38. package/dist/lib/reference/index.d.ts +1 -1
  39. package/dist/lib/reference/index.js +18 -18
  40. package/dist/lib/reference/rgaa/common.d.ts +2 -2
  41. package/dist/lib/reference/rgaa/common.js +5 -5
  42. package/dist/lib/reference/rgaa/coverage/coverage-helper.d.ts +2 -2
  43. package/dist/lib/reference/rgaa/coverage/coverage-helper.js +100 -100
  44. package/dist/lib/reference/rgaa/coverage/coverage-statement.json +90 -90
  45. package/dist/lib/reference/rgaa/index.d.ts +2 -2
  46. package/dist/lib/reference/rgaa/index.js +18 -18
  47. package/dist/lib/reference/rgaa/rgaa-checker.d.ts +8 -8
  48. package/dist/lib/reference/rgaa/rgaa-checker.js +31 -31
  49. package/dist/lib/reference/rgaa/rgaa-reference.d.ts +2 -2
  50. package/dist/lib/reference/rgaa/rgaa-reference.js +44 -44
  51. package/dist/lib/reference/rgaa/rgaa_4.1.criteres.json +4144 -4144
  52. package/dist/lib/reference/rgaa/rules/1-image.d.ts +14 -14
  53. package/dist/lib/reference/rgaa/rules/1-image.js +644 -644
  54. package/dist/lib/reference/rgaa/rules/10-display.d.ts +2 -2
  55. package/dist/lib/reference/rgaa/rules/10-display.js +3 -3
  56. package/dist/lib/reference/rgaa/rules/11-form.d.ts +14 -14
  57. package/dist/lib/reference/rgaa/rules/11-form.js +16 -16
  58. package/dist/lib/reference/rgaa/rules/12-navigation.d.ts +2 -2
  59. package/dist/lib/reference/rgaa/rules/12-navigation.js +3 -3
  60. package/dist/lib/reference/rgaa/rules/13-visit.d.ts +2 -2
  61. package/dist/lib/reference/rgaa/rules/13-visit.js +3 -3
  62. package/dist/lib/reference/rgaa/rules/2-frame.d.ts +14 -14
  63. package/dist/lib/reference/rgaa/rules/2-frame.js +34 -34
  64. package/dist/lib/reference/rgaa/rules/3-color.d.ts +14 -14
  65. package/dist/lib/reference/rgaa/rules/3-color.js +50 -50
  66. package/dist/lib/reference/rgaa/rules/4-multimedia.d.ts +2 -2
  67. package/dist/lib/reference/rgaa/rules/4-multimedia.js +3 -3
  68. package/dist/lib/reference/rgaa/rules/5-table.d.ts +2 -2
  69. package/dist/lib/reference/rgaa/rules/5-table.js +3 -3
  70. package/dist/lib/reference/rgaa/rules/6-link.d.ts +2 -2
  71. package/dist/lib/reference/rgaa/rules/6-link.js +3 -3
  72. package/dist/lib/reference/rgaa/rules/7-script.d.ts +2 -2
  73. package/dist/lib/reference/rgaa/rules/7-script.js +3 -3
  74. package/dist/lib/reference/rgaa/rules/8-required-element.d.ts +14 -14
  75. package/dist/lib/reference/rgaa/rules/8-required-element.js +78 -78
  76. package/dist/lib/reference/rgaa/rules/9-structure.d.ts +2 -2
  77. package/dist/lib/reference/rgaa/rules/9-structure.js +3 -3
  78. package/dist/lib/reference/rgaa/selector-helper.d.ts +17 -17
  79. package/dist/lib/reference/rgaa/selector-helper.js +33 -33
  80. package/dist/package.json +1 -0
  81. package/docs/diagram-a11y-rgaa.excalidraw +1654 -0
  82. package/docs/diagram-a11y-rgaa.png +0 -0
  83. package/package.json +2 -1
@@ -1,66 +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;
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;
@@ -1,57 +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
- }
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
+ }
@@ -1,144 +1,144 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A11yResult = exports.A11yRuleResult = exports.A11yRuleValidationResult = exports.A11yResultStatus = void 0;
4
- var A11yResultStatus;
5
- (function (A11yResultStatus) {
6
- A11yResultStatus["UNKNOWN"] = "unknown";
7
- A11yResultStatus["SUCCESS"] = "success";
8
- A11yResultStatus["MANUAL"] = "manual";
9
- A11yResultStatus["ERROR"] = "error";
10
- })(A11yResultStatus = exports.A11yResultStatus || (exports.A11yResultStatus = {}));
11
- class A11yRuleValidationResult {
12
- criteria;
13
- status = A11yResultStatus.UNKNOWN;
14
- errorNodes = [];
15
- nodesToCheckManually = [];
16
- constructor(criteria) {
17
- this.criteria = criteria;
18
- }
19
- }
20
- exports.A11yRuleValidationResult = A11yRuleValidationResult;
21
- class A11yRuleResult {
22
- url;
23
- rule;
24
- status = A11yResultStatus.UNKNOWN;
25
- validations = [];
26
- constructor(url, rule) {
27
- this.url = url;
28
- this.rule = rule;
29
- }
30
- getOrAddValidation(criteria) {
31
- let validation = this.validations.find(value => value.criteria === criteria);
32
- if (!validation) {
33
- validation = new A11yRuleValidationResult(criteria);
34
- this.validations.push(validation);
35
- }
36
- return validation;
37
- }
38
- getErrorNodes() {
39
- let nodeFound = [];
40
- this.validations.forEach(validation => {
41
- nodeFound = nodeFound.concat(validation.errorNodes);
42
- });
43
- return nodeFound;
44
- }
45
- getNodesToCheckManually() {
46
- let nodeFound = [];
47
- this.validations.forEach(validation => {
48
- nodeFound = nodeFound.concat(validation.nodesToCheckManually);
49
- });
50
- return nodeFound;
51
- }
52
- computeStatus() {
53
- this.status = this.getStatus();
54
- }
55
- getStatus() {
56
- if (this.validations.find(validation => validation.status === A11yResultStatus.UNKNOWN)) {
57
- return A11yResultStatus.UNKNOWN;
58
- }
59
- if (this.validations.find(validation => validation.status === A11yResultStatus.ERROR)) {
60
- return A11yResultStatus.ERROR;
61
- }
62
- if (this.validations.find(validation => validation.status === A11yResultStatus.MANUAL)) {
63
- return A11yResultStatus.MANUAL;
64
- }
65
- return A11yResultStatus.SUCCESS;
66
- }
67
- }
68
- exports.A11yRuleResult = A11yRuleResult;
69
- class A11yResult {
70
- url;
71
- reference;
72
- status = A11yResultStatus.UNKNOWN;
73
- ruleResults = [];
74
- constructor(url, reference) {
75
- this.url = url;
76
- this.reference = reference;
77
- }
78
- computeStatus() {
79
- this.status = computeStatus(this.ruleResults);
80
- }
81
- summary() {
82
- const summary = {
83
- status: this.status,
84
- criteria: {}
85
- };
86
- this.groupRuleResultByCriterion().forEach((rulesResult, key) => {
87
- summary.criteria[key] = this.buildSummaryForCriterion(key, rulesResult);
88
- });
89
- return summary;
90
- }
91
- buildSummaryForCriterion(criterion, criterionRulesResult) {
92
- const criterionSummary = {
93
- status: computeStatus(criterionRulesResult),
94
- tests: {}
95
- };
96
- this.groupRuleResultByTestOfACriterion(criterion).forEach((rulesResult, key) => {
97
- criterionSummary.tests[key] = {
98
- status: computeStatus(rulesResult)
99
- };
100
- });
101
- return criterionSummary;
102
- }
103
- getPosition(inputString, subString, index) {
104
- return inputString.split(subString, index).join(subString).length;
105
- }
106
- groupRuleResultByLevel(ruleResults, level) {
107
- const ruleResultPerCriteria = new Map();
108
- ruleResults.forEach(ruleResult => {
109
- const key = this.getKeyOfLevel(ruleResult, level);
110
- if (!ruleResultPerCriteria.has(key)) {
111
- ruleResultPerCriteria.set(key, []);
112
- }
113
- ruleResultPerCriteria.get(key)?.push(ruleResult);
114
- });
115
- return ruleResultPerCriteria;
116
- }
117
- getKeyOfLevel(ruleResult, level) {
118
- const nextLevelPosition = this.getPosition(ruleResult.rule.id, ".", level + 1);
119
- return ruleResult.rule.id.substring(0, nextLevelPosition > 0 ? nextLevelPosition : undefined);
120
- }
121
- groupRuleResultByCriterion() {
122
- return this.groupRuleResultByLevel(this.ruleResults, 1);
123
- }
124
- groupRuleResultByTestOfACriterion(criterion) {
125
- return this.groupRuleResultByLevel(this.ruleResults.filter(ruleResult => criterion === this.getKeyOfLevel(ruleResult, 1)), 2);
126
- }
127
- }
128
- exports.A11yResult = A11yResult;
129
- const computeStatus = (ruleResults) => {
130
- ruleResults.forEach(ruleResult => ruleResult.computeStatus());
131
- return getStatus(ruleResults);
132
- };
133
- const getStatus = (ruleResults) => {
134
- if (ruleResults.find(ruleResult => ruleResult.status === A11yResultStatus.UNKNOWN)) {
135
- return A11yResultStatus.UNKNOWN;
136
- }
137
- if (ruleResults.find(ruleResult => ruleResult.status === A11yResultStatus.ERROR)) {
138
- return A11yResultStatus.ERROR;
139
- }
140
- if (ruleResults.find(ruleResult => ruleResult.status === A11yResultStatus.MANUAL)) {
141
- return A11yResultStatus.MANUAL;
142
- }
143
- return A11yResultStatus.SUCCESS;
144
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.A11yResult = exports.A11yRuleResult = exports.A11yRuleValidationResult = exports.A11yResultStatus = void 0;
4
+ var A11yResultStatus;
5
+ (function (A11yResultStatus) {
6
+ A11yResultStatus["UNKNOWN"] = "unknown";
7
+ A11yResultStatus["SUCCESS"] = "success";
8
+ A11yResultStatus["MANUAL"] = "manual";
9
+ A11yResultStatus["ERROR"] = "error";
10
+ })(A11yResultStatus = exports.A11yResultStatus || (exports.A11yResultStatus = {}));
11
+ class A11yRuleValidationResult {
12
+ criteria;
13
+ status = A11yResultStatus.UNKNOWN;
14
+ errorNodes = [];
15
+ nodesToCheckManually = [];
16
+ constructor(criteria) {
17
+ this.criteria = criteria;
18
+ }
19
+ }
20
+ exports.A11yRuleValidationResult = A11yRuleValidationResult;
21
+ class A11yRuleResult {
22
+ url;
23
+ rule;
24
+ status = A11yResultStatus.UNKNOWN;
25
+ validations = [];
26
+ constructor(url, rule) {
27
+ this.url = url;
28
+ this.rule = rule;
29
+ }
30
+ getOrAddValidation(criteria) {
31
+ let validation = this.validations.find(value => value.criteria === criteria);
32
+ if (!validation) {
33
+ validation = new A11yRuleValidationResult(criteria);
34
+ this.validations.push(validation);
35
+ }
36
+ return validation;
37
+ }
38
+ getErrorNodes() {
39
+ let nodeFound = [];
40
+ this.validations.forEach(validation => {
41
+ nodeFound = nodeFound.concat(validation.errorNodes);
42
+ });
43
+ return nodeFound;
44
+ }
45
+ getNodesToCheckManually() {
46
+ let nodeFound = [];
47
+ this.validations.forEach(validation => {
48
+ nodeFound = nodeFound.concat(validation.nodesToCheckManually);
49
+ });
50
+ return nodeFound;
51
+ }
52
+ computeStatus() {
53
+ this.status = this.getStatus();
54
+ }
55
+ getStatus() {
56
+ if (this.validations.find(validation => validation.status === A11yResultStatus.UNKNOWN)) {
57
+ return A11yResultStatus.UNKNOWN;
58
+ }
59
+ if (this.validations.find(validation => validation.status === A11yResultStatus.ERROR)) {
60
+ return A11yResultStatus.ERROR;
61
+ }
62
+ if (this.validations.find(validation => validation.status === A11yResultStatus.MANUAL)) {
63
+ return A11yResultStatus.MANUAL;
64
+ }
65
+ return A11yResultStatus.SUCCESS;
66
+ }
67
+ }
68
+ exports.A11yRuleResult = A11yRuleResult;
69
+ class A11yResult {
70
+ url;
71
+ reference;
72
+ status = A11yResultStatus.UNKNOWN;
73
+ ruleResults = [];
74
+ constructor(url, reference) {
75
+ this.url = url;
76
+ this.reference = reference;
77
+ }
78
+ computeStatus() {
79
+ this.status = computeStatus(this.ruleResults);
80
+ }
81
+ summary() {
82
+ const summary = {
83
+ status: this.status,
84
+ criteria: {}
85
+ };
86
+ this.groupRuleResultByCriterion().forEach((rulesResult, key) => {
87
+ summary.criteria[key] = this.buildSummaryForCriterion(key, rulesResult);
88
+ });
89
+ return summary;
90
+ }
91
+ buildSummaryForCriterion(criterion, criterionRulesResult) {
92
+ const criterionSummary = {
93
+ status: computeStatus(criterionRulesResult),
94
+ tests: {}
95
+ };
96
+ this.groupRuleResultByTestOfACriterion(criterion).forEach((rulesResult, key) => {
97
+ criterionSummary.tests[key] = {
98
+ status: computeStatus(rulesResult)
99
+ };
100
+ });
101
+ return criterionSummary;
102
+ }
103
+ getPosition(inputString, subString, index) {
104
+ return inputString.split(subString, index).join(subString).length;
105
+ }
106
+ groupRuleResultByLevel(ruleResults, level) {
107
+ const ruleResultPerCriteria = new Map();
108
+ ruleResults.forEach(ruleResult => {
109
+ const key = this.getKeyOfLevel(ruleResult, level);
110
+ if (!ruleResultPerCriteria.has(key)) {
111
+ ruleResultPerCriteria.set(key, []);
112
+ }
113
+ ruleResultPerCriteria.get(key)?.push(ruleResult);
114
+ });
115
+ return ruleResultPerCriteria;
116
+ }
117
+ getKeyOfLevel(ruleResult, level) {
118
+ const nextLevelPosition = this.getPosition(ruleResult.rule.id, ".", level + 1);
119
+ return ruleResult.rule.id.substring(0, nextLevelPosition > 0 ? nextLevelPosition : undefined);
120
+ }
121
+ groupRuleResultByCriterion() {
122
+ return this.groupRuleResultByLevel(this.ruleResults, 1);
123
+ }
124
+ groupRuleResultByTestOfACriterion(criterion) {
125
+ return this.groupRuleResultByLevel(this.ruleResults.filter(ruleResult => criterion === this.getKeyOfLevel(ruleResult, 1)), 2);
126
+ }
127
+ }
128
+ exports.A11yResult = A11yResult;
129
+ const computeStatus = (ruleResults) => {
130
+ ruleResults.forEach(ruleResult => ruleResult.computeStatus());
131
+ return getStatus(ruleResults);
132
+ };
133
+ const getStatus = (ruleResults) => {
134
+ if (ruleResults.find(ruleResult => ruleResult.status === A11yResultStatus.UNKNOWN)) {
135
+ return A11yResultStatus.UNKNOWN;
136
+ }
137
+ if (ruleResults.find(ruleResult => ruleResult.status === A11yResultStatus.ERROR)) {
138
+ return A11yResultStatus.ERROR;
139
+ }
140
+ if (ruleResults.find(ruleResult => ruleResult.status === A11yResultStatus.MANUAL)) {
141
+ return A11yResultStatus.MANUAL;
142
+ }
143
+ return A11yResultStatus.SUCCESS;
144
+ };