testilo 12.0.4 → 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: [
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.4",
3
+ "version": "12.1.0",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {