testaro 4.1.1 → 4.2.1
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 +88 -27
- package/batchify.js +24 -0
- package/{job.js → create.js} +10 -28
- package/high.js +11 -0
- package/package.json +1 -1
- package/procs/{test/allText.js → allText.js} +0 -0
- package/procs/{test/allVis.js → allVis.js} +0 -0
- package/procs/{test/linksByType.js → linksByType.js} +0 -0
- package/procs/{test/textOf.txt → textOf.txt} +0 -0
- package/run.js +10 -9
- package/samples/scripts/simple.json +3 -1
- package/samples/scripts/tenon.json +1 -0
- package/tests/focInd.js +1 -1
- package/tests/linkUl.js +1 -1
- package/tests/menuNav.js +1 -1
- package/tests/radioSet.js +1 -1
- package/tests/styleDiff.js +1 -1
- package/tests/tabNav.js +1 -1
- package/tests/wave.js +1 -1
- package/validation/exJobs/README.md +3 -0
- package/validation/executors/high1.js +32 -0
- package/validation/executors/high2.js +37 -0
- package/validation/executors/low.js +31 -0
- package/validation/executors/watchDir.js +17 -0
- package/validation/executors/watchNet.js +106 -0
- package/validation/jobs/README.md +3 -0
- package/validation/protoJobs/README.md +3 -0
- package/validation/protoJobs/val1.json +25 -0
- package/validation/protoJobs/val2.json +41 -0
- package/watch.js +281 -0
- package/procs/score/asp09.js +0 -555
- package/procs/score/asp09NoWAVE.js +0 -508
- package/validation/executors/app.js +0 -66
- package/validation/executors/test.js +0 -48
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ Some of the dependencies of Testaro are published as Github packages. Installing
|
|
|
66
66
|
//npm.pkg.github.com/:username=abc
|
|
67
67
|
//npm.pkg.github.com/:_authToken=xyz
|
|
68
68
|
```
|
|
69
|
+
|
|
69
70
|
Once you have done that, you can install Testaro as you would install any `npm` package.
|
|
70
71
|
|
|
71
72
|
## Payment
|
|
@@ -383,36 +384,40 @@ You may wish to have Testaro perform the same sequence of tests on multiple web
|
|
|
383
384
|
}
|
|
384
385
|
```
|
|
385
386
|
|
|
386
|
-
With a batch, you can execute a single statement to run a script multiple times, one per host. On each call, Testaro takes one of the hosts in the batch and substitutes it for each host specified in a `url` command of the script.
|
|
387
|
+
With a batch, you can execute a single statement to run a script multiple times, one per host. On each call, Testaro takes one of the hosts in the batch and substitutes it for each host specified in a `url` command of the script. The result is a _host script_. Testaro sequentially runs all of those host scripts.
|
|
388
|
+
|
|
389
|
+
## Samples
|
|
390
|
+
|
|
391
|
+
The `samples` directory contains examples of scripts and batches. If you wish to use them in their current locations, you can give `SCRIPTDIR` the value `'samples/scripts'` and `BATCHDIR` the value `'samples/batches'`. Then execute `node create sss` or `node create sss bbb` to run the `sss` script alone or with the `bbb` batch (e.g., `node create simple weborgs`). The `create` module will create a job, run the script or host scripts, and save the report(s) in the directory that you have specified with the `REPORTDIR` environment variable.
|
|
387
392
|
|
|
388
393
|
## Execution
|
|
389
394
|
|
|
390
395
|
### Invocation
|
|
391
396
|
|
|
392
|
-
There are
|
|
397
|
+
There are three methods for using Testaro.
|
|
393
398
|
|
|
394
399
|
#### Low-level
|
|
395
400
|
|
|
396
|
-
|
|
401
|
+
A module in this package can invoke Testaro with this pattern:
|
|
397
402
|
|
|
398
403
|
```javascript
|
|
399
404
|
const report = {
|
|
400
|
-
id: '',
|
|
401
405
|
script: {…},
|
|
402
406
|
log: [],
|
|
403
407
|
acts: []
|
|
404
408
|
};
|
|
409
|
+
const {handleRequest} = require('./run');
|
|
410
|
+
handleRequest(report)
|
|
411
|
+
.then(() => …);
|
|
405
412
|
```
|
|
406
413
|
|
|
407
414
|
Replace `{…}` with a script object, like the example script shown above. The low-level method does not allow the use of batches.
|
|
408
415
|
|
|
409
|
-
|
|
410
|
-
- Another Node.js package that has Testaro as a dependency can execute `require('testaro').run(report)`.
|
|
411
|
-
- In a command environment with the Testaro project directory as the current directory, you can execute `node run report`.
|
|
416
|
+
The argument of `require` is a path relative to the directory of the module in which this code appears. If the module is in a subdirectory, `./run` will need to be revised. In an executor within `validation/executors`, it must be revised to `../../run`.
|
|
412
417
|
|
|
413
|
-
|
|
418
|
+
Another Node.js package that has Testaro as a dependency can execute the same statements, except changing `'./run'` to `'testaro/run'`.
|
|
414
419
|
|
|
415
|
-
|
|
420
|
+
Testaro will run the script and populate the `log` and `acts` arrays of the `report` object. When Testaro finishes, the `log` and `acts` properties will contain the results. The final statement can further process the `report` object as desired in the `then` callback.
|
|
416
421
|
|
|
417
422
|
#### High-level
|
|
418
423
|
|
|
@@ -421,52 +426,109 @@ Make sure that you have defined these environment variables, with absolute or re
|
|
|
421
426
|
- `BATCHDIR`
|
|
422
427
|
- `REPORTDIR`
|
|
423
428
|
|
|
424
|
-
Relative paths must be relative to the Testaro project directory. For example, if the script directory is `scripts` in a `testing` directory that is a sibling of the Testaro directory, then `SCRIPTDIR` must have the value `../testing/scripts`.
|
|
429
|
+
Relative paths must be relative to the Testaro project directory. For example, if the script directory is `scripts` in a `testing` directory that is a sibling of the Testaro directory, then a relative-path `SCRIPTDIR` must have the value `../testing/scripts`.
|
|
425
430
|
|
|
426
431
|
Also ensure that Testaro can read all those directories and write to `REPORTDIR`.
|
|
427
432
|
|
|
428
433
|
Place a script into `SCRIPTDIR` and, optionally, a batch into `BATCHDIR`. Each should be named `idValue.json`, where `idValue` is replaced with the value of its `id` property. That value must consist of only lower-case ASCII letters and digits.
|
|
429
434
|
|
|
430
|
-
Then execute the statement `node
|
|
435
|
+
Then execute the statement `node high scriptID` or `node high scriptID batchID`, replacing `scriptID` and `batchID` with the `id` values of the script and the batch, respectively.
|
|
431
436
|
|
|
432
|
-
The `
|
|
437
|
+
The `high` module will call the `runJob` function of the `create` module, which in turn will call the `handleRequest` function of the `run` module. The results will be saved in report files in the `REPORTDIR` directory.
|
|
433
438
|
|
|
434
|
-
If there is no batch, the report file will be named with a unique timestamp, suffixed with a `.json` extension. If there is a batch, then the base of each file’s name will be the same timestamp, suffixed with `-hostID`, where `hostID` is the value of the `id` property of the `host` object in the batch file. For example, if you execute `node
|
|
439
|
+
If there is no batch, the report file will be named with a unique timestamp, suffixed with a `.json` extension. If there is a batch, then the base of each report file’s name will be the same timestamp, suffixed with `-hostID`, where `hostID` is the value of the `id` property of the `host` object in the batch file. For example, if you execute `node create script01 wikis`, you might get these report files deposited into `REPORTDIR`:
|
|
435
440
|
- `enp46j-wikipedia.json`
|
|
436
441
|
- `enp45j-wiktionary.json`
|
|
437
442
|
- `enp45j-wikidata.json`
|
|
438
443
|
|
|
444
|
+
#### Watch
|
|
445
|
+
|
|
446
|
+
In watch mode, Testaro periodically checks for a job to be run by it, containing a script and, optionally, a batch. When such a job exists, Testaro runs the script, or uses the batch to create a set of host scripts and sequentially runs them. After running the script or each host script, Testaro converts the report to JSON and disposes of it as specified.
|
|
447
|
+
|
|
448
|
+
Testaro checks periodically. The interval between checks, in seconds, is specified by an `INTERVAL` environment variable.
|
|
449
|
+
|
|
450
|
+
After Testaro starts watching, its behavior depends on the environment variable `WATCH_FOREVER`. If its value is `true`, watching continues indefinitely. If its value is `false` or it has no value, watching stops after the first job is found and run.
|
|
451
|
+
|
|
452
|
+
To make Testaro start watching, execute the statement `node watch`.
|
|
453
|
+
|
|
454
|
+
There are two ways for Testaro to watch for jobs.
|
|
455
|
+
|
|
456
|
+
##### Directory watch
|
|
457
|
+
|
|
458
|
+
With directory watch, Testaro checks whether a particular directory in its host’s filesystem contains a job file. A job file is a JSON-format file named `abc.json` representing an object like this:
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{
|
|
462
|
+
"script": {…},
|
|
463
|
+
"batch": {…}
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
The `batch` property is optional. The value `abc` may be replaced with any string of lower-case ASCII letters and digits.
|
|
468
|
+
|
|
469
|
+
When Testaro finds job files in the directory, Testaro runs the first job, writes the report(s) into the report directory, and moves the job file into the ex-jobs directory.
|
|
470
|
+
|
|
471
|
+
Testaro suspends checking while it is running any job. Therefore, even though the currently running job file remains in `JOBDIR`, Testaro will not try to run it again.
|
|
472
|
+
|
|
473
|
+
Since Testaro runs the first job (i.e. the job whose name is first in ASCII order), whoever populates the directory with job files has control over the order in which Testaro runs them. For example, to force a new job to be run before the already waiting jobs, one can give it a filename that comes before that of the first waiting job.
|
|
474
|
+
|
|
475
|
+
In order to make directory watching possible, you must define these environment variables:
|
|
476
|
+
- `WATCH_TYPE=dir`
|
|
477
|
+
- `INTERVAL`
|
|
478
|
+
- `WATCH_FOREVER` (`=true` or `=false`)
|
|
479
|
+
- `REPORTDIR`
|
|
480
|
+
- `JOBDIR`
|
|
481
|
+
- `EXJOBDIR`
|
|
482
|
+
|
|
483
|
+
##### Network watch
|
|
484
|
+
|
|
485
|
+
With network watch, Testaro asks a particular API whether it has any jobs for the current instance of Testaro, identified by an authorization code. If the response is a JSON representation of an object satisfying the same requirements as given above under “Directory watch”, Testaro runs the job and sends the report(s) to the API.
|
|
486
|
+
|
|
487
|
+
Thus, if there are multiple jobs queued for the Testaro instance, the API is responsible for choosing one of them to send in response.
|
|
488
|
+
|
|
489
|
+
When the API receives the reports, it can dispose of them as desired. Each report is a JSON representation of an object, which has these identification properties:
|
|
490
|
+
- `jobID`
|
|
491
|
+
- `timeStamp`
|
|
492
|
+
- `id`
|
|
493
|
+
|
|
494
|
+
The `jobID` property can be used for an association between each report and the job that it arose from. The `timeStamp` property can be used for an association of all the reports in a batched job. And the `id` property (which begins with the time stamp) is unique to each report.
|
|
495
|
+
|
|
496
|
+
In order to make network watching possible, you must define these environment variables:
|
|
497
|
+
- `WATCH_TYPE=net`
|
|
498
|
+
- `INTERVAL`
|
|
499
|
+
- `WATCH_FOREVER` (`=true` or `=false`)
|
|
500
|
+
- `PROTOCOL` (`=http` or `=https`)
|
|
501
|
+
- `JOB_URL` (not including the authorization code)
|
|
502
|
+
- `REPORT_URL` (not including the authorization code)
|
|
503
|
+
|
|
439
504
|
### Environment variables
|
|
440
505
|
|
|
441
506
|
As mentioned above, using the high-level method to run Testaro jobs requires `SCRIPTDIR`, `BATCHDIR`, and `REPORTDIR` environment variables.
|
|
442
507
|
|
|
443
|
-
If a `tenon` test is included in the script, environment variables named `
|
|
508
|
+
If a `tenon` test is included in the script, environment variables named `TENON_USER` and `TENON_PASSWORD` must exist, with your Tenon username and password, respectively, as their values.
|
|
444
509
|
|
|
445
|
-
If a `wave` test is included in the script, an environment variable named `
|
|
510
|
+
If a `wave` test is included in the script, an environment variable named `WAVE_KEY` must exist, with your WAVE API key as its value.
|
|
446
511
|
|
|
447
512
|
The `text` command can interpolate the value of an environment variable into text that it enters on a page, as documented in the `commands.js` file.
|
|
448
513
|
|
|
449
|
-
Before executing a Testaro script, you can optionally also set the environment variables `
|
|
514
|
+
Before executing a Testaro script, you can optionally also set the environment variables `DEBUG` (to `'true'` or anything else) and/or `WAITS` (to a non-negative integer). The effects of these variables are described in the `index.js` file.
|
|
450
515
|
|
|
451
516
|
You may store these environment variables in an untracked `.env` file if you wish, and Testaro will recognize them.
|
|
452
517
|
|
|
453
518
|
## Validation
|
|
454
519
|
|
|
455
|
-
### Samples
|
|
456
|
-
|
|
457
|
-
The `samples` directory contains scripts and a batch that you can use to test Testaro with with the high-level method, by giving `SCRIPTDIR` the value `'samples/scripts'` and `BATCHDIR` the value `'samples/batches'`. Do to this, you must also define `REPORTDIR`. Then execute `node job simple` or `node job simple weborgs` to run the `simple` script alone or with the `weborgs` batch.
|
|
458
|
-
|
|
459
520
|
### Validators
|
|
460
521
|
|
|
461
|
-
Testaro can be validated with the _executors_ located in the `validation/executors` directory.
|
|
522
|
+
Testaro and its custom tests can be validated with the _executors_ located in the `validation/executors` directory.
|
|
462
523
|
|
|
463
524
|
The executors are:
|
|
464
525
|
|
|
465
|
-
- `
|
|
466
|
-
- `
|
|
467
|
-
- `
|
|
468
|
-
|
|
469
|
-
|
|
526
|
+
- `low`: validates low-level invocation
|
|
527
|
+
- `high1`: validates high-level invocation of a script without a batch
|
|
528
|
+
- `high2`: validates high-level invocation of a script with a batch
|
|
529
|
+
- `watchDir`: validates directory watching
|
|
530
|
+
- `watchNet`: validates network watching
|
|
531
|
+
- `tests`: validates all the custom tests (not the test packages)
|
|
470
532
|
|
|
471
533
|
To execute any executor `xyz`, call it with the statement `node validation/executors/xyz`.
|
|
472
534
|
|
|
@@ -543,7 +605,6 @@ Further development is contemplated, is taking place, or is welcomed, on:
|
|
|
543
605
|
- autocomplete attributes
|
|
544
606
|
- inclusion of other test packages, such as:
|
|
545
607
|
- FAE (https://github.com/opena11y/evaluation-library)
|
|
546
|
-
- Tenon
|
|
547
608
|
|
|
548
609
|
## Corrections
|
|
549
610
|
|
package/batchify.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
batchify.js
|
|
3
|
+
Creates a set of scripts from a script and a batch.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Converts a script to a batch-based array of scripts.
|
|
7
|
+
exports.batchify = (script, batch, timeStamp) => {
|
|
8
|
+
const {hosts} = batch;
|
|
9
|
+
const specs = hosts.map(host => {
|
|
10
|
+
const newScript = JSON.parse(JSON.stringify(script));
|
|
11
|
+
newScript.commands.forEach(command => {
|
|
12
|
+
if (command.type === 'url') {
|
|
13
|
+
command.which = host.which;
|
|
14
|
+
command.what = host.what;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
const spec = {
|
|
18
|
+
id: `${timeStamp}-${host.id}`,
|
|
19
|
+
script: newScript
|
|
20
|
+
};
|
|
21
|
+
return spec;
|
|
22
|
+
});
|
|
23
|
+
return specs;
|
|
24
|
+
};
|
package/{job.js → create.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
create.js
|
|
3
|
+
Creates and runs a file-based job and writes a report file.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// ########## IMPORTS
|
|
@@ -10,6 +10,8 @@ require('dotenv').config();
|
|
|
10
10
|
// Module to read and write files.
|
|
11
11
|
const fs = require('fs/promises');
|
|
12
12
|
const {handleRequest} = require('./run');
|
|
13
|
+
// Module to convert a script and a batch to a batch-based array of scripts.
|
|
14
|
+
const {batchify} = require('./batchify');
|
|
13
15
|
|
|
14
16
|
// ########## CONSTANTS
|
|
15
17
|
const scriptDir = process.env.SCRIPTDIR;
|
|
@@ -18,26 +20,7 @@ const reportDir = process.env.REPORTDIR;
|
|
|
18
20
|
|
|
19
21
|
// ########## FUNCTIONS
|
|
20
22
|
|
|
21
|
-
//
|
|
22
|
-
const batchify = (script, batch, timeStamp) => {
|
|
23
|
-
const {hosts} = batch;
|
|
24
|
-
const specs = hosts.map(host => {
|
|
25
|
-
const newScript = JSON.parse(JSON.stringify(script));
|
|
26
|
-
newScript.commands.forEach(command => {
|
|
27
|
-
if (command.type === 'url') {
|
|
28
|
-
command.which = host.which;
|
|
29
|
-
command.what = host.what;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const spec = {
|
|
33
|
-
id: `${timeStamp}-${host.id}`,
|
|
34
|
-
script: newScript
|
|
35
|
-
};
|
|
36
|
-
return spec;
|
|
37
|
-
});
|
|
38
|
-
return specs;
|
|
39
|
-
};
|
|
40
|
-
// Runs a no-batch script.
|
|
23
|
+
// Runs one script and writes a report file.
|
|
41
24
|
const runHost = async (id, script) => {
|
|
42
25
|
const report = {
|
|
43
26
|
id,
|
|
@@ -49,8 +32,8 @@ const runHost = async (id, script) => {
|
|
|
49
32
|
const reportJSON = JSON.stringify(report, null, 2);
|
|
50
33
|
await fs.writeFile(`${reportDir}/${id}.json`, reportJSON);
|
|
51
34
|
};
|
|
52
|
-
// Runs a job.
|
|
53
|
-
exports.
|
|
35
|
+
// Runs a file-based job and writes a report file for the script or each host.
|
|
36
|
+
exports.runJob = async (scriptID, batchID) => {
|
|
54
37
|
if (scriptID) {
|
|
55
38
|
try {
|
|
56
39
|
const scriptJSON = await fs.readFile(`${scriptDir}/${scriptID}.json`, 'utf8');
|
|
@@ -77,16 +60,15 @@ exports.job = async (scriptID, batchID) => {
|
|
|
77
60
|
// Run the script and save the result with a timestamp ID.
|
|
78
61
|
await runHost(timeStamp, script);
|
|
79
62
|
}
|
|
63
|
+
return timeStamp;
|
|
80
64
|
}
|
|
81
65
|
catch(error) {
|
|
82
66
|
console.log(`ERROR: ${error.message}\n${error.stack}`);
|
|
67
|
+
return null;
|
|
83
68
|
}
|
|
84
69
|
}
|
|
85
70
|
else {
|
|
86
71
|
console.log('ERROR: no script specified');
|
|
72
|
+
return null;
|
|
87
73
|
}
|
|
88
74
|
};
|
|
89
|
-
|
|
90
|
-
// ########## OPERATION
|
|
91
|
-
|
|
92
|
-
exports.job(process.argv[2], process.argv[3]);
|
package/high.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// high.js
|
|
2
|
+
// Invokes Testaro with the high-level method.
|
|
3
|
+
|
|
4
|
+
const {runJob} = require('./create');
|
|
5
|
+
const scriptID = process.argv[2];
|
|
6
|
+
const batchID = process.argv[3];
|
|
7
|
+
const run = async (scriptID, batchID) => {
|
|
8
|
+
const timeStamp = await runJob(scriptID, batchID);
|
|
9
|
+
console.log(`Reports in ${process.env.REPORTDIR}; ID base ${timeStamp}`);
|
|
10
|
+
};
|
|
11
|
+
run(scriptID, batchID);
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/run.js
CHANGED
|
@@ -9,9 +9,9 @@ require('dotenv').config();
|
|
|
9
9
|
const {commands} = require('./commands');
|
|
10
10
|
// ########## CONSTANTS
|
|
11
11
|
// Set DEBUG environment variable to 'true' to add debugging features.
|
|
12
|
-
const debug = process.env.
|
|
12
|
+
const debug = process.env.DEBUG === 'true';
|
|
13
13
|
// Set WAITS environment variable to a positive number to insert delays (in ms).
|
|
14
|
-
const waits = Number.parseInt(process.env.
|
|
14
|
+
const waits = Number.parseInt(process.env.WAITS) || 0;
|
|
15
15
|
// CSS selectors for targets of moves.
|
|
16
16
|
const moves = {
|
|
17
17
|
button: 'button',
|
|
@@ -209,9 +209,8 @@ const isValidLog = log => Array.isArray(log) && ! log.length;
|
|
|
209
209
|
// Validates a report object.
|
|
210
210
|
const isValidReport = async report => {
|
|
211
211
|
if (report) {
|
|
212
|
-
const {
|
|
213
|
-
return
|
|
214
|
-
&& isValidScript(script)
|
|
212
|
+
const {script, log, acts} = report;
|
|
213
|
+
return isValidScript(script)
|
|
215
214
|
&& isValidLog(log)
|
|
216
215
|
&& isValidActs(acts);
|
|
217
216
|
}
|
|
@@ -700,7 +699,7 @@ const doActs = async (report, actIndex, page) => {
|
|
|
700
699
|
// If the act is a revelation:
|
|
701
700
|
if (act.type === 'reveal') {
|
|
702
701
|
// Make all elements in the page visible.
|
|
703
|
-
await require('./procs/
|
|
702
|
+
await require('./procs/allVis').allVis(page);
|
|
704
703
|
act.result = 'All elements visible.';
|
|
705
704
|
}
|
|
706
705
|
// Otherwise, if the act is a tenon request:
|
|
@@ -742,8 +741,8 @@ const doActs = async (report, actIndex, page) => {
|
|
|
742
741
|
});
|
|
743
742
|
}
|
|
744
743
|
);
|
|
745
|
-
const tenonUser = process.env.
|
|
746
|
-
const tenonPassword = process.env.
|
|
744
|
+
const tenonUser = process.env.TENON_USER;
|
|
745
|
+
const tenonPassword = process.env.TENON_PASSWORD;
|
|
747
746
|
const postData = JSON.stringify({
|
|
748
747
|
username: tenonUser,
|
|
749
748
|
password: tenonPassword
|
|
@@ -1244,11 +1243,13 @@ exports.handleRequest = async report => {
|
|
|
1244
1243
|
if (! report.id) {
|
|
1245
1244
|
report.id = Math.floor((Date.now() - Date.UTC(2022, 1)) / 2000).toString(36);
|
|
1246
1245
|
}
|
|
1246
|
+
// Add a time stamp to the report.
|
|
1247
|
+
report.timeStamp = report.id.replace(/-.+/, '');
|
|
1247
1248
|
// Add the script commands to the report as its initial acts.
|
|
1248
1249
|
report.acts = JSON.parse(JSON.stringify(report.script.commands));
|
|
1249
1250
|
// Inject url acts where necessary to undo DOM changes.
|
|
1250
1251
|
injectURLActs(report.acts);
|
|
1251
|
-
// Perform the
|
|
1252
|
+
// Perform the acts, asynchronously adding to the log and report.
|
|
1252
1253
|
await doScript(report);
|
|
1253
1254
|
}
|
|
1254
1255
|
else {
|
package/tests/focInd.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
exports.reporter = async (page, withItems, revealAll) => {
|
|
13
13
|
// If required, make all elements visible.
|
|
14
14
|
if (revealAll) {
|
|
15
|
-
await require('../procs/
|
|
15
|
+
await require('../procs/allVis').allVis(page);
|
|
16
16
|
}
|
|
17
17
|
// Get data on the focusable visible elements with and without indicators.
|
|
18
18
|
const data = await page.$$eval('body *:visible', (elements, withItems) => {
|
package/tests/linkUl.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
exports.reporter = async (page, withItems) => {
|
|
11
11
|
// Identify the links in the page, by type.
|
|
12
|
-
const linkTypes = await require('../procs/
|
|
12
|
+
const linkTypes = await require('../procs/linksByType').linksByType(page);
|
|
13
13
|
return await page.evaluate(args => {
|
|
14
14
|
const withItems = args[0];
|
|
15
15
|
const linkTypes = args[1];
|
package/tests/menuNav.js
CHANGED
|
@@ -77,7 +77,7 @@ exports.reporter = async (page, withItems) => {
|
|
|
77
77
|
if (menus.length) {
|
|
78
78
|
// FUNCTION DEFINITIONS START
|
|
79
79
|
// Returns text associated with an element.
|
|
80
|
-
const {allText} = require('../procs/
|
|
80
|
+
const {allText} = require('../procs/allText');
|
|
81
81
|
// Returns the index of the focused menu item in an array of menu items.
|
|
82
82
|
const focusedMenuItem = async menuItems => await page.evaluate(menuItems => {
|
|
83
83
|
const focus = document.activeElement;
|
package/tests/radioSet.js
CHANGED
|
@@ -12,7 +12,7 @@ exports.reporter = async (page, withItems) => {
|
|
|
12
12
|
// If itemization is required:
|
|
13
13
|
if (withItems) {
|
|
14
14
|
// Add the body of the textOf function as a string to the array.
|
|
15
|
-
const textOfBody = await fs.readFile(`${__dirname}/../procs/
|
|
15
|
+
const textOfBody = await fs.readFile(`${__dirname}/../procs/textOf.txt`, 'utf8');
|
|
16
16
|
args.push(textOfBody);
|
|
17
17
|
}
|
|
18
18
|
// Get the result data.
|
package/tests/styleDiff.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
exports.reporter = async (page, withItems) => {
|
|
9
9
|
// Get an object with arrays of block and inline links as properties.
|
|
10
|
-
const linkTypes = await require('../procs/
|
|
10
|
+
const linkTypes = await require('../procs/linksByType').linksByType(page);
|
|
11
11
|
return await page.$eval('body', (body, args) => {
|
|
12
12
|
const withItems = args[0];
|
|
13
13
|
const linkTypes = args[1];
|
package/tests/tabNav.js
CHANGED
|
@@ -74,7 +74,7 @@ exports.reporter = async (page, withItems) => {
|
|
|
74
74
|
if (tabLists.length) {
|
|
75
75
|
// FUNCTION DEFINITIONS START
|
|
76
76
|
// Returns text associated with an element.
|
|
77
|
-
const {allText} = require('../procs/
|
|
77
|
+
const {allText} = require('../procs/allText');
|
|
78
78
|
// Returns the index of the focused tab in an array of tabs.
|
|
79
79
|
const focusedTab = async tabs => await page.evaluate(tabs => {
|
|
80
80
|
const focus = document.activeElement;
|
package/tests/wave.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
const https = require('https');
|
|
8
8
|
exports.reporter = async (page, reportType) => {
|
|
9
|
-
const waveKey = process.env.
|
|
9
|
+
const waveKey = process.env.WAVE_KEY;
|
|
10
10
|
// Get the data from a WAVE test.
|
|
11
11
|
const data = await new Promise(resolve => {
|
|
12
12
|
https.get(
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// high1.js
|
|
2
|
+
// Validator for high-level invocation of Testaro without a batch.
|
|
3
|
+
|
|
4
|
+
const fs = require('fs/promises');
|
|
5
|
+
process.env.SCRIPTDIR = 'samples/scripts';
|
|
6
|
+
process.env.REPORTDIR = 'temp';
|
|
7
|
+
const {runJob} = require('../../create');
|
|
8
|
+
const validate = async (scriptID) => {
|
|
9
|
+
const timeStamp = await runJob(scriptID);
|
|
10
|
+
try {
|
|
11
|
+
const reportJSON = await fs.readFile(`${__dirname}/../../temp/${timeStamp}.json`);
|
|
12
|
+
const report = JSON.parse(reportJSON);
|
|
13
|
+
const {log, acts} = report;
|
|
14
|
+
if (log.length !== 2) {
|
|
15
|
+
console.log(
|
|
16
|
+
`Failure: log length is ${log.length} instead of 2 (see temp/${timeStamp}.json})`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
else if (acts.length !== 3) {
|
|
20
|
+
console.log(
|
|
21
|
+
`Failure: acts length is ${acts.length} instead of 3 (see temp/${timeStamp}.json})`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
console.log(`Success (report is in temp/${timeStamp}.json)`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch(error) {
|
|
29
|
+
console.log(`ERROR: ${error.message}`);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
validate('simple');
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// high2.js
|
|
2
|
+
// Validator for high-level invocation of Testaro with a batch.
|
|
3
|
+
|
|
4
|
+
const fs = require('fs/promises');
|
|
5
|
+
process.env.SCRIPTDIR = 'samples/scripts';
|
|
6
|
+
process.env.BATCHDIR = 'samples/batches';
|
|
7
|
+
process.env.REPORTDIR = 'temp';
|
|
8
|
+
const {runJob} = require('../../create');
|
|
9
|
+
const validate = async (scriptID, batchID) => {
|
|
10
|
+
const timeStamp = await runJob(scriptID, batchID);
|
|
11
|
+
try {
|
|
12
|
+
const tempFileNames = await fs.readdir(`${__dirname}/../../temp`);
|
|
13
|
+
const reportFileNames = tempFileNames.filter(fileName => fileName.startsWith(timeStamp));
|
|
14
|
+
for (const fileName of reportFileNames) {
|
|
15
|
+
const reportJSON = await fs.readFile(`${__dirname}/../../temp/${fileName}`);
|
|
16
|
+
const report = JSON.parse(reportJSON);
|
|
17
|
+
const {log, acts} = report;
|
|
18
|
+
if (log.length !== 2) {
|
|
19
|
+
console.log(
|
|
20
|
+
`Failure: log length is ${log.length} instead of 2 (see temp/${fileName})`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
else if (acts.length !== 3) {
|
|
24
|
+
console.log(
|
|
25
|
+
`Failure: acts length is ${acts.length} instead of 3 (see temp/${fileName})`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.log(`Success (report is in temp/${fileName})`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch(error) {
|
|
34
|
+
console.log(`ERROR: ${error.message}`);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
validate('simple', 'weborgs');
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// low.js
|
|
2
|
+
// Validator for low-level invocation of Testaro.
|
|
3
|
+
|
|
4
|
+
const fs = require('fs/promises');
|
|
5
|
+
const getSampleScript = async scriptID => {
|
|
6
|
+
const scriptJSON = await fs.readFile(`${__dirname}/../../samples/scripts/${scriptID}.json`);
|
|
7
|
+
return JSON.parse(scriptJSON);
|
|
8
|
+
};
|
|
9
|
+
const validate = async () => {
|
|
10
|
+
const script = await getSampleScript('simple');
|
|
11
|
+
const report = {
|
|
12
|
+
script,
|
|
13
|
+
log: [],
|
|
14
|
+
acts: []
|
|
15
|
+
};
|
|
16
|
+
const {handleRequest} = require('../../run');
|
|
17
|
+
await handleRequest(report);
|
|
18
|
+
const {log, acts} = report;
|
|
19
|
+
if (log.length !== 2) {
|
|
20
|
+
console.log(`Failure: log length is ${log.length} instead of 2`);
|
|
21
|
+
console.log(JSON.stringify(log, null, 2));
|
|
22
|
+
}
|
|
23
|
+
else if (acts.length !== 3) {
|
|
24
|
+
console.log(`Failure: acts length is ${acts.length} instead of 3`);
|
|
25
|
+
console.log(JSON.stringify(acts, null, 2));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
console.log('Success');
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
validate();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// watchDir.js
|
|
2
|
+
// Validator for directory watching.
|
|
3
|
+
|
|
4
|
+
const fs = require('fs/promises');
|
|
5
|
+
process.env.WATCH_TYPE = 'dir';
|
|
6
|
+
process.env.INTERVAL = 5;
|
|
7
|
+
process.env.REPORTDIR = 'temp';
|
|
8
|
+
process.env.JOBDIR = 'validation/jobs';
|
|
9
|
+
process.env.EXJOBDIR = 'validation/exJobs';
|
|
10
|
+
process.env.WATCH_FOREVER = false;
|
|
11
|
+
// Start checking for jobs every 5 seconds.
|
|
12
|
+
require('../../watch');
|
|
13
|
+
// Copy a job into JOBDIR after 7 seconds.
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
fs.copyFile(`${__dirname}/../protoJobs/val1.json`, `${__dirname}/../jobs/val1.json`);
|
|
16
|
+
console.log('Job copied into job directory after 7 seconds');
|
|
17
|
+
}, 7000);
|