testilo 2.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/LICENSE +21 -0
- package/README.md +85 -0
- package/aceconfig.js +6 -0
- package/index.js +87 -0
- package/package.json +26 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Jonathan Pool
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# testilo
|
|
2
|
+
Runner of Testaro tests
|
|
3
|
+
|
|
4
|
+
## Introduction
|
|
5
|
+
|
|
6
|
+
This application is designed to be installed on a Windows or Macintosh host and to operate as a runner of Testaro jobs.
|
|
7
|
+
|
|
8
|
+
[Testaro](https://www.npmjs.com/package/testaro) is a dependency that performs digital accessibility tests on Web resources.
|
|
9
|
+
|
|
10
|
+
## Dependencies
|
|
11
|
+
|
|
12
|
+
The Testaro dependency has some dependencies in the @siteimprove scope that are Github Packages. In order to execute `npm install` successfully, you need the `.npmrc` file in your project directory with this content, unless an `.npmrc` file in your home directory or elsewhere provides the same content:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
@siteimprove:registry=https://npm.pkg.github.com
|
|
16
|
+
//npm.pkg.github.com/:username=abc
|
|
17
|
+
//npm.pkg.github.com/:_authToken=def
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
In this content, replace `abc` with your Github username and `def` with a Github personal access token that has `read:packages` scope.
|
|
21
|
+
|
|
22
|
+
## Operation
|
|
23
|
+
|
|
24
|
+
### General
|
|
25
|
+
|
|
26
|
+
Testilo orders a Testaro job by calling Testaro’s `handleRequest` function with an object argument. The argument has this structure:
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
{
|
|
30
|
+
id,
|
|
31
|
+
script: {…},
|
|
32
|
+
log: [],
|
|
33
|
+
acts: []
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The `script` property has a Testaro script as its value. See the Testaro `README.md` file for documentation on scripts.
|
|
38
|
+
|
|
39
|
+
If a script is represented as JSON in a file `scripts/scriptX.json`, you can incorporate it into the options object of a Testaro call by executing the statement
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
node index scriptX
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Batches
|
|
46
|
+
|
|
47
|
+
You may wish to have Testaro perform the same sequence of tests on multiple web pages. In that case, you can create a _batch_, with the following structure:
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
{
|
|
51
|
+
what: 'Web leaders',
|
|
52
|
+
hosts: {
|
|
53
|
+
id: 'w3c',
|
|
54
|
+
which: 'https://www.w3.org/',
|
|
55
|
+
what: 'W3C'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'wikimedia',
|
|
59
|
+
which: 'https://www.wikimedia.org/',
|
|
60
|
+
what: 'Wikimedia'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
With a batch, you can execute a single statement to call Testaro multiple times, one per host. On each call, Testilo takes one of the hosts in the batch and substitutes it for each host specified in a `url` command of the script. Testilo waits for each Testaro job to finish before calling the next Testaro job.
|
|
66
|
+
|
|
67
|
+
If a batch is represented as a JSON file `batches/batchY.json`, you can use it to call a set of Testaro jobs with the statement
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
node index scriptX batchY
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Given that statement, Testilo replaces the hosts in the script with the first host in the batch and calls Testaro. When Testaro finishes performing that script, Testilo replaces the script hosts with the second batch host and calls Testaro again. And so on.
|
|
74
|
+
|
|
75
|
+
### Reports
|
|
76
|
+
|
|
77
|
+
When you execute a `node index …` statement, Testilo begins populating the object argument by giving its `id` property a value. If there is no batch, the value of that property is a string encoding the date and time when you executed the statement (e.g., `eh9q7r`). If there is a batch, the value is the same, except that it is suffixed with a hyphen-minus character followed by the `id` value of the host (e.g., `eh9q7r-wikimedia`).
|
|
78
|
+
|
|
79
|
+
Testaro delivers its results by populating the `log` and `acts` arrays of the object argument. Testilo waits for Testaro to finish performing the script and then saves the object argument in JSON format as a file in the `reports` directory.
|
|
80
|
+
|
|
81
|
+
## Configuration
|
|
82
|
+
|
|
83
|
+
### `ibm` test
|
|
84
|
+
|
|
85
|
+
Testaro can perform the `ibm` test. That test requires the `aceconfig.js` configuration file in the root directory of the Testilo project.
|
package/aceconfig.js
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
index.js
|
|
3
|
+
Testilo main script.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ########## IMPORTS
|
|
7
|
+
|
|
8
|
+
// Module to perform tests.
|
|
9
|
+
const {handleRequest} = require('testaro');
|
|
10
|
+
const fs = require('fs').promises;
|
|
11
|
+
|
|
12
|
+
// ########## FUNCTIONS
|
|
13
|
+
|
|
14
|
+
// Converts a script to a batch-based array of scripts.
|
|
15
|
+
const batchify = (script, batch, timeStamp) => {
|
|
16
|
+
const {hosts} = batch;
|
|
17
|
+
const specs = hosts.map(host => {
|
|
18
|
+
const newScript = JSON.parse(JSON.stringify(script));
|
|
19
|
+
newScript.commands.forEach(command => {
|
|
20
|
+
if (command.type === 'url') {
|
|
21
|
+
command.which = host.which;
|
|
22
|
+
command.what = host.what;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const spec = {
|
|
26
|
+
id: `${timeStamp}-${host.id}`,
|
|
27
|
+
script: newScript
|
|
28
|
+
};
|
|
29
|
+
return spec;
|
|
30
|
+
});
|
|
31
|
+
return specs;
|
|
32
|
+
};
|
|
33
|
+
// Calls Testaro.
|
|
34
|
+
const callTestaro = async (id, script) => {
|
|
35
|
+
const report = {
|
|
36
|
+
id,
|
|
37
|
+
log: [],
|
|
38
|
+
script,
|
|
39
|
+
acts: []
|
|
40
|
+
};
|
|
41
|
+
await handleRequest(report);
|
|
42
|
+
const reportJSON = JSON.stringify(report, null, 2);
|
|
43
|
+
await fs.writeFile(`reports/${id}.json`, reportJSON);
|
|
44
|
+
};
|
|
45
|
+
// Runs a job.
|
|
46
|
+
const run = async () => {
|
|
47
|
+
const scriptName = process.argv[2];
|
|
48
|
+
const batchName = process.argv[3];
|
|
49
|
+
if (scriptName) {
|
|
50
|
+
try {
|
|
51
|
+
const scriptJSON = await fs.readFile(`scripts/${scriptName}.json`, 'utf8');
|
|
52
|
+
const script = JSON.parse(scriptJSON);
|
|
53
|
+
let batch = null;
|
|
54
|
+
// Identify the start time and a timestamp.
|
|
55
|
+
const timeStamp = Math.floor((Date.now() - Date.UTC(2022, 1)) / 2000).toString(36);
|
|
56
|
+
// If there is a batch:
|
|
57
|
+
if (batchName) {
|
|
58
|
+
// Convert the script to a batch-based set of scripts.
|
|
59
|
+
const batchJSON = await fs.readFile(`batches/${batchName}.json`, 'utf8');
|
|
60
|
+
batch = JSON.parse(batchJSON);
|
|
61
|
+
const specs = batchify(script, batch, timeStamp);
|
|
62
|
+
// For each script:
|
|
63
|
+
while (specs.length) {
|
|
64
|
+
const spec = specs.shift();
|
|
65
|
+
const {id, script} = spec;
|
|
66
|
+
// Call Testaro on it and save the result with a host-suffixed ID.
|
|
67
|
+
await callTestaro(id, script);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Otherwise, i.e. if there is no batch:
|
|
71
|
+
else {
|
|
72
|
+
// Call Testaro on the script and save the result with a timestamp ID.
|
|
73
|
+
await callTestaro(timeStamp, script);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch(error) {
|
|
77
|
+
console.log(`ERROR: ${error.message}\n${error.stack}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
console.log('ERROR: no script specified');
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
// ########## OPERATION
|
|
86
|
+
|
|
87
|
+
run();
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "testilo",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Client that runs Testaro tests to fulfill Aorta jobs",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/jrpool/testilo"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["accessibility", "a11y", "testing"],
|
|
14
|
+
"author": "Jonathan Pool <pool@jpdev.pro>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/jrpool/testilo/issues"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/jrpool/testilo",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"testaro": "*"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"eslint": "*"
|
|
25
|
+
}
|
|
26
|
+
}
|