testaro 75.2.0 → 75.2.2

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/README.md CHANGED
@@ -258,7 +258,7 @@ In both cases, the first argument of `dirWatch` tells Testaro whether to continu
258
258
 
259
259
  Testaro can poll a server for jobs to be performed. The server can act as the “controller” described in [How to run a thousand accessibility tests](https://medium.com/cvs-health-tech-blog/how-to-run-a-thousand-accessibility-tests-63692ad120c3). The server is responsible for preparing Testaro jobs, assigning them to Testaro agents, receiving reports back from those agents, and performing any further processing of the reports, including enhancement, storage, and disclosure to audiences. It can be any server reachable with a URL. That includes a server running on the same host as Testaro, with a URL such as `localhost:3000`.
260
260
 
261
- To make Testaro poll a server for jobs, define the following environment variables:
261
+ To allow Testaro to poll a server for jobs, define the following environment variables:
262
262
 
263
263
  - `NETWATCH_URL_JOB`: which URL to poll (the URL must contain the value of the `AGENT` environment variable)
264
264
  - `NETWATCH_URL_REPORT`: which URL to send job reports to
package/netWatch.js CHANGED
@@ -29,10 +29,21 @@ const {nowString} = require('./procs/dateTime');
29
29
 
30
30
  // CONSTANTS
31
31
 
32
- const jobURL = new URL(process.env.NETWATCH_URL_JOB);
33
- const jobHost = jobURL.host;
34
- const reportURL = new URL(process.env.NETWATCH_URL_REPORT);
35
- const reportHost = reportURL.host;
32
+ // The netWatch environment variables are required only for network watching,
33
+ // but call.js loads this module for every command, so their absence or
34
+ // invalidity must not throw here; netWatch reports it if netWatch is used.
35
+ const toURL = urlString => {
36
+ try {
37
+ return new URL(urlString);
38
+ }
39
+ catch(error) {
40
+ return null;
41
+ }
42
+ };
43
+ const jobURL = toURL(process.env.NETWATCH_URL_JOB);
44
+ const jobHost = jobURL && jobURL.host;
45
+ const reportURL = toURL(process.env.NETWATCH_URL_REPORT);
46
+ const reportHost = reportURL && reportURL.host;
36
47
  const agentPW = process.env.NETWATCH_URL_AUTH;
37
48
 
38
49
  // FUNCTIONS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testaro",
3
- "version": "75.2.0",
3
+ "version": "75.2.2",
4
4
  "description": "Run 1300 web accessibility tests from 10 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/procs/catalog.js CHANGED
@@ -35,7 +35,7 @@ exports.getCatalog = async report => {
35
35
  const targetURL = report.target?.url;
36
36
  // If the report specifies a global browser ID and a global target URL:
37
37
  if (browserID && targetURL) {
38
- // Launch a browser, navigate to the target, and get the resulting page.
38
+ // Launch a browser and visit the target, or abort the job on failure.
39
39
  const page = await launch({
40
40
  report,
41
41
  actIndex: null,
@@ -159,7 +159,7 @@ exports.getCatalog = async report => {
159
159
  return catalog;
160
160
  }
161
161
  // Otherwise, i.e. if the launch or navigation failed, report and return this.
162
- console.log('ERROR: Launch or navigation failure prevented catalog creation');
162
+ console.log('ERROR: Launch or navigation failure prevented cataloguing and aborted job');
163
163
  return {};
164
164
  }
165
165
  // Otherwise, i.e. if the report specification is incomplete, report and return this.
package/procs/launch.js CHANGED
@@ -132,6 +132,7 @@ const goTo = exports.goTo = async (report, page, url, timeout, waitUntil) => {
132
132
  const actualURL = page.url();
133
133
  const actualNorm = actualURL.startsWith('file:') ? normalizeURL(actualURL) : actualURL;
134
134
  const urlNorm = url.startsWith('file:') ? normalizeURL(url) : url;
135
+ const title = await page.title();
135
136
  // If the browser was redirected in violation of a strictness requirement:
136
137
  if (report.strict && deSlash(actualNorm) !== deSlash(urlNorm)) {
137
138
  // Return an error.
@@ -141,6 +142,15 @@ const goTo = exports.goTo = async (report, page, url, timeout, waitUntil) => {
141
142
  error: 'badRedirection'
142
143
  };
143
144
  }
145
+ // Otherwise, if the browser was redirected to a CAPTCHA barrier:
146
+ else if ([urlNorm, title].some(identifier => identifier.includes('captcha'))) {
147
+ // Return this.
148
+ console.log(`ERROR: Visit to ${url} redirected to CAPTCHA barrier (${actualURL})`);
149
+ return {
150
+ success: false,
151
+ error: 'captchaBarrier'
152
+ };
153
+ }
144
154
  // Otherwise, i.e. if no prohibited redirection occurred:
145
155
  else {
146
156
  // Press the Escape key to dismiss any modal dialog.
@@ -179,6 +189,15 @@ const goTo = exports.goTo = async (report, page, url, timeout, waitUntil) => {
179
189
  error: `status429/retryAfterSeconds=${waitSeconds}`
180
190
  };
181
191
  }
192
+ // Otherwise, if the response status was a suspension:
193
+ else if (httpStatus === 202) {
194
+ // Return this.
195
+ console.log(`ERROR: Visit to ${url} suspended (status 202)`);
196
+ return {
197
+ success: false,
198
+ error: 'status202'
199
+ };
200
+ }
182
201
  // Otherwise, i.e. if the response status was otherwise abnormal:
183
202
  else {
184
203
  // Return an error.
@@ -626,7 +645,7 @@ exports.launch = async (opts = {}) => {
626
645
  // Report this and, if so configured, that the job was aborted.
627
646
  addError(
628
647
  true,
629
- abortAssertively,
648
+ actIndex === null ? true : abortAssertively,
630
649
  report,
631
650
  actIndex,
632
651
  `Launch or navigation failed; retries and browser types exhausted`