@sa11y/jest 6.6.2 → 6.7.1-alpha.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.
@@ -1 +1 @@
1
- {"version":3,"file":"groupViolationResultsProcessor.d.ts","sourceRoot":"","sources":["../src/groupViolationResultsProcessor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAA+B,MAAM,mBAAmB,CAAC;AAsHlF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAapF"}
1
+ {"version":3,"file":"groupViolationResultsProcessor.d.ts","sourceRoot":"","sources":["../src/groupViolationResultsProcessor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAA+B,MAAM,mBAAmB,CAAC;AA0JlF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAapF"}
@@ -2,15 +2,45 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const common_1 = require("@sa11y/common");
4
4
  const format_1 = require("@sa11y/format");
5
+ const formatSpacing = ' '.repeat(2);
6
+ const formatForError = ' '.repeat(4);
7
+ const axeMessages = {
8
+ toSolveAny: `\n${formatForError}- More Info: To solve the problem, you need to fix at least (1) of the following:\n`,
9
+ toSolveFirst: `\n${formatForError}- More Info: To solve the problem, you need to fix one of the following:\n`,
10
+ toSolveSecond: `\n${formatForError}- And fix the following:\n`,
11
+ };
5
12
  /**
6
13
  * Create a test failure html elements array grouped by rule violation
7
14
  */
8
15
  function createA11yErrorElements(errorElements) {
9
16
  const a11yErrorElements = [];
10
17
  errorElements.forEach((errorElement, index) => {
11
- a11yErrorElements.push(`- (${index + 1}) HTML element : ${errorElement.html.replace(/&lt;/g, '<').replace(/&gt;/, '>')}
12
- - CSS selector(s) : ${errorElement.selectors.replace(/&gt;/, '>')}
13
- - HTML Tag Hierarchy : ${errorElement.hierarchy}`);
18
+ let errorMessage = `${formatForError}(${index + 1}) - HTML element : ${errorElement.html
19
+ .replace(/&lt;/g, '<')
20
+ .replace(/&gt;/, '>')}
21
+ ${formatForError}- CSS selector(s) : ${errorElement.selectors.replace(/&gt;/, '>')}
22
+ ${formatForError}- HTML Tag Hierarchy : ${errorElement.hierarchy}`;
23
+ if (errorElement.any && errorElement.any.length > 0) {
24
+ errorMessage += `${axeMessages.toSolveAny}${errorElement.any}`;
25
+ if (errorElement.all && errorElement.all.length > 0) {
26
+ errorMessage += `${axeMessages.toSolveSecond}${errorElement.all}`;
27
+ }
28
+ if (errorElement.none && errorElement.none.length > 0) {
29
+ errorMessage += `${axeMessages.toSolveSecond}${errorElement.none}`;
30
+ }
31
+ }
32
+ else if (errorElement.all && errorElement.all.length > 0) {
33
+ errorMessage += `${axeMessages.toSolveFirst}${errorElement.all}`;
34
+ if (errorElement.none && errorElement.none.length > 0) {
35
+ errorMessage += `${axeMessages.toSolveSecond}${errorElement.none}`;
36
+ }
37
+ }
38
+ else {
39
+ if (errorElement.none && errorElement.none.length > 0) {
40
+ errorMessage += `${axeMessages.toSolveFirst}${errorElement.none}`;
41
+ }
42
+ }
43
+ a11yErrorElements.push(errorMessage);
14
44
  });
15
45
  return a11yErrorElements.join('\n');
16
46
  }
@@ -19,11 +49,11 @@ function createA11yErrorElements(errorElements) {
19
49
  */
20
50
  function createA11yRuleViolation(a11yRule, ruleIndex) {
21
51
  return `(${ruleIndex}) [${a11yRule.id}] ${a11yRule.description}
22
- * Help URL: ${a11yRule.helpUrl}
23
- * WCAG Criteria: ${a11yRule.wcagCriteria}
24
- * More info: ${a11yRule.summary}
25
- * Error element(s) : ${a11yRule.errorElements.length}
26
- ${createA11yErrorElements(a11yRule.errorElements)}`;
52
+ ${formatSpacing}* Error element(s) : ${a11yRule.errorElements.length}
53
+ \n${createA11yErrorElements(a11yRule.errorElements)}
54
+ ${formatSpacing}* Help:
55
+ ${formatSpacing}${formatSpacing}• Help URL: ${a11yRule.helpUrl}
56
+ ${formatSpacing}${formatSpacing}• WCAG Criteria: ${a11yRule.wcagCriteria}`;
27
57
  }
28
58
  /**
29
59
  * Convert any a11y errors from test failures into their own test suite, results
@@ -62,7 +92,10 @@ function processA11yErrors(results, testSuite, testResult) {
62
92
  a11yRuleViolations[a11yResult.wcag].errorElements.push({
63
93
  html: a11yResult.html,
64
94
  selectors: a11yResult.selectors,
65
- hierarchy: a11yResult.key,
95
+ hierarchy: a11yResult.ancestry,
96
+ any: a11yResult.any,
97
+ all: a11yResult.all,
98
+ none: a11yResult.none,
66
99
  });
67
100
  });
68
101
  const a11yFailureMessage = `
@@ -72,6 +105,8 @@ function processA11yErrors(results, testSuite, testResult) {
72
105
  ${Object.values(a11yRuleViolations)
73
106
  .map((a11yRuleViolation, index) => createA11yRuleViolation(a11yRuleViolation, index + 1))
74
107
  .join('\n')}
108
+
109
+
75
110
  For more info about automated accessibility testing: https://sfdc.co/a11y-test
76
111
  For tips on fixing accessibility bugs: https://sfdc.co/a11y
77
112
  For technical questions regarding Salesforce accessibility tools, contact our Sa11y team: http://sfdc.co/sa11y-users
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sa11y/jest",
3
- "version": "6.6.2",
3
+ "version": "6.7.1-alpha.1",
4
4
  "description": "Accessibility testing matcher for Jest",
5
5
  "license": "BSD-3-Clause",
6
6
  "homepage": "https://github.com/salesforce/sa11y/tree/master/packages/jest#readme",
@@ -24,9 +24,9 @@
24
24
  ],
25
25
  "dependencies": {
26
26
  "@jest/test-result": "^27",
27
- "@sa11y/assert": "6.6.2",
28
- "@sa11y/format": "6.6.2",
29
- "@sa11y/preset-rules": "6.6.2",
27
+ "@sa11y/assert": "6.7.1-alpha.1",
28
+ "@sa11y/format": "6.7.1-alpha.1",
29
+ "@sa11y/preset-rules": "6.7.1-alpha.1",
30
30
  "jest-matcher-utils": "^27"
31
31
  },
32
32
  "peerDependencies": {
@@ -34,8 +34,8 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@jest/globals": "28.1.3",
37
- "@sa11y/common": "6.6.2",
38
- "@sa11y/test-utils": "6.6.2"
37
+ "@sa11y/common": "6.7.1-alpha.1",
38
+ "@sa11y/test-utils": "6.7.1-alpha.1"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -43,5 +43,5 @@
43
43
  "engines": {
44
44
  "node": "^16 || ^18"
45
45
  },
46
- "gitHead": "03c66b2df14c3d80601e50e911a3eb40e8b5cbcd"
46
+ "gitHead": "42a62e360fcd24a0d072a24d6d18a64a41b9fd92"
47
47
  }