testilo 11.0.0 → 11.0.3

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
@@ -158,7 +158,36 @@ As shown in this example, when a browser is launched by placeholder substitution
158
158
 
159
159
  ### Target list to batch
160
160
 
161
- If you have a target list, Testilo can convert it to a batch. The batch will contain, for each target, one array of acts named `main`, containing a `launch` act (depending on the script to specify the browser type) and a `url` act.
161
+ If you have a target list, the `batch` module of Testilo can convert it to a batch. The batch will contain, for each target, one array of acts named `main`, containing a `launch` act (depending on the script to specify the browser type) and a `url` act.
162
+
163
+ #### Invocation
164
+
165
+ There are two ways to use the `batch` module.
166
+
167
+ ##### By a module
168
+
169
+ A module can invoke `batch` in this way:
170
+
171
+ ```javaScript
172
+ const {batch} = require('testilo/batch');
173
+ const batchObj = batch(listID, what, targetList);
174
+ ```
175
+
176
+ This invocation references `listID`, `what`, and `targetList` variables that the module must have already defined. They are all strings. `listID` is a unique identifier for the target list. `what` describes the target list. `targetList` is the target list. The `batch()` function of the `batch` module generates a batch and returns it as an object. The invoking module can further dispose of the batch as needed.
177
+
178
+ ##### By a user
179
+
180
+ A user can invoke `batch` in this way:
181
+
182
+ - Create a target list and save it as a text file (with tab-delimited items in newline-delimited lines) in the `targetLists` subdirectory of the `process.env.SPECDIR` directory. Name the file `x.tsv`, where `x` is the list ID.
183
+ - In the Testilo project directory, execute this statement:
184
+ - `node call batch i`
185
+
186
+ In this statement, replace `i` with the list ID.
187
+
188
+ The `call` module will retrieve the named target list.
189
+ The `batch` module will convert the target list to a batch.
190
+ The `call` module will save the batch as a JSON file in the `batches` subdirectory of the `process.env.SPECDIR` directory.
162
191
 
163
192
  ### Merge
164
193
 
package/batch.js CHANGED
@@ -20,8 +20,10 @@ exports.batch = (id, what, targetList) => {
20
20
  && Array.isArray(targetList)
21
21
  && targetList.length
22
22
  && targetList.every(
23
- target => Array.isArray(target) && target.every(item => typeof item === string && item.length)
23
+ target => Array.isArray(target)
24
+ && target.every(item => typeof item === 'string')
24
25
  )
26
+ && targetList.some(target => target.length === 3)
25
27
  ) {
26
28
  // Initialize the batch.
27
29
  const batch = {
@@ -29,25 +31,27 @@ exports.batch = (id, what, targetList) => {
29
31
  what,
30
32
  targets: []
31
33
  };
32
- // For each target:
34
+ // For each valid target:
33
35
  targetList.forEach(target => {
34
- // Add it to the batch.
35
- batch.targets.push({
36
- id: target[0],
37
- what: target[1],
38
- acts: {
39
- main: [
40
- {
41
- type: 'launch'
42
- },
43
- {
44
- type: 'url',
45
- which: target[2],
46
- what: target[1]
47
- }
48
- ]
49
- }
50
- });
36
+ if (target.length === 3) {
37
+ // Add it to the batch.
38
+ batch.targets.push({
39
+ id: target[0],
40
+ what: target[1],
41
+ acts: {
42
+ main: [
43
+ {
44
+ type: 'launch'
45
+ },
46
+ {
47
+ type: 'url',
48
+ which: target[2],
49
+ what: target[1]
50
+ }
51
+ ]
52
+ }
53
+ });
54
+ }
51
55
  });
52
56
  // Return the batch.
53
57
  return batch;
package/call.js CHANGED
@@ -18,6 +18,8 @@
18
18
  require('dotenv').config();
19
19
  // Function to process files.
20
20
  const fs = require('fs/promises');
21
+ // Function to process a list-to-batch conversion.
22
+ const {batch} = require('./batch');
21
23
  // Function to process a merger.
22
24
  const {merge} = require('./merge');
23
25
  // Function to score reports.
@@ -38,6 +40,18 @@ const fnArgs = process.argv.slice(3);
38
40
 
39
41
  // ########## FUNCTIONS
40
42
 
43
+ // Converts a target list to a batch.
44
+ const callBatch = async (listID, what) => {
45
+ // Get the target list.
46
+ const listString = await fs.readFile(`${specDir}/targetLists/${listID}.tsv`, 'utf8');
47
+ const list = listString.split('\n').map(target => target.split('\t'));
48
+ // Convert it to a batch.
49
+ const batchObj = batch(listID, what, list);
50
+ // Save the batch.
51
+ const batchJSON = JSON.stringify(batchObj, null, 2);
52
+ await fs.writeFile(`${specDir}/batches/${listID}.json`, `${batchJSON}\n`);
53
+ console.log(`Target list ${listID} converted to a batch and saved in ${specDir}/batches`);
54
+ };
41
55
  // Fulfills a merging request.
42
56
  const callMerge = async (scriptID, batchID, requester, withIsolation = false) => {
43
57
  // Get the script and the batch.
@@ -145,6 +159,12 @@ if (fn === 'aim' && fnArgs.length === 5) {
145
159
  console.log('Execution completed');
146
160
  });
147
161
  }
162
+ else if (fn === 'batch' && fnArgs.length === 2) {
163
+ callBatch(... fnArgs)
164
+ .then(() => {
165
+ console.log('Execution completed');
166
+ });
167
+ }
148
168
  else if (fn === 'merge' && fnArgs.length > 2 && fnArgs.length < 5) {
149
169
  callMerge(... fnArgs)
150
170
  .then(() => {
package/merge.js CHANGED
@@ -38,7 +38,7 @@ exports.merge = (script, batch, requester, isolate = false) => {
38
38
  // If the requester is unspecified, make it the standard requester.
39
39
  requester ||= stdRequester;
40
40
  // Create a timestamp.
41
- const timeStamp = Math.floor((Date.now() - Date.UTC(2022, 1)) / 2000).toString(36);
41
+ const timeStamp = Math.floor((Date.now() - Date.UTC(2023, 4)) / 2000).toString(36);
42
42
  // Create a time description.
43
43
  const creationTime = (new Date()).toISOString().slice(0, 19);
44
44
  // Initialize a target-independent job.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "11.0.0",
3
+ "version": "11.0.3",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {
@@ -48,7 +48,7 @@ exports.issues = {
48
48
  }
49
49
  }
50
50
  },
51
- duplicateAttribute:{
51
+ duplicateAttribute: {
52
52
  wcag: '4.1.1',
53
53
  weight: 2,
54
54
  tools: {
@@ -1,6 +1,6 @@
1
1
  /*
2
- tic24
3
- Testilo issue classification 24
2
+ tic26
3
+ Testilo issue classification 26
4
4
 
5
5
  Classifies tests of Testaro and its dependent tools into issues.
6
6
 
@@ -5398,10 +5398,15 @@ exports.issues = {
5398
5398
  weight: 3,
5399
5399
  tools: {
5400
5400
  testaro: {
5401
- focOp: {
5401
+ 'focOp-focusable-inoperable': {
5402
5402
  variable: false,
5403
5403
  quality: 1,
5404
- what: 'Operable elements that cannot be Tab-focused and vice versa'
5404
+ what: 'Tab-focusable elements that are inoperable'
5405
+ },
5406
+ 'focOp-operable-nonfocusable': {
5407
+ variable: false,
5408
+ quality: 1,
5409
+ what: 'Operable elements that cannot be Tab-focused'
5405
5410
  }
5406
5411
  }
5407
5412
  }
@@ -489,7 +489,7 @@ exports.scorer = async report => {
489
489
  changeFrequency
490
490
  } = data;
491
491
  const score = 2 * (meanLocalRatio - 1)
492
- + (maxLocalRatio - 1)
492
+ + maxLocalRatio - 1
493
493
  + globalRatio - 1
494
494
  + meanPixelChange / 10000
495
495
  + maxPixelChange / 25000