@sa11y/jest 6.9.5-alpha.4 → 6.10.0

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":"automatic.d.ts","sourceRoot":"","sources":["../src/automatic.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAI7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAgBF,eAAO,MAAM,2BAA2B,aAAc,MAAM,GAAG,IAAI,SAElE,CAAC;AAEF,eAAO,MAAM,2BAA2B,qBAEvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAUtF;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,aAAoC,GAAG,OAAO,CAAC,IAAI,CAAC,CAwF9F;AAsBD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,aAAoC,GAAG,IAAI,CAmB7F"}
1
+ {"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../src/automatic.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAI7B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACpC,CAAC;AAiBF,eAAO,MAAM,2BAA2B,aAAc,MAAM,GAAG,IAAI,SAElE,CAAC;AAEF,eAAO,MAAM,2BAA2B,qBAEvC,CAAC;AAEF;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAUtF;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,GAAE,aAAoC,GAAG,OAAO,CAAC,IAAI,CAAC,CAiF9F;AAsBD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,GAAE,aAAoC,GAAG,IAAI,CAmB7F"}
package/dist/automatic.js CHANGED
@@ -22,6 +22,7 @@ const defaultAutoCheckOpts = {
22
22
  cleanupAfterEach: true,
23
23
  consolidateResults: true,
24
24
  filesFilter: [],
25
+ runDOMMutationObserver: false,
25
26
  };
26
27
  let originalDocumentBodyHtml = null;
27
28
  let mutatedNodes = [];
@@ -66,7 +67,7 @@ async function automaticCheck(opts = defaultAutoCheckOpts) {
66
67
  // Create a DOM walker filtering only elements (skipping text, comment nodes etc)
67
68
  const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT);
68
69
  let currNode = walker.firstChild();
69
- let customRules = (0, common_1.useCustomRules)();
70
+ const customRules = (0, common_1.useCustomRules)();
70
71
  try {
71
72
  if (!opts.runDOMMutationObserver) {
72
73
  while (currNode !== null) {
@@ -85,7 +86,6 @@ async function automaticCheck(opts = defaultAutoCheckOpts) {
85
86
  }
86
87
  }
87
88
  else {
88
- customRules = [];
89
89
  if (customRules.length === 0)
90
90
  violations.push(...(await (0, assert_1.getViolationsJSDOM)(document.body, (0, setup_1.adaptA11yConfig)(preset_rules_1.defaultRuleset))));
91
91
  else
@@ -95,16 +95,10 @@ async function automaticCheck(opts = defaultAutoCheckOpts) {
95
95
  for await (const mutatedNode of mutatedNodes) {
96
96
  if (mutatedNode) {
97
97
  document.body.innerHTML = mutatedNode;
98
- // remove walker
99
- // const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT);
100
- // let currNode = walker.firstChild();
101
- // while (currNode !== null) {
102
98
  if (customRules.length === 0)
103
99
  violations.push(...(await (0, assert_1.getViolationsJSDOM)(document.body, (0, setup_1.adaptA11yConfig)(preset_rules_1.defaultRuleset))));
104
100
  else
105
101
  violations.push(...(await (0, assert_1.getViolationsJSDOM)(document.body, (0, setup_1.adaptA11yConfigCustomRules)(preset_rules_1.defaultRuleset, customRules))));
106
- // currNode = walker.nextSibling();
107
- // }
108
102
  }
109
103
  }
110
104
  }
@@ -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;AAkLlF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAa5E;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAaxF"}
1
+ {"version":3,"file":"groupViolationResultsProcessor.d.ts","sourceRoot":"","sources":["../src/groupViolationResultsProcessor.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAA+B,MAAM,mBAAmB,CAAC;AA6MlF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAa5E;AAED,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,gBAAgB,GAAG,gBAAgB,CAaxF"}
@@ -3,44 +3,64 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resultsProcessorManualChecks = exports.resultsProcessor = void 0;
4
4
  const common_1 = require("@sa11y/common");
5
5
  const format_1 = require("@sa11y/format");
6
- const formatSpacing = '\t'.repeat(8);
7
- const formatForAxeMessage = `\n${formatSpacing}\t\t`;
6
+ const formatSpacing = '\t'.repeat(4);
7
+ const formatForAxeMessage = `\n${formatSpacing}\t`;
8
8
  const axeMessages = {
9
9
  toSolveAny: `${formatForAxeMessage}- More Info: To solve the problem, you need to fix at least (1) of the following:\n`,
10
10
  toSolveFirst: `${formatForAxeMessage}- More Info: To solve the problem, you need to fix one of the following:\n`,
11
11
  toSolveSecond: `${formatForAxeMessage}- And fix the following:\n`,
12
+ relatedNodes: `${formatForAxeMessage}- Related Nodes: \n`,
12
13
  };
13
14
  /**
14
15
  * Create a test failure html elements array grouped by rule violation
15
16
  */
16
17
  function createA11yErrorElements(errorElements) {
17
18
  const a11yErrorElements = [];
19
+ let onlyOneSummary = false;
20
+ const appendRelatedNodes = (errorMessage, relatedNodes) => {
21
+ return relatedNodes ? `${errorMessage}${axeMessages.relatedNodes}${relatedNodes}` : errorMessage;
22
+ };
18
23
  errorElements.forEach((errorElement, index) => {
19
- let errorMessage = `${formatSpacing}(${index + 1}) - HTML element : ${errorElement.html
24
+ let errorMessage = `${formatSpacing}(${index + 1}) - HTML element : ${errorElement.html
20
25
  .replace(/&lt;/g, '<')
21
- .replace(/&gt;/, '>')}
22
- - CSS selector(s) : ${errorElement.selectors.replace(/&gt;/, '>')}
23
- - HTML Tag Hierarchy : ${errorElement.hierarchy}`;
24
- if (errorElement.any && errorElement.any.length > 0) {
25
- errorMessage += `${axeMessages.toSolveAny}${errorElement.any}`;
26
- if (errorElement.all && errorElement.all.length > 0) {
27
- errorMessage += `${axeMessages.toSolveSecond}${errorElement.all}`;
26
+ .replace(/&gt;/, '>')}`;
27
+ errorMessage += `${formatForAxeMessage}- CSS selector(s) : ${errorElement.selectors.replace(/&gt;/, '>')}`;
28
+ errorMessage += `${formatForAxeMessage}- HTML Tag Hierarchy : ${errorElement.hierarchy}`;
29
+ const isAny = errorElement.any?.length > 0;
30
+ const isAll = errorElement.all?.length > 0;
31
+ const isNone = errorElement.none?.length > 0;
32
+ if (!onlyOneSummary) {
33
+ if (isAny) {
34
+ errorMessage += `${axeMessages.toSolveAny}${errorElement.any}`;
35
+ errorMessage = appendRelatedNodes(errorMessage, errorElement.relatedNodeAny);
36
+ if (isAll) {
37
+ errorMessage += `${axeMessages.toSolveSecond}${errorElement.all}`;
38
+ errorMessage = appendRelatedNodes(errorMessage, errorElement.relatedNodeAll);
39
+ }
40
+ if (isNone) {
41
+ errorMessage += `${axeMessages.toSolveSecond}${errorElement.none}`;
42
+ errorMessage = appendRelatedNodes(errorMessage, errorElement.relatedNodeNone);
43
+ }
28
44
  }
29
- if (errorElement.none && errorElement.none.length > 0) {
30
- errorMessage += `${axeMessages.toSolveSecond}${errorElement.none}`;
45
+ else if (isAll) {
46
+ errorMessage += `${axeMessages.toSolveFirst}${errorElement.all}`;
47
+ errorMessage = appendRelatedNodes(errorMessage, errorElement.relatedNodeAll);
48
+ if (isNone) {
49
+ errorMessage += `${axeMessages.toSolveSecond}${errorElement.none}`;
50
+ errorMessage = appendRelatedNodes(errorMessage, errorElement.relatedNodeNone);
51
+ }
31
52
  }
32
- }
33
- else if (errorElement.all && errorElement.all.length > 0) {
34
- errorMessage += `${axeMessages.toSolveFirst}${errorElement.all}`;
35
- if (errorElement.none && errorElement.none.length > 0) {
36
- errorMessage += `${axeMessages.toSolveSecond}${errorElement.none}`;
53
+ else {
54
+ if (isNone) {
55
+ errorMessage += `${axeMessages.toSolveFirst}${errorElement.none}`;
56
+ errorMessage = appendRelatedNodes(errorMessage, errorElement.relatedNodeNone);
57
+ }
37
58
  }
38
59
  }
39
60
  else {
40
- if (errorElement.none && errorElement.none.length > 0) {
41
- errorMessage += `${axeMessages.toSolveFirst}${errorElement.none}`;
42
- }
61
+ errorMessage = appendRelatedNodes(errorMessage, errorElement.relatedNodeAny);
43
62
  }
63
+ onlyOneSummary = isAny && !isAll && !isNone;
44
64
  a11yErrorElements.push(errorMessage);
45
65
  });
46
66
  return a11yErrorElements.join('\n');
@@ -83,21 +103,24 @@ function processA11yDetailsAndMessages(error, a11yFailureMessages) {
83
103
  any: a11yResult.any,
84
104
  all: a11yResult.all,
85
105
  none: a11yResult.none,
106
+ relatedNodeAny: a11yResult.relatedNodeAny,
107
+ relatedNodeAll: a11yResult.relatedNodeAll,
108
+ relatedNodeNone: a11yResult.relatedNodeNone,
86
109
  });
87
110
  });
88
111
  const a11yFailureMessage = `
89
- The test has failed the accessibility check. Accessibility Stacktrace/Issues:
90
- ${a11yErrorElementsCount} HTML elements have accessibility issue(s). ${a11yRuleViolationsCount} rules failed.
112
+ The test has failed the accessibility check. Accessibility Stacktrace/Issues:
113
+ ${a11yErrorElementsCount} HTML elements have accessibility issue(s). ${a11yRuleViolationsCount} rules failed.
91
114
 
92
- ${Object.values(a11yRuleViolations)
115
+ ${Object.values(a11yRuleViolations)
93
116
  .map((a11yRuleViolation, index) => createA11yRuleViolation(a11yRuleViolation, index + 1))
94
117
  .join('\n')}
95
118
 
96
-
97
- For more info about automated accessibility testing: https://sfdc.co/a11y-test
98
- For tips on fixing accessibility bugs: https://sfdc.co/a11y
99
- For technical questions regarding Salesforce accessibility tools, contact our Sa11y team: http://sfdc.co/sa11y-users
100
- For guidance on accessibility related specifics, contact our A11y team: http://sfdc.co/tmp-a11y
119
+
120
+ For more info about automated accessibility testing: https://sfdc.co/a11y-test
121
+ For tips on fixing accessibility bugs: https://sfdc.co/a11y
122
+ For technical questions regarding Salesforce accessibility tools, contact our Sa11y team: http://sfdc.co/sa11y-users
123
+ For guidance on accessibility related specifics, contact our A11y team: http://sfdc.co/tmp-a11y
101
124
  `;
102
125
  a11yFailureMessages.push(a11yFailureMessage);
103
126
  }
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAA6C,MAAM,eAAe,CAAC;AACtF,OAAO,EACH,aAAa,EAIhB,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,aAAa,UAiBzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB,aAAa,EAAE,aAAa,CAAC;CAKhC,CAAC;AAmCF;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,GAAE,SAA4B,GAAG,IAAI,CAkD9D;AACD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAU3C;AACD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,UAAU,CAKhG;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,WAAgB,GAAG,UAAU,CAM3F"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAA6C,MAAM,eAAe,CAAC;AACtF,OAAO,EACH,aAAa,EAIhB,MAAM,aAAa,CAAC;AAIrB,eAAO,MAAM,aAAa,UAiBzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB,aAAa,EAAE,aAAa,CAAC;CAKhC,CAAC;AAmCF;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,GAAE,SAA4B,GAAG,IAAI,CAgD9D;AACD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAU3C;AACD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,UAAU,CAKhG;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,WAAW,WAAgB,GAAG,UAAU,CAM3F"}
package/dist/setup.js CHANGED
@@ -104,9 +104,8 @@ function setup(opts = defaultSa11yOpts) {
104
104
  'ui-help-components/modules/forceHelp/searchResults/__tests__/searchResults.spec.js',
105
105
  'ui-help-components/modules/forceHelp/linkToKnownIssue/__tests__/linkToKnownIssue.spec.js',
106
106
  ]);
107
- // TODO: For testing purposes, using SA11Y_CUSTOM_RULES config
108
- // autoCheckOpts.runDOMMutationObserver ||= !!process.env.SA11Y_ENABLE_DOM_MUTATION_CHECKS;
109
- autoCheckOpts.runDOMMutationObserver || (autoCheckOpts.runDOMMutationObserver = !!process.env.SA11Y_CUSTOM_RULES);
107
+ // set the flag to true to run sa11y in DOM Mutation Observer mode
108
+ autoCheckOpts.runDOMMutationObserver || (autoCheckOpts.runDOMMutationObserver = !!process.env.SA11Y_ENABLE_DOM_MUTATION_OBSERVER);
110
109
  (0, automatic_1.registerSa11yAutomaticChecks)(autoCheckOpts);
111
110
  }
112
111
  exports.setup = setup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sa11y/jest",
3
- "version": "6.9.5-alpha.4",
3
+ "version": "6.10.0",
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.9.5-alpha.4",
28
- "@sa11y/format": "6.9.5-alpha.4",
29
- "@sa11y/preset-rules": "6.9.5-alpha.4",
27
+ "@sa11y/assert": "6.10.0",
28
+ "@sa11y/format": "6.10.0",
29
+ "@sa11y/preset-rules": "6.10.0",
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.9.5-alpha.4",
38
- "@sa11y/test-utils": "6.9.5-alpha.4"
37
+ "@sa11y/common": "6.10.0",
38
+ "@sa11y/test-utils": "6.10.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -43,5 +43,5 @@
43
43
  "engines": {
44
44
  "node": "^16 || ^18 || ^20"
45
45
  },
46
- "gitHead": "f76314d90c55041be24e945d6cd424f59a38c368"
46
+ "gitHead": "1f5d3dc24b26e096686cc22436998661705b490a"
47
47
  }