testaro 5.2.0 → 5.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "5.2.0",
3
+ "version": "5.3.0",
4
4
  "description": "Automation of accessibility testing",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/run.js CHANGED
@@ -633,6 +633,12 @@ const wait = ms => {
633
633
  };
634
634
  // Recursively performs the acts in a report.
635
635
  const doActs = async (report, actIndex, page) => {
636
+ process.on('message', message => {
637
+ if (message === 'interrupt') {
638
+ console.log('ERROR: Terminal interrupted doActs');
639
+ process.exit();
640
+ }
641
+ });
636
642
  const {acts} = report;
637
643
  // If any more commands are to be performed:
638
644
  if (actIndex > -1 && actIndex < acts.length) {
@@ -1310,8 +1316,7 @@ const doScript = async (report) => {
1310
1316
  const injectLaunches = acts => {
1311
1317
  let injectMore = true;
1312
1318
  while (injectMore) {
1313
- const injectIndex = acts.findIndex(
1314
- (act, index) =>
1319
+ const injectIndex = acts.findIndex((act, index) =>
1315
1320
  index < acts.length - 1
1316
1321
  && act.type === 'test'
1317
1322
  && acts[index + 1].type === 'test'
package/runHost.js ADDED
@@ -0,0 +1,36 @@
1
+ /*
2
+ runHost.js
3
+ Runs a host job and writes a report file.
4
+ */
5
+
6
+ // ########## IMPORTS
7
+
8
+ // Module to keep secrets.
9
+ require('dotenv').config();
10
+ // Module to read and write files.
11
+ const fs = require('fs/promises');
12
+ const {handleRequest} = require('./run');
13
+
14
+ // ########## CONSTANTS
15
+ const reportDir = process.env.REPORTDIR;
16
+
17
+ // ########## FUNCTIONS
18
+
19
+ // Runs one script and writes a report file.
20
+ const runHost = async (id, scriptJSON, hostJSON) => {
21
+ const report = {
22
+ id,
23
+ host: JSON.parse(hostJSON),
24
+ log: [],
25
+ script: JSON.parse(scriptJSON),
26
+ acts: []
27
+ };
28
+ await handleRequest(report);
29
+ const reportJSON = JSON.stringify(report, null, 2);
30
+ await fs.writeFile(`${reportDir}/${id}.json`, reportJSON);
31
+ process.disconnect();
32
+ process.exit();
33
+ };
34
+
35
+ // ########## OPERATION
36
+ runHost(... process.argv.slice(2));
package/tests/hover.js CHANGED
@@ -30,20 +30,7 @@
30
30
 
31
31
  // CONSTANTS
32
32
 
33
- // Initialize the result.
34
- const data = {
35
- totals: {
36
- triggers: 0,
37
- headTriggers: 0,
38
- tailTriggers: 0,
39
- impactTriggers: 0,
40
- additions: 0,
41
- removals: 0,
42
- opacityChanges: 0,
43
- opacityImpact: 0,
44
- unhoverables: 0
45
- }
46
- };
33
+ const data = {};
47
34
 
48
35
  // FUNCTIONS
49
36
 
@@ -171,7 +158,10 @@ const find = async (withItems, page, region, sample, popRatio) => {
171
158
  position: {
172
159
  x: 0,
173
160
  y: 0
174
- }
161
+ },
162
+ timeout: 500,
163
+ force: true,
164
+ noWaitAfter: true
175
165
  });
176
166
  // Wait for any delayed and/or slowed hover reaction.
177
167
  await page.waitForTimeout(200);
@@ -218,6 +208,18 @@ const find = async (withItems, page, region, sample, popRatio) => {
218
208
  exports.reporter = async (
219
209
  page, headSize = 0, headSampleSize = -1, tailSampleSize = -1, withItems
220
210
  ) => {
211
+ // Initialize the result.
212
+ data.totals = {
213
+ triggers: 0,
214
+ headTriggers: 0,
215
+ tailTriggers: 0,
216
+ impactTriggers: 0,
217
+ additions: 0,
218
+ removals: 0,
219
+ opacityChanges: 0,
220
+ opacityImpact: 0,
221
+ unhoverables: 0
222
+ };
221
223
  // If details are to be reported:
222
224
  if (withItems) {
223
225
  // Add properties for details to the initialized result.
package/tests/htmlcs.js CHANGED
@@ -21,14 +21,14 @@ exports.reporter = async page => {
21
21
  const nextIssues = await page.evaluate(standard => {
22
22
  let issues = null;
23
23
  try {
24
- issues = HTMLCS_RUNNER.run(standard);
24
+ issues = window['HTMLCS_RUNNER'].run(standard);
25
25
  }
26
26
  catch(error) {
27
27
  console.log(`ERROR executing HTMLCS_RUNNER on ${document.URL} (${error.message})`);
28
- };
28
+ }
29
29
  return issues;
30
30
  }, standard);
31
- if (nextIssues) {
31
+ if (nextIssues && nextIssues.every(issue => typeof issue === 'string')) {
32
32
  messageStrings.push(... nextIssues);
33
33
  }
34
34
  else {
@@ -36,7 +36,7 @@ exports.reporter = async page => {
36
36
  result.error = 'ERROR executing HTMLCS_RUNNER in the page';
37
37
  break;
38
38
  }
39
- };
39
+ }
40
40
  if (! result.prevented) {
41
41
  // Sort the issues by class and standard.
42
42
  messageStrings.sort();
package/tests/ibm.js CHANGED
@@ -104,7 +104,7 @@ exports.reporter = async (page, withItems, withNewContent) => {
104
104
  result.content = await doTest(typeContent, withItems, timeLimit);
105
105
  if (result.content.prevented) {
106
106
  result.prevented = true;
107
- console.log('ERROR: Getting ibm test report from page took too long');
107
+ console.log(`ERROR: Getting ibm test report from page timed out at ${timeLimit} seconds`);
108
108
  }
109
109
  }
110
110
  // If a test with new content is to be performed:
@@ -114,7 +114,7 @@ exports.reporter = async (page, withItems, withNewContent) => {
114
114
  result.url = await doTest(typeContent, withItems, timeLimit);
115
115
  if (result.url.prevented) {
116
116
  result.prevented = true;
117
- console.log('ERROR: Getting ibm test report from URL took too long');
117
+ console.log(`ERROR: Getting ibm test report from URL timed out at ${timeLimit} seconds`);
118
118
  }
119
119
  }
120
120
  await close();
package/tests/tabNav.js CHANGED
@@ -103,7 +103,9 @@ exports.reporter = async (page, withItems) => {
103
103
  });
104
104
  })
105
105
  .catch(error => {
106
- console.log(`ERROR: could not click tab element ${itemData.text} (${error.message})`);
106
+ console.log(
107
+ `ERROR clicking tab element ${itemData.text} (${error.message.replace(/\n.+/s, '')})`
108
+ );
107
109
  pressed = false;
108
110
  });
109
111
  // Increment the counts of navigations and key navigations.