testaro 12.1.1 → 12.2.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.
package/actSpecs.js CHANGED
@@ -308,6 +308,7 @@ exports.actSpecs = {
308
308
  qualWeb: [
309
309
  'Perform a qualWeb test',
310
310
  {
311
+ withNewContent: [true, 'boolean', '', 'whether to use a URL instead of page content'],
311
312
  rules: [false, 'array', 'areStrings', 'QualWeb or ACT IDs of ACT rules to include, if not all']
312
313
  }
313
314
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "12.1.1",
3
+ "version": "12.2.0",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/tests/qualWeb.js CHANGED
@@ -5,21 +5,18 @@
5
5
  // IMPORTS
6
6
  const {QualWeb} = require('@qualweb/core');
7
7
  // CONSTANTS
8
- const qualweb = new QualWeb({});
8
+ const qualWeb = new QualWeb({});
9
9
  const clusterOptions = {
10
10
  timeout: 25 * 1000
11
11
  };
12
12
  // FUNCTIONS
13
13
  // Conducts and reports a QualWeb test.
14
- exports.reporter = async (page, rules = null) => {
14
+ exports.reporter = async (page, withNewContent, rules = null) => {
15
15
  // Initialize the report.
16
- let data = {};
17
16
  // Start the QualWeb core engine.
18
- await qualweb.start(clusterOptions);
17
+ await qualWeb.start(clusterOptions);
19
18
  // Specify the page.
20
- const html = await page.content();
21
- const qualwebOptions = {
22
- html,
19
+ const qualWebOptions = {
23
20
  log: {
24
21
  console: true
25
22
  },
@@ -41,24 +38,33 @@ exports.reporter = async (page, rules = null) => {
41
38
  exclude: []
42
39
  }
43
40
  };
41
+ if (withNewContent) {
42
+ qualWebOptions.url = page.url();
43
+ }
44
+ else {
45
+ qualWebOptions.html = await page.content();
46
+ }
44
47
  if (rules) {
45
- qualwebOptions['act-rules'].rules = rules;
48
+ qualWebOptions['act-rules'].rules = rules;
46
49
  }
47
50
  else {
48
- qualwebOptions['act-rules'].levels = ['A', 'AA', 'AAA'];
49
- qualwebOptions['act-rules'].principles = [
51
+ qualWebOptions['act-rules'].levels = ['A', 'AA', 'AAA'];
52
+ qualWebOptions['act-rules'].principles = [
50
53
  'Perceivable', 'Operable', 'Understandable', 'Robust'
51
54
  ];
52
55
  }
53
56
  // Get the report.
54
- const reports = await qualweb.evaluate(qualwebOptions);
55
- // Prepare to trim its ACT rules and WCAG Techniques section.
56
- delete reports.customHtml.system.page.dom;
57
+ let reports = await qualWeb.evaluate(qualWebOptions);
58
+ // Remove the copy of the DOM from it.
59
+ let report = reports[withNewContent ? qualWebOptions.url : 'customHtml'];
60
+ delete report.system.page.dom;
61
+ // For each section of the report:
57
62
  ['act-rules', 'wcag-techniques', 'best-practices'].forEach(module => {
58
- const {assertions} = reports.customHtml.modules[module];
63
+ // For each test:
64
+ const {assertions} = report.modules[module];
59
65
  const ruleIDs = Object.keys(assertions);
60
66
  ruleIDs.forEach(ruleID => {
61
- // Remove passing customHtml results.
67
+ // Remove passing results.
62
68
  const ruleAssertions = assertions[ruleID];
63
69
  const {metadata} = ruleAssertions;
64
70
  if (metadata) {
@@ -88,17 +94,17 @@ exports.reporter = async (page, rules = null) => {
88
94
  });
89
95
  });
90
96
  // Stop the QualWeb core engine.
91
- await qualweb.stop();
97
+ await qualWeb.stop();
92
98
  // Return the result.
93
99
  try {
94
- JSON.stringify(data);
100
+ JSON.stringify(reports);
95
101
  }
96
102
  catch(error) {
97
103
  console.log(`ERROR: qualWeb result cannot be made JSON (${error.message})`);
98
- data = {
104
+ report = {
99
105
  prevented: true,
100
106
  error: `ERROR: qualWeb result cannot be made JSON (${error.message})`
101
107
  };
102
108
  }
103
- return {result: reports};
109
+ return {result: report};
104
110
  };