testilo 3.13.0 → 4.0.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 +100 -37
- package/compare.js +7 -2
- package/digest.js +9 -3
- package/merge.js +72 -0
- package/package.json +1 -1
- package/score.js +7 -3
package/README.md
CHANGED
|
@@ -1,72 +1,135 @@
|
|
|
1
1
|
# testilo
|
|
2
|
-
|
|
2
|
+
Utilities for Testaro
|
|
3
3
|
|
|
4
4
|
## Introduction
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
The Testilo package contains utilities that facilitate the use of the [Testaro](https://www.npmjs.com/package/testaro) package.
|
|
7
|
+
|
|
8
|
+
Testaro performs digital accessibility tests on web artifacts and creates reports in JSON format. The utilities in Testilo prepare jobs for Testaro to run and create additional value from the reports that Testaro produces.
|
|
9
|
+
|
|
10
|
+
Because Testilo supports Testaro, this `README` file presumes that you have access to the Testaro `README` file and therefore does not repeat information provided there.
|
|
7
11
|
|
|
8
12
|
## Dependencies
|
|
9
13
|
|
|
10
|
-
The `dotenv` dependency lets you set environment variables in an untracked `.env` file.
|
|
14
|
+
The `dotenv` dependency lets you set environment variables in an untracked `.env` file. This prevents secret data, such as passwords, from being shared as part of this package.
|
|
11
15
|
|
|
12
16
|
## Architecture
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
Testilo is written in Node.js. Commands are given to Testilo in a command-line (terminal) interface or programmatically.
|
|
19
|
+
|
|
20
|
+
Shared routines that perform scoring, digesting, and comparing are _procs_ and are located in the `procs` directory.
|
|
21
|
+
|
|
22
|
+
Testilo can be installed wherever Node.js (version 14 or later) is installed. This can be a server or the same workstation on which Testaro is installed.
|
|
23
|
+
|
|
24
|
+
The reason for Testilo being an independent package, rather than part of Testaro, is that Testilo can be installed on any host, while Testaro can run successfully only on a Windows or Macintosh workstation (and perhaps on some workstations with Ubuntu operating systems). Testaro runs tests similar to those that a human accessibility tester would run, using whatever browsers, input devices, system settings, simulated and attached devices, and assistive technologies tests may require. Thus, Testaro is limited to functionalities that require workstation attributes. For maximum flexibility in the management of Testaro jobs, all other functionalities are located outside of Testaro. You could have software such as Testilo running on a server, communicating with multiple workstations running Testaro, receiving job orders from the server and returning job results to the server for further processing.
|
|
25
|
+
|
|
26
|
+
## Utilities
|
|
27
|
+
|
|
28
|
+
### `merge`
|
|
29
|
+
|
|
30
|
+
The `merge` utility is useful when you want Testaro to perform the same set of operations on multiple hosts. For example, you may want the same tests run on multiple web pages. You would have a single script, and you would want multiple jobs created from it. Each job would target one host, and, for that purpose, any `url` command in the script would be modified so that its properties are those of that host. The `merge` utility (similar to mail merge in office applications) does this. It creates Testaro jobs out of a script and a _batch_.
|
|
31
|
+
|
|
32
|
+
A batch is a JSON-format file representing a `batch` object, which contains an array of _hosts_.
|
|
33
|
+
|
|
34
|
+
Here is an example of a batch:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"id": "usFedExec1",
|
|
39
|
+
"what": "United States federal executive agencies",
|
|
40
|
+
"hosts": [
|
|
41
|
+
{
|
|
42
|
+
"id": "achp",
|
|
43
|
+
"which": "https://www.achp.gov/",
|
|
44
|
+
"what": "Advisory Council on Historic Preservation (ACHP)"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"id": "agm",
|
|
48
|
+
"which": "https://www.usagm.gov/",
|
|
49
|
+
"what": "Agency for Global Media"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The `merge` utility finds all the `url` commands in a script (telling the browser what to visit), replaces them with one of the hosts in the batch, and outputs the modified script as a job. It then does the same with each of the other hosts in the batch.
|
|
56
|
+
|
|
57
|
+
To execute `merge`, you need to have three environment variables defined to tell `merge` where files are located. You can define the environment variables in the `.env` file. Here is an example:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
SCRIPTDIR=../testing/scripts
|
|
61
|
+
BATCHDIR=../testing/batches
|
|
62
|
+
JOBDIR=../testing/jobs
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
In this example, the script, batch, and job files are located in directories named `scripts`, `batches`, and `jobs` within `testing`, which is a sibling directory of the Testilo project directory.
|
|
66
|
+
|
|
67
|
+
The syntax of the `merge` statement is documented in `merge.js`.
|
|
68
|
+
|
|
69
|
+
Suppose that:
|
|
70
|
+
- The environment variables are defined as in the above example.
|
|
71
|
+
- There is a script file named `testall.json`.
|
|
72
|
+
- The above batch example is in a file named `usFedExec1.json`.
|
|
73
|
+
|
|
74
|
+
The statement `node merge testall usFedExec1 allFedExec` would tell Testilo to merge the batch `../testing/batches/usFedExec1.json` and the script `../testing/scripts/testall.json` into two job files and save those files in the directory `../testing/jobs/allFedExec`. Testilo will create any directories necessary to save the files there.
|
|
75
|
+
|
|
76
|
+
### `score`
|
|
15
77
|
|
|
16
|
-
|
|
78
|
+
Testaro performs tests and produces reports of test results. Testilo can add scores to those reports. In this way, each report can not only detail successes and failures of individual tests but also assign scores to those results and combine the partial scores into total scores.
|
|
17
79
|
|
|
18
|
-
|
|
80
|
+
The `score` utility performs scoring. It depends on score procs to define the scoring rules. Some score procs are in the Testilo package (in the `procs/score` directory), and you can create more score procs to implement different rules.
|
|
19
81
|
|
|
20
|
-
|
|
82
|
+
You can score multiple reports with a single invocation of `score`.
|
|
21
83
|
|
|
22
|
-
|
|
84
|
+
To execute `score`, you need to have two environment variables defined to tell `score` where files are located. You can define the environment variables in the `.env` file. Here is an example:
|
|
23
85
|
|
|
24
|
-
|
|
86
|
+
```
|
|
87
|
+
REPORTDIR_RAW=../testing/reports/raw
|
|
88
|
+
REPORTDIR_SCORED=../testing/reports/scored
|
|
89
|
+
```
|
|
25
90
|
|
|
26
|
-
|
|
91
|
+
The named directories must already exist.
|
|
27
92
|
|
|
28
|
-
|
|
93
|
+
The syntax of the `score` statement is documented in `score.js`.
|
|
29
94
|
|
|
30
|
-
|
|
95
|
+
A scored report file is identical to the file it was created from, except that the scored report has new properties named `score` and `scoreProcID`. The `score` property contains the scores.
|
|
31
96
|
|
|
32
|
-
|
|
33
|
-
- The score proc is compatible with the script (or _test proc_) that produced the report(s).
|
|
34
|
-
- You have defined environment variables `REPORTDIR_RAW` and (for the scored reports that Testilo will write) `REPORTDIR_SCORED`.
|
|
97
|
+
### `digest`
|
|
35
98
|
|
|
36
|
-
|
|
99
|
+
Testaro reports, both originally and after they are scored, are JSON files. That format is basically designed for machine tractability.
|
|
37
100
|
|
|
38
|
-
|
|
101
|
+
The `digest` utility converts scored reports into HTML documents with explanatory content. Thus, it converts machine-oriented reports into human-oriented reports, called _digests_. It depends on digest procs to define the digesting rules. Some digest procs are in the Testilo package (in the `procs/digest` directory), and you can create more digest procs to implement different rules.
|
|
39
102
|
|
|
40
|
-
|
|
103
|
+
You can digest multiple scored reports with a single invocation of `digest`.
|
|
41
104
|
|
|
42
|
-
|
|
105
|
+
To execute `digest`, you need to have two environment variables defined to tell `digest` where files are located. You can define the environment variables in the `.env` file. Here is an example:
|
|
43
106
|
|
|
44
|
-
|
|
107
|
+
```
|
|
108
|
+
REPORTDIR_SCORED=../testing/reports/scored
|
|
109
|
+
REPORTDIR_DIGESTED=../testing/reports/digested
|
|
110
|
+
```
|
|
45
111
|
|
|
46
|
-
The
|
|
112
|
+
The named directories must already exist.
|
|
47
113
|
|
|
48
|
-
|
|
114
|
+
The syntax of the `digest` statement is documented in `digest.js`.
|
|
49
115
|
|
|
50
|
-
|
|
116
|
+
The digests created by `digest` are HTML files, and they expect a `style.css` file to exist in their directory. The `reports/digested/style.css` file in Testilo is an appropriate stylesheet to be copied into `process.env.REPORTDIR_DIGESTED`.
|
|
51
117
|
|
|
52
|
-
###
|
|
118
|
+
### `compare`
|
|
53
119
|
|
|
54
|
-
|
|
120
|
+
You can summarize the results of a multi-host job by producing a document comparing the scores received by the hosts. The `compare` utility does this.
|
|
55
121
|
|
|
56
|
-
|
|
122
|
+
The `compare` utility gathers scores from a set of scored reports and produces an HTML document comparing the scores. It depends on compare procs to define the rules for making and showing the comparative scores. Some compare procs are in the Testilo package (in the `procs/compare` directory), and you can create more compare procs to implement different rules.
|
|
57
123
|
|
|
58
|
-
|
|
124
|
+
To execute `compare`, you need to have two environment variables defined to tell `digest` where files are located. You can define the environment variables in the `.env` file. Here is an example:
|
|
59
125
|
|
|
60
|
-
|
|
126
|
+
```
|
|
127
|
+
REPORTDIR_SCORED=../testing/reports/scored
|
|
128
|
+
COMPARISONDIR=../testing/reports/compared
|
|
129
|
+
```
|
|
61
130
|
|
|
62
|
-
|
|
131
|
+
The named directories must already exist.
|
|
63
132
|
|
|
64
|
-
|
|
133
|
+
The syntax of the `compare` statement is documented in `compare.js`.
|
|
65
134
|
|
|
66
|
-
|
|
67
|
-
- The comparison proc is compatible with the score proc that scored the report.
|
|
68
|
-
- Testilo can find the scored report files in the directory whose relative path (relative to the project directory of Testilo) is the value of the `REPORTDIR_SCORED` environment variable.
|
|
69
|
-
- Testilo can read in the `REPORTDIR_SCORED` directory.
|
|
70
|
-
- There is a `COMPARISONDIR` environment variable, whose value is the relative path of a directory that Testilo can write to.
|
|
71
|
-
- The `procs/compare` directory contains a subdirectory named `xyz`, which in turn contains files named `index.html` and `index.js`.
|
|
72
|
-
- You have copied the `reports/comparative/style.css` file into the `COMPARISONDIR` directory.
|
|
135
|
+
The comparisons created by `compare` are HTML files, and they expect a `style.css` file to exist in their directory. The `reports/comparative/style.css` file in Testilo is an appropriate stylesheet to be copied into `process.env.COMPARISONDIR`.
|
package/compare.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/*
|
|
2
2
|
compare.js
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Creates comparisons from scored reports.
|
|
4
|
+
Reads reports in process.env.REPORTDIR_SCORED and outputs into process.env.COMPARISONDIR.
|
|
5
|
+
Arguments:
|
|
6
|
+
0. Base of name of compare proc located in procs/compare.
|
|
7
|
+
1. Base of name of comparative report to be written.
|
|
8
|
+
Usage example: node compare cp18a usFedExec
|
|
9
|
+
Note: Compares all reports in process.env.REPORTDIR_SCORED (but not in its subdirectories).
|
|
5
10
|
*/
|
|
6
11
|
|
|
7
12
|
// ########## IMPORTS
|
package/digest.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
digest.js
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Creates digests from scored reports.
|
|
4
|
+
Reads reports in process.env.REPORTDIR_SCORED and outputs into process.env.REPORTDIR_DIGESTED.
|
|
5
|
+
Arguments:
|
|
6
|
+
0. Base of name of digest proc located in procs/digest.
|
|
7
|
+
1?. starting substring of names of reports in process.env.REPORTDIR_SCORED.
|
|
8
|
+
Usage examples:
|
|
9
|
+
node digest dp18a 35k1r (to digest all scored reports with names starting with 35k1r)
|
|
10
|
+
node digest dp18a (to digest all scored reports)
|
|
5
11
|
*/
|
|
6
12
|
|
|
7
13
|
// ########## IMPORTS
|
|
@@ -23,7 +29,7 @@ const reportIDStart = process.argv[3];
|
|
|
23
29
|
// Replaces the placeholders in content with eponymous query parameters.
|
|
24
30
|
const replaceHolders = (content, query) => content
|
|
25
31
|
.replace(/__([a-zA-Z]+)__/g, (ph, qp) => query[qp]);
|
|
26
|
-
// Creates
|
|
32
|
+
// Creates digests.
|
|
27
33
|
const digest = async () => {
|
|
28
34
|
const reportDirScoredAbs = `${__dirname}/${reportDirScored}`;
|
|
29
35
|
let reportFileNames = await fs.readdir(reportDirScoredAbs);
|
package/merge.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
merge.js
|
|
3
|
+
Merges a batch and a script to produce jobs.
|
|
4
|
+
Arguments:
|
|
5
|
+
0. base of name of script located in process.env.SCRIPTDIR.
|
|
6
|
+
1. base of name of batch located in process.env.BATCHDIR.
|
|
7
|
+
2. name of subdirectory of process.env.JOBDIR into which to write host scripts.
|
|
8
|
+
Usage example:
|
|
9
|
+
node merge tp18 weborgs tp18-weborgs-1
|
|
10
|
+
Note: The subdirectory for host scripts will be created if it does not exist.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// ########## IMPORTS
|
|
14
|
+
|
|
15
|
+
// Module to keep secrets.
|
|
16
|
+
require('dotenv').config();
|
|
17
|
+
// Module to read and write files.
|
|
18
|
+
const fs = require('fs/promises');
|
|
19
|
+
|
|
20
|
+
// ########## CONSTANTS
|
|
21
|
+
|
|
22
|
+
const scriptDir = process.env.SCRIPTDIR || 'scripts';
|
|
23
|
+
const batchDir = process.env.BATCHDIR || 'batches';
|
|
24
|
+
const jobDir = process.env.JOBDIR || 'jobs';
|
|
25
|
+
const scriptName = process.argv[2];
|
|
26
|
+
const batchName = process.argv[3];
|
|
27
|
+
const jobSubdir = process.argv[4];
|
|
28
|
+
|
|
29
|
+
// ########## FUNCTIONS
|
|
30
|
+
|
|
31
|
+
// Merges a batch into a script and writes host scripts.
|
|
32
|
+
const merge = async (script, batch, timeStamp, outDir) => {
|
|
33
|
+
await fs.mkdir(outDir, {recursive: true});
|
|
34
|
+
const {hosts} = batch;
|
|
35
|
+
// For each host in the batch:
|
|
36
|
+
const jobs = hosts.map(host => {
|
|
37
|
+
// Copy the script.
|
|
38
|
+
const newScript = JSON.parse(JSON.stringify(script));
|
|
39
|
+
// In the copy, make all url commands visit the host.
|
|
40
|
+
newScript.commands.forEach(command => {
|
|
41
|
+
if (command.type === 'url') {
|
|
42
|
+
command.which = host.which;
|
|
43
|
+
command.what = host.what;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
// Create a host script.
|
|
47
|
+
return {
|
|
48
|
+
id: `${timeStamp}-${host.id}`,
|
|
49
|
+
host,
|
|
50
|
+
script: newScript
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
// Write the host scripts.
|
|
54
|
+
for (const job of jobs) {
|
|
55
|
+
await fs.writeFile(`${outDir}/${job.id}.json`, JSON.stringify(job, null, 2));
|
|
56
|
+
};
|
|
57
|
+
console.log(`Merger completed. Count of jobs created: ${hosts.length}`);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// ########## OPERATION
|
|
61
|
+
|
|
62
|
+
fs.readFile(`${scriptDir}/${scriptName}.json`, 'utf8')
|
|
63
|
+
.then(scriptFile => {
|
|
64
|
+
fs.readFile(`${batchDir}/${batchName}.json`, 'utf8')
|
|
65
|
+
.then(async batchFile => {
|
|
66
|
+
const script = JSON.parse(scriptFile);
|
|
67
|
+
const batch = JSON.parse(batchFile);
|
|
68
|
+
const timeStamp = Math.floor((Date.now() - Date.UTC(2022, 1)) / 2000).toString(36);
|
|
69
|
+
const outDir = `${jobDir}/${jobSubdir}`;
|
|
70
|
+
await merge(script, batch, timeStamp, outDir);
|
|
71
|
+
});
|
|
72
|
+
});
|
package/package.json
CHANGED
package/score.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
2
|
score.js
|
|
3
|
-
|
|
3
|
+
Scores Testaro reports.
|
|
4
|
+
Reads reports in process.env.REPORTDIR_RAW and outputs into process.env.REPORTDIR_SCORED.
|
|
5
|
+
Arguments:
|
|
6
|
+
0. Base of name of score proc located in procs/score.
|
|
7
|
+
1?. Starting substring of names of reports in process.env.REPORTDIR_RAW.
|
|
4
8
|
Usage examples:
|
|
5
|
-
node score
|
|
6
|
-
node score
|
|
9
|
+
node score sp18a 35k1r (to score all reports with names starting with 35k1r)
|
|
10
|
+
node score sp18a (to score all reports)
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
13
|
// ########## IMPORTS
|