testaro 36.1.2 → 36.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "36.1.2",
3
+ "version": "36.2.0",
4
4
  "description": "Run 1000 web accessibility tests from 10 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2023–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -84,7 +84,7 @@ exports.getLocatorData = async loc => {
84
84
  if (data.location.type === 'box') {
85
85
  // Define a bounding-box-based location.
86
86
  const rawSpec = await loc.boundingBox();
87
- // If there is a bounding box:
87
+ // If there is a bounding box (i.e. the element is visible):
88
88
  if (rawSpec) {
89
89
  // Populate the location.
90
90
  Object.keys(rawSpec).forEach(specName => {
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2023–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2023–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2023–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
package/testaro/motion.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2021–2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2021–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -51,6 +51,7 @@ exports.reporter = async page => {
51
51
  delayBefore: 2000,
52
52
  delayBetween: 3000
53
53
  });
54
+ console.log(JSON.stringify(data, null, 2));
54
55
  // If the screenshots succeeded:
55
56
  if (data.success) {
56
57
  // If any pixels were changed:
package/testaro/tabNav.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2021–2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2021–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2023–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
package/tests/nuVal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2022–2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2022–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -31,93 +31,78 @@
31
31
  erratic, no better solution is known.
32
32
  */
33
33
 
34
- // ########## IMPORTS
34
+ // IMPORTS
35
35
 
36
36
  // Module to process files.
37
37
  const fs = require('fs/promises');
38
+ // Module to get the document source.
39
+ const {getSource} = require('../procs/getSource');
38
40
 
39
- // ########## FUNCTIONS
41
+ // FUNCTIONS
40
42
 
41
43
  // Conducts and reports the Nu Html Checker tests.
42
44
  exports.reporter = async (page, options) => {
43
45
  const {rules} = options;
44
46
  // Get the browser-parsed page.
45
47
  const pageContent = await page.content();
46
- // Get the page source.
47
- const url = page.url();
48
- const scheme = url.replace(/:.+/, '');
49
- let rawPage;
50
- // If it is local.
51
- if (scheme === 'file') {
52
- const filePath = url.slice(7);
53
- rawPage = await fs.readFile(filePath, 'utf8');
54
- }
55
- else {
56
- // If it is remote (15 seconds allowed).
57
- try {
58
- const rawPageResponse = await fetch(url, {signal: AbortSignal.timeout(15000)});
59
- rawPage = rawPageResponse.body;
60
- }
61
- catch(error) {
62
- console.log(`ERROR getting page for nuVal test (${error.message})`);
63
- return {result: {
64
- prevented: true,
65
- error: 'ERROR getting page for nuVal test'
66
- }};
67
- }
68
- }
69
- // Get the data from validator.w3.org, a more reliable service than validator.nu.
70
- const fetchOptions = {
71
- method: 'post',
72
- headers: {
73
- 'User-Agent': 'Mozilla/5.0',
74
- 'Content-Type': 'text/html; charset=utf-8'
75
- }
76
- };
77
- const nuURL = 'https://validator.w3.org/nu/?parser=html&out=json';
48
+ // Get the source.
49
+ const sourceData = await getSource(page);
50
+ // If it was not obtained:
78
51
  const data = {};
79
52
  const result = {};
80
- // For each page type:
81
- for (const page of [['pageContent', pageContent], ['rawPage', rawPage]]) {
82
- try {
83
- // Get a Nu Html Checker report on it.
84
- fetchOptions.body = page[1];
85
- const nuResult = await fetch(nuURL, fetchOptions);
86
- const nuData = await nuResult.json();
87
- // Delete left and right quotation marks and their erratic invalid replacements.
88
- const nuDataClean = JSON.parse(JSON.stringify(nuData).replace(/[\u{fffd}“”]/ug, ''));
89
- result[page[0]] = nuDataClean;
90
- // If there is a report and rules were specified:
91
- if (! result[page[0]].error && rules && Array.isArray(rules) && rules.length) {
92
- // Remove all messages except those specified.
93
- result[page[0]].messages = result[page[0]].messages.filter(message => rules.some(rule => {
94
- if (rule[0] === '=') {
95
- return message.message === rule.slice(1);
96
- }
97
- else if (rule[0] === '~') {
98
- return new RegExp(rule.slice(1)).test(message.message);
99
- }
100
- else {
101
- console.log(`ERROR: Invalid nuVal rule ${rule}`);
102
- return false;
103
- }
104
- }));
53
+ if (sourceData.prevented) {
54
+ // Report this.
55
+ data.prevented = true;
56
+ data.error = sourceData.error;
57
+ }
58
+ // Otherwise, i.e. if it was obtained:
59
+ else {
60
+ // Get results from validator.w3.org, a more reliable service than validator.nu.
61
+ const fetchOptions = {
62
+ method: 'post',
63
+ headers: {
64
+ 'User-Agent': 'Mozilla/5.0',
65
+ 'Content-Type': 'text/html; charset=utf-8'
105
66
  }
106
- return {
107
- data,
108
- result
109
- };
110
- }
111
- catch (error) {
112
- const message = `ERROR: Act failed (${error.message})`;
113
- console.log(message);
114
- return {
115
- data: {
116
- prevented: true,
117
- error: message,
118
- },
119
- result: {}
67
+ };
68
+ const nuURL = 'https://validator.w3.org/nu/?parser=html&out=json';
69
+ // For each page type:
70
+ for (const page of [['pageContent', pageContent], ['rawPage', sourceData.source]]) {
71
+ try {
72
+ // Get a Nu Html Checker report on it.
73
+ fetchOptions.body = page[1];
74
+ const nuResult = await fetch(nuURL, fetchOptions);
75
+ const nuData = await nuResult.json();
76
+ // Delete left and right quotation marks and their erratic invalid replacements.
77
+ const nuDataClean = JSON.parse(JSON.stringify(nuData).replace(/[\u{fffd}“”]/ug, ''));
78
+ result[page[0]] = nuDataClean;
79
+ // If there is a report and rules were specified:
80
+ if (! result[page[0]].error && rules && Array.isArray(rules) && rules.length) {
81
+ // Remove all messages except those specified.
82
+ result[page[0]].messages = result[page[0]].messages.filter(message => rules.some(rule => {
83
+ if (rule[0] === '=') {
84
+ return message.message === rule.slice(1);
85
+ }
86
+ else if (rule[0] === '~') {
87
+ return new RegExp(rule.slice(1)).test(message.message);
88
+ }
89
+ else {
90
+ console.log(`ERROR: Invalid nuVal rule ${rule}`);
91
+ return false;
92
+ }
93
+ }));
94
+ }
95
+ }
96
+ catch (error) {
97
+ const message = `ERROR getting results for ${page[0]} (${error.message})`;
98
+ console.log(message);
99
+ data.prevented = true;
100
+ data.error = message;
120
101
  };
121
- }
102
+ };
122
103
  }
104
+ return {
105
+ data,
106
+ result
107
+ };
123
108
  };
package/tests/testaro.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- © 2023 CVS Health and/or one of its affiliates. All rights reserved.
2
+ © 2023–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal