testilo 12.0.3 → 12.1.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 CHANGED
@@ -64,6 +64,7 @@ Targets can be specified in a more complex way, too. That allows you to create j
64
64
  targets: [
65
65
  {
66
66
  id: 'acme',
67
+ which: 'https://acmeclothes.com/',
67
68
  what: 'Acme Clothes',
68
69
  acts: {
69
70
  public: [
@@ -189,6 +190,49 @@ The `call` module will retrieve the named target list.
189
190
  The `batch` module will convert the target list to a batch.
190
191
  The `call` module will save the batch as a JSON file in the `batches` subdirectory of the `process.env.SPECDIR` directory.
191
192
 
193
+ ### Issues to script
194
+
195
+ Testilo classifies issues. The built-in issue classifications are located in the `procs/score` directory, in files whose names begin with `tic` (for “Testilo issue classification”). You can create additional `tic` files with custom issue classifications.
196
+
197
+ If you want Testaro to test targets for particular issues, you can name those issues and use the Testilo `script` module to create a script.
198
+
199
+ #### Invocation
200
+
201
+ There are two ways to use the `script` module.
202
+
203
+ ##### By a module
204
+
205
+ A module can invoke `script` in this way:
206
+
207
+ ```javaScript
208
+ const {script} = require('testilo/script');
209
+ const scriptObj = script(scriptID, issueClasses, issueID0, issueID1, …);
210
+ ```
211
+
212
+ This invocation references `scriptID`, `issueClasses`, and `issueID` variables.
213
+ - The `scriptID` variable is an alphanumeric string.
214
+ - The `issueClasses` variable is an object that classifies issues, such as the `issueClasses` object in a `tic` file.
215
+ - The `issueID` variables are strings, such as `'regionNoText'`, that name of properties of the `issueClasses` object.
216
+
217
+ The `script()` function of the `script` module generates a script and returns it as an object. The invoking module can further dispose of the script as needed.
218
+
219
+ ##### By a user
220
+
221
+ A user can invoke `script` in this way: In the Testilo project directory, execute the statement `node call script s c i0 i1 i2 i3 …`.
222
+
223
+ In this statement:
224
+ - Replace `s` with an ID for the script, such as `headings`.
225
+ - Replace `c` with the base name, such as `tic99`, of an issue classification file in the `score` subdirectory of the `process.env.FUNCTIONDIR` directory.
226
+ - Replace the remaining arguments (`i0` etc.) with issue IDs from that classification file.
227
+
228
+ The `call` module will retrieve the named classification from its directory.
229
+ The `script` module will create a script.
230
+ The `call` module will save the script as a JSON file in the `scripts` subdirectory of the `process.env.SPECDIR` directory.
231
+
232
+ #### Options
233
+
234
+ When the `script` module creates a script for you, it does not ask you for all of the options that the script may require. Instead, it chooses options. After you invoke `script`, you can edit the script that it creates to revise options.
235
+
192
236
  ### Merge
193
237
 
194
238
  Testilo merges batches with scripts, producing jobs, by means of the `merge` module.
@@ -324,49 +368,6 @@ The `call` module will save the jobs as JSON files in the `todo` subdirectory of
324
368
 
325
369
  To test the `merge` module, in the project directory you can execute the statement `node validation/merge/validate`. If `merge` is valid, all logging statements will begin with “Success” and none will begin with “ERROR”.
326
370
 
327
- ### Issues to script
328
-
329
- Testilo classifies issues. The built-in issue classifications are located in the `procs/score` directory, in files whose names begin with `tic` (for “Testilo issue classification”). You can create additional `tic` files with custom issue classifications.
330
-
331
- If you want Testaro to test targets for particular issues, you can name those issues and use the Testilo `script` module to create a script.
332
-
333
- #### Invocation
334
-
335
- There are two ways to use the `script` module.
336
-
337
- ##### By a module
338
-
339
- A module can invoke `script` in this way:
340
-
341
- ```javaScript
342
- const {script} = require('testilo/script');
343
- const scriptObj = script(scriptID, issueClasses, issueID0, issueID1, …);
344
- ```
345
-
346
- This invocation references `scriptID`, `issueClasses`, and `issueID` variables.
347
- - The `scriptID` variable is an alphanumeric string.
348
- - The `issueClasses` variable is an object that classifies issues, such as the `issueClasses` object in a `tic` file.
349
- - The `issueID` variables are strings, such as `'regionNoText'`, that name of properties of the `issueClasses` object.
350
-
351
- The `script()` function of the `script` module generates a script and returns it as an object. The invoking module can further dispose of the script as needed.
352
-
353
- ##### By a user
354
-
355
- A user can invoke `script` in this way: In the Testilo project directory, execute the statement `node call script s c i0 i1 i2 i3 …`.
356
-
357
- In this statement:
358
- - Replace `s` with an ID for the script, such as `headings`.
359
- - Replace `c` with the base name, such as `tic99`, of an issue classification file in the `score` subdirectory of the `process.env.FUNCTIONDIR` directory.
360
- - Replace the remaining arguments (`i0` etc.) with issue IDs from that classification file.
361
-
362
- The `call` module will retrieve the named classification from its directory.
363
- The `script` module will create a script.
364
- The `call` module will save the script as a JSON file in the `scripts` subdirectory of the `process.env.SPECDIR` directory.
365
-
366
- #### Options
367
-
368
- When the `script` module creates a script for you, it does not ask you for all of the options that the script may require. Instead, it chooses options. After you invoke `script`, you can edit the script that it creates to revise options.
369
-
370
371
  ## Report scoring
371
372
 
372
373
  ### Introduction
package/batch.js CHANGED
@@ -33,10 +33,11 @@ exports.batch = (id, what, targetList) => {
33
33
  };
34
34
  // For each valid target:
35
35
  targetList.forEach(target => {
36
- if (target.length === 3) {
36
+ if (target.length === 3 && target.every(item => item.length)) {
37
37
  // Add it to the batch.
38
38
  batch.targets.push({
39
39
  id: target[0],
40
+ which: target[2],
40
41
  what: target[1],
41
42
  acts: {
42
43
  main: [
package/merge.js CHANGED
@@ -51,6 +51,7 @@ exports.merge = (script, batch, requester, isolate = false) => {
51
51
  batch: batch.id,
52
52
  target: {
53
53
  id: '',
54
+ which: '',
54
55
  what: ''
55
56
  },
56
57
  requester
@@ -87,43 +88,51 @@ exports.merge = (script, batch, requester, isolate = false) => {
87
88
  // For each target in the batch:
88
89
  const {targets} = batch;
89
90
  for (const target of targets) {
90
- // Initialize a job.
91
- const job = JSON.parse(JSON.stringify(protoJob));
92
- // Add the target ID to the job ID.
93
- job.id += target.id;
94
- // Add data on the target to the sources property of the job.
95
- job.sources.target.id = target.id;
96
- job.sources.target.what = target.what;
97
- // Replace each placeholder object in the job with the named replacer array of the target.
98
- let {acts} = job;
99
- for (const actIndex in acts) {
100
- const act = acts[actIndex];
101
- if (act.type === 'placeholder') {
102
- const replacerName = act.which;
103
- if (replacerName && target.acts) {
104
- let replacerActs = target.acts[replacerName];
105
- if (replacerActs) {
106
- // Add a which property to any launch act in the replacer.
107
- replacerActs = JSON.parse(JSON.stringify(replacerActs));
108
- for (const replacerAct of replacerActs) {
109
- if (replacerAct.type === 'launch') {
110
- replacerAct.which = act.launch;
91
+ // If the target has the required identifiers:
92
+ const {id, which, what} = target;
93
+ if (id && which && what) {
94
+ // Initialize a job.
95
+ const job = JSON.parse(JSON.stringify(protoJob));
96
+ // Append the target ID to the job ID.
97
+ job.id += target.id;
98
+ // Add data on the target to the sources property of the job.
99
+ job.sources.target.id = target.id;
100
+ job.sources.target.which = target.which;
101
+ job.sources.target.what = target.what;
102
+ // Replace each placeholder object in the job with the named replacer array of the target.
103
+ let {acts} = job;
104
+ for (const actIndex in acts) {
105
+ const act = acts[actIndex];
106
+ if (act.type === 'placeholder') {
107
+ const replacerName = act.which;
108
+ if (replacerName && target.acts) {
109
+ let replacerActs = target.acts[replacerName];
110
+ if (replacerActs) {
111
+ // Add a which property to any launch act in the replacer.
112
+ replacerActs = JSON.parse(JSON.stringify(replacerActs));
113
+ for (const replacerAct of replacerActs) {
114
+ if (replacerAct.type === 'launch') {
115
+ replacerAct.which = act.launch;
116
+ }
111
117
  }
118
+ acts[actIndex] = replacerActs;
119
+ }
120
+ else {
121
+ console.log(`ERROR: Target ${target.id} has no ${replacerName} replacer`);
112
122
  }
113
- acts[actIndex] = replacerActs;
114
123
  }
115
124
  else {
116
- console.log(`ERROR: Target ${target.id} has no ${replacerName} replacer`);
125
+ console.log(`ERROR: Placeholder for target ${target.id} not replaceable`);
117
126
  }
118
127
  }
119
- else {
120
- console.log(`ERROR: Placeholder for target ${target.id} not replaceable`);
121
- }
122
128
  }
129
+ job.acts = acts.flat();
130
+ // Append the job to the array of jobs.
131
+ jobs.push(job);
132
+ }
133
+ else {
134
+ console.log('ERROR: Target in batch missing id, which, or what property');
123
135
  }
124
- job.acts = acts.flat();
125
- // Append the job to the array of jobs.
126
- jobs.push(job);
127
136
  };
128
137
  return jobs;
129
138
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "12.0.3",
3
+ "version": "12.1.0",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {
package/script.js CHANGED
@@ -88,6 +88,11 @@ exports.script = (id, issueClasses, ... issueIDs) => {
88
88
  which: toolID,
89
89
  rules: neededTools[toolID]
90
90
  };
91
+ // If the tool is Testaro:
92
+ if (toolID === 'testaro') {
93
+ // Prepend the inclusion option to the rule array.
94
+ toolAct.rules.unshift('y');
95
+ }
91
96
  // Add option specifications if necessary.
92
97
  if (toolID === 'axe') {
93
98
  toolAct.detailLevel = 2;