testilo 12.2.2 → 12.3.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/call.js +6 -4
- package/package.json +1 -1
- package/script.js +60 -47
package/call.js
CHANGED
|
@@ -55,9 +55,11 @@ const callBatch = async (listID, what) => {
|
|
|
55
55
|
console.log(`Target list ${listID} converted to a batch and saved in ${specDir}/batches`);
|
|
56
56
|
};
|
|
57
57
|
// Fulfills a script-creation request.
|
|
58
|
-
const callScript = async (scriptID, classificationID, ... issueIDs) => {
|
|
59
|
-
// Get
|
|
60
|
-
const
|
|
58
|
+
const callScript = async (scriptID, classificationID = null, ... issueIDs) => {
|
|
59
|
+
// Get any issue classification.
|
|
60
|
+
const issueClasses = classificationID
|
|
61
|
+
? require(`${functionDir}/score/${classificationID}`)
|
|
62
|
+
: null;
|
|
61
63
|
// Create a script.
|
|
62
64
|
const scriptObj = script(scriptID, issueClasses, ... issueIDs);
|
|
63
65
|
// Save the script.
|
|
@@ -176,7 +178,7 @@ else if (fn === 'batch' && fnArgs.length === 2) {
|
|
|
176
178
|
console.log('Execution completed');
|
|
177
179
|
});
|
|
178
180
|
}
|
|
179
|
-
else if (fn === 'script' && fnArgs.length
|
|
181
|
+
else if (fn === 'script' && fnArgs.length) {
|
|
180
182
|
callScript(... fnArgs)
|
|
181
183
|
.then(() => {
|
|
182
184
|
console.log('Execution completed');
|
package/package.json
CHANGED
package/script.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
script.js
|
|
3
|
-
Creates and returns a script
|
|
3
|
+
Creates and returns a script.
|
|
4
4
|
Arguments:
|
|
5
5
|
0. issue classification
|
|
6
6
|
1. issue IDs
|
|
@@ -11,57 +11,66 @@
|
|
|
11
11
|
// Module to keep secrets.
|
|
12
12
|
require('dotenv').config();
|
|
13
13
|
|
|
14
|
+
// ########## VARIABLES
|
|
15
|
+
|
|
16
|
+
let toolIDs = [
|
|
17
|
+
'alfa', 'axe', 'continuum', 'htmlcs', 'ibm', 'nuVal', 'qualWeb', 'tenon', 'testaro', 'wave'
|
|
18
|
+
];
|
|
19
|
+
|
|
14
20
|
// ########## FUNCTIONS
|
|
15
21
|
|
|
16
22
|
// Creates and returns a script.
|
|
17
|
-
exports.script = (id, issueClasses, ... issueIDs) => {
|
|
18
|
-
// Initialize data on the
|
|
23
|
+
exports.script = (id, issueClasses = null, ... issueIDs) => {
|
|
24
|
+
// Initialize data on the tools and rules for the specified issues.
|
|
19
25
|
const neededTools = {};
|
|
20
|
-
//
|
|
21
|
-
issueIDs.
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
// If an issue classification and any issues were specified:
|
|
27
|
+
if (issueClasses && issueIDs.length) {
|
|
28
|
+
// For each specified issue:
|
|
29
|
+
issueIDs.forEach(issueID => {
|
|
30
|
+
// If it exists in the classification:
|
|
31
|
+
const issueData = issueClasses[issueID];
|
|
32
|
+
if (issueData) {
|
|
33
|
+
// For each tool that tests for the issue:
|
|
34
|
+
const issueToolIDs = Object.keys(issueData.tools);
|
|
35
|
+
issueToolIDs.forEach(issueToolID => {
|
|
36
|
+
// For each of the rules of the tool for the issue:
|
|
37
|
+
if (! neededTools[issueToolID]) {
|
|
38
|
+
neededTools[issueToolID] = [];
|
|
39
|
+
}
|
|
40
|
+
Object.keys(issueData.tools[issueToolID]).forEach(ruleID => {
|
|
41
|
+
// Add data on the rule.
|
|
42
|
+
const ruleData = issueData.tools[issueToolID][ruleID];
|
|
43
|
+
if (issueToolID === 'nuVal') {
|
|
44
|
+
if (ruleData.variable) {
|
|
45
|
+
neededTools[issueToolID].push(`~${ruleID}`);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
neededTools[issueToolID].push(`=${ruleID}`);
|
|
49
|
+
}
|
|
38
50
|
}
|
|
39
51
|
else {
|
|
40
|
-
neededTools[issueToolID].push(
|
|
52
|
+
neededTools[issueToolID].push(ruleID);
|
|
41
53
|
}
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
neededTools[issueToolID].push(ruleID);
|
|
45
|
-
}
|
|
54
|
+
});
|
|
46
55
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
toolIDs = Object.keys(neededTools);
|
|
57
|
+
}
|
|
58
|
+
// Otherwise, i.e. if it does not exist in the classification:
|
|
59
|
+
else {
|
|
60
|
+
// Report this.
|
|
61
|
+
console.log(`ERROR: Issue ${issueID} not in issue classification`);
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// If any rules have been identified:
|
|
58
67
|
if (toolIDs.length) {
|
|
59
68
|
// Initialize a script.
|
|
60
69
|
const scriptObj = {
|
|
61
70
|
id,
|
|
62
71
|
what: `accessibility tests`,
|
|
63
72
|
strict: true,
|
|
64
|
-
timeLimit: 30 +
|
|
73
|
+
timeLimit: 30 + (10 * issueIDs.length || 30 * toolIDs.length),
|
|
65
74
|
acts: [
|
|
66
75
|
{
|
|
67
76
|
"type": "placeholder",
|
|
@@ -77,7 +86,7 @@ exports.script = (id, issueClasses, ... issueIDs) => {
|
|
|
77
86
|
type: 'tenonRequest',
|
|
78
87
|
id: 'a',
|
|
79
88
|
withNewContent: false,
|
|
80
|
-
what: 'Tenon API version 2 test request, with
|
|
89
|
+
what: 'Tenon API version 2 test request, with page content'
|
|
81
90
|
});
|
|
82
91
|
}
|
|
83
92
|
// For each identified tool:
|
|
@@ -85,13 +94,17 @@ exports.script = (id, issueClasses, ... issueIDs) => {
|
|
|
85
94
|
// Initialize a test act for it.
|
|
86
95
|
const toolAct = {
|
|
87
96
|
type: 'test',
|
|
88
|
-
which: toolID
|
|
89
|
-
rules: neededTools[toolID]
|
|
97
|
+
which: toolID
|
|
90
98
|
};
|
|
91
|
-
// If
|
|
92
|
-
if (
|
|
93
|
-
//
|
|
94
|
-
toolAct.rules
|
|
99
|
+
// If rules were specified:
|
|
100
|
+
if (issueClasses && issueIDs.length) {
|
|
101
|
+
// Add a rules property to the act.
|
|
102
|
+
toolAct.rules = neededTools[toolID];
|
|
103
|
+
// If the tool is Testaro:
|
|
104
|
+
if (toolID === 'testaro') {
|
|
105
|
+
// Prepend the inclusion option to the rule array.
|
|
106
|
+
toolAct.rules.unshift('y');
|
|
107
|
+
}
|
|
95
108
|
}
|
|
96
109
|
// Add option specifications if necessary.
|
|
97
110
|
if (toolID === 'axe') {
|
|
@@ -119,10 +132,10 @@ exports.script = (id, issueClasses, ... issueIDs) => {
|
|
|
119
132
|
// Return the script.
|
|
120
133
|
return scriptObj;
|
|
121
134
|
}
|
|
122
|
-
// Otherwise, i.e. if no
|
|
135
|
+
// Otherwise, i.e. if no rules have been identified:
|
|
123
136
|
else {
|
|
124
137
|
// Report this.
|
|
125
|
-
console.log(`ERROR: No
|
|
138
|
+
console.log(`ERROR: No rules for the specified issues found`);
|
|
126
139
|
return {};
|
|
127
140
|
}
|
|
128
141
|
};
|