testaro 4.2.5 → 4.2.6
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/package.json +1 -1
- package/samples/scripts/alfa.json +22 -0
- package/samples/scripts/ibm.json +23 -0
- package/tests/ibm.js +16 -14
package/package.json
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "alfa",
|
|
3
|
+
"what": "Alfa test package",
|
|
4
|
+
"strict": true,
|
|
5
|
+
"commands": [
|
|
6
|
+
{
|
|
7
|
+
"type": "launch",
|
|
8
|
+
"which": "chromium",
|
|
9
|
+
"what": "used for most tests"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"type": "url",
|
|
13
|
+
"which": "https://*",
|
|
14
|
+
"what": "any page"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "test",
|
|
18
|
+
"which": "alfa",
|
|
19
|
+
"what": "Siteimprove alfa"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "ibm",
|
|
3
|
+
"what": "IBM Equal Access test package",
|
|
4
|
+
"strict": true,
|
|
5
|
+
"commands": [
|
|
6
|
+
{
|
|
7
|
+
"type": "launch",
|
|
8
|
+
"which": "chromium",
|
|
9
|
+
"what": "used for most tests"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"type": "url",
|
|
13
|
+
"which": "https://*",
|
|
14
|
+
"what": "any page"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"type": "test",
|
|
18
|
+
"which": "ibm",
|
|
19
|
+
"withItems": true,
|
|
20
|
+
"what": "IBM Equal Access"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
package/tests/ibm.js
CHANGED
|
@@ -24,18 +24,18 @@ const {getCompliance} = require('accessibility-checker');
|
|
|
24
24
|
const run = async content => {
|
|
25
25
|
const nowLabel = (new Date()).toISOString().slice(0, 19);
|
|
26
26
|
// Return the result of a test.
|
|
27
|
-
const
|
|
28
|
-
return
|
|
27
|
+
const ibmReport = await getCompliance(content, nowLabel);
|
|
28
|
+
return ibmReport;
|
|
29
29
|
};
|
|
30
|
-
//
|
|
31
|
-
const report = (
|
|
30
|
+
// Trims an IBM report.
|
|
31
|
+
const report = (ibmReport, withItems) => {
|
|
32
32
|
const data = {};
|
|
33
|
-
if (
|
|
34
|
-
const totals =
|
|
33
|
+
if (ibmReport && ibmReport.report && ibmReport.report.summary) {
|
|
34
|
+
const totals = ibmReport.report.summary.counts;
|
|
35
35
|
if (totals) {
|
|
36
36
|
data.totals = totals;
|
|
37
37
|
if (withItems) {
|
|
38
|
-
data.items =
|
|
38
|
+
data.items = ibmReport.report.results;
|
|
39
39
|
data.items.forEach(item => {
|
|
40
40
|
delete item.apiArgs;
|
|
41
41
|
delete item.category;
|
|
@@ -62,13 +62,13 @@ const doTest = async (content, withItems, timeLimit) => {
|
|
|
62
62
|
let timeoutID;
|
|
63
63
|
const wait = new Promise(resolve => {
|
|
64
64
|
timeoutID = setTimeout(() => {
|
|
65
|
-
resolve(
|
|
65
|
+
resolve({});
|
|
66
66
|
}, 1000 * timeLimit);
|
|
67
67
|
});
|
|
68
68
|
// Conduct and report the test.
|
|
69
|
-
const
|
|
69
|
+
const ibmReport = run(content);
|
|
70
70
|
// Wait for the report until the time limit expires.
|
|
71
|
-
const
|
|
71
|
+
const ibmReportIfFast = await Promise.race([ibmReport, wait]);
|
|
72
72
|
// Delete the report files.
|
|
73
73
|
try {
|
|
74
74
|
const reportNames = await fs.readdir('results');
|
|
@@ -80,14 +80,16 @@ const doTest = async (content, withItems, timeLimit) => {
|
|
|
80
80
|
console.log('ibm test created no result files.');
|
|
81
81
|
}
|
|
82
82
|
// Return the result.
|
|
83
|
-
if (
|
|
83
|
+
if (ibmReportIfFast.report) {
|
|
84
84
|
clearTimeout(timeoutID);
|
|
85
|
-
const
|
|
86
|
-
return
|
|
85
|
+
const ibmTypeReport = report(ibmReportIfFast, withItems);
|
|
86
|
+
return ibmTypeReport;
|
|
87
87
|
}
|
|
88
88
|
else {
|
|
89
89
|
console.log('ERROR: getting ibm test report took too long');
|
|
90
|
-
return
|
|
90
|
+
return {
|
|
91
|
+
error: 'ERROR: getting ibm test report took too long'
|
|
92
|
+
};
|
|
91
93
|
}
|
|
92
94
|
};
|
|
93
95
|
// Returns results of one or two IBM tests.
|