testilo 3.13.0 → 4.0.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/README.md +112 -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,147 @@
|
|
|
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 package](https://www.npmjs.com/package/testaro).
|
|
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.
|
|
7
9
|
|
|
8
10
|
## Dependencies
|
|
9
11
|
|
|
10
|
-
The `dotenv` dependency lets you set environment variables in an untracked `.env` file.
|
|
12
|
+
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
13
|
|
|
12
14
|
## Architecture
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
Testilo is written in Node.js. Commands are given to Testilo in a command-line (terminal) interface or programmatically.
|
|
17
|
+
|
|
18
|
+
Shared routines that perform scoring, digesting, and comparing are _procs_ and are located in the `procs` directory.
|
|
19
|
+
|
|
20
|
+
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.
|
|
21
|
+
|
|
22
|
+
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.
|
|
23
|
+
|
|
24
|
+
## Utilities
|
|
25
|
+
|
|
26
|
+
### `merge`
|
|
27
|
+
|
|
28
|
+
Testaro runs _jobs_. A job gives Testaro instructions.
|
|
29
|
+
|
|
30
|
+
Sometimes you may want Testaro to perform a set of tests on multiple targets. The `merge` utility in Testilo facilitates this. It creates Testaro jobs out of a _script_ and a _batch_.
|
|
31
|
+
|
|
32
|
+
A script tells Testaro where to go and what to do. If the where-to-go part identifies a specific URL, the script can be a job, ready for Testaro to run. But the where-to-go part can also be generic, such as `http://*.*`. Then the script needs to be converted to a job by having its generic destination replaced with a specific URL. A batch is a list of _hosts_ (URLs and metadata). Merging a batch and a script means generating from the script as many jobs as there are hosts in the batch. In each job, one host from the batch becomes the specific target.
|
|
33
|
+
|
|
34
|
+
A script is a JSON file representing a `script` object, which contains a sequence of _commands_. Scripts are documented in detail in the Testaro `README.md` file.
|
|
35
|
+
|
|
36
|
+
A batch is a JSON file representing a `batch` object, which contains an array of _hosts_. Each host is an object with three properties:
|
|
37
|
+
- `id`: a string unique in the batch
|
|
38
|
+
- `which`: a URL
|
|
39
|
+
- `what`: a string naming the entity associated with the URL
|
|
40
|
+
|
|
41
|
+
The batch as a whole also has three properties:
|
|
42
|
+
- `id`: a string composed of ASCII letters and digits
|
|
43
|
+
- `what`: a string describing the batch
|
|
44
|
+
- `hosts`: an array of host objects
|
|
45
|
+
|
|
46
|
+
Here is an example of a batch:
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"id": "usFedExec1",
|
|
51
|
+
"what": "United States federal executive agencies",
|
|
52
|
+
"hosts": [
|
|
53
|
+
{
|
|
54
|
+
"id": "achp",
|
|
55
|
+
"which": "https://www.achp.gov/",
|
|
56
|
+
"what": "Advisory Council on Historic Preservation (ACHP)"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"id": "agm",
|
|
60
|
+
"which": "https://www.usagm.gov/",
|
|
61
|
+
"what": "Agency for Global Media"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
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.
|
|
68
|
+
|
|
69
|
+
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:
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
SCRIPTDIR=../testing/scripts
|
|
73
|
+
BATCHDIR=../testing/batches
|
|
74
|
+
JOBDIR=../testing/jobs
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
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.
|
|
78
|
+
|
|
79
|
+
The syntax of the `merge` statement is documented in `merge.js`.
|
|
80
|
+
|
|
81
|
+
Suppose that:
|
|
82
|
+
- The environment variables are defined as in the above example.
|
|
83
|
+
- There is a script file named `testall.json`.
|
|
84
|
+
- The above batch example is in a file named `usFedExec1.json`.
|
|
85
|
+
|
|
86
|
+
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` and write the two job files in `../testing/jobs/allFedExec`.
|
|
87
|
+
|
|
88
|
+
### `score`
|
|
15
89
|
|
|
16
|
-
|
|
90
|
+
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
91
|
|
|
18
|
-
|
|
92
|
+
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
93
|
|
|
20
|
-
|
|
94
|
+
You can score multiple reports with a single invocation of `score`.
|
|
21
95
|
|
|
22
|
-
|
|
96
|
+
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
97
|
|
|
24
|
-
|
|
98
|
+
```
|
|
99
|
+
REPORTDIR_RAW=../testing/reports/raw
|
|
100
|
+
REPORTDIR_SCORED=../testing/reports/scored
|
|
101
|
+
```
|
|
25
102
|
|
|
26
|
-
|
|
103
|
+
The named directories must already exist.
|
|
27
104
|
|
|
28
|
-
|
|
105
|
+
The syntax of the `score` statement is documented in `score.js`.
|
|
29
106
|
|
|
30
|
-
|
|
107
|
+
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
108
|
|
|
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`.
|
|
109
|
+
### `digest`
|
|
35
110
|
|
|
36
|
-
|
|
111
|
+
Testaro reports, both originally and after they are scored, are JSON files. That format is basically designed for machine tractability.
|
|
37
112
|
|
|
38
|
-
|
|
113
|
+
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
114
|
|
|
40
|
-
|
|
115
|
+
You can digest multiple scored reports with a single invocation of `digest`.
|
|
41
116
|
|
|
42
|
-
|
|
117
|
+
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
118
|
|
|
44
|
-
|
|
119
|
+
```
|
|
120
|
+
REPORTDIR_SCORED=../testing/reports/scored
|
|
121
|
+
REPORTDIR_DIGESTED=../testing/reports/digested
|
|
122
|
+
```
|
|
45
123
|
|
|
46
|
-
The
|
|
124
|
+
The named directories must already exist.
|
|
47
125
|
|
|
48
|
-
|
|
126
|
+
The syntax of the `digest` statement is documented in `digest.js`.
|
|
49
127
|
|
|
50
|
-
|
|
128
|
+
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
129
|
|
|
52
|
-
###
|
|
130
|
+
### `compare`
|
|
53
131
|
|
|
54
|
-
|
|
132
|
+
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
133
|
|
|
56
|
-
|
|
134
|
+
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
135
|
|
|
58
|
-
|
|
136
|
+
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
137
|
|
|
60
|
-
|
|
138
|
+
```
|
|
139
|
+
REPORTDIR_SCORED=../testing/reports/scored
|
|
140
|
+
COMPARISONDIR=../testing/reports/compared
|
|
141
|
+
```
|
|
61
142
|
|
|
62
|
-
|
|
143
|
+
The named directories must already exist.
|
|
63
144
|
|
|
64
|
-
|
|
145
|
+
The syntax of the `compare` statement is documented in `compare.js`.
|
|
65
146
|
|
|
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.
|
|
147
|
+
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
|