testilo 46.0.1 → 47.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/package.json +1 -1
- package/procs/excerpts/excerpts.js +44 -9
package/package.json
CHANGED
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
|
|
23
23
|
/*
|
|
24
24
|
excerpts
|
|
25
|
-
Excerpt collation proc
|
|
25
|
+
Excerpt and text collation proc
|
|
26
26
|
|
|
27
|
-
Adds
|
|
27
|
+
Adds directories of element excerpts and texts to a Testaro report.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
// FUNCTIONS
|
|
31
31
|
|
|
32
|
-
// Adds
|
|
32
|
+
// Adds directories of element excerpts and texts to a Testaro report.
|
|
33
33
|
exports.collateExcerpts = report => {
|
|
34
34
|
const {acts} = report;
|
|
35
35
|
// If there are any acts in the report:
|
|
@@ -38,8 +38,9 @@ exports.collateExcerpts = report => {
|
|
|
38
38
|
const testActs = acts.filter(act => act.type === 'test');
|
|
39
39
|
// If there are any:
|
|
40
40
|
if (testActs.length) {
|
|
41
|
-
// Initialize
|
|
41
|
+
// Initialize excerpt and text directories in the report in place.
|
|
42
42
|
const excerpts = report.excerpts = {};
|
|
43
|
+
const texts = report.texts = {};
|
|
43
44
|
// For each test act:
|
|
44
45
|
testActs.forEach(act => {
|
|
45
46
|
const {which, standardResult} = act;
|
|
@@ -53,17 +54,51 @@ exports.collateExcerpts = report => {
|
|
|
53
54
|
) {
|
|
54
55
|
// For each instance of the tool:
|
|
55
56
|
standardResult.instances.forEach(instance => {
|
|
56
|
-
// Get the excerpt
|
|
57
|
-
const {excerpt, pathID} = instance;
|
|
57
|
+
// Get the excerpt, path ID, and text, if any, of the element.
|
|
58
|
+
const {excerpt, pathID, text} = instance;
|
|
58
59
|
excerpts[pathID] ??= {};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
texts[pathID] ??= {};
|
|
61
|
+
// If a path ID exists:
|
|
62
|
+
if (pathID) {
|
|
63
|
+
// Add the excerpt to the excerpt directory unless one already exists.
|
|
62
64
|
excerpts[pathID][which] ??= excerpt;
|
|
65
|
+
// Add the text to the text directory unless one already exists.
|
|
66
|
+
texts[pathID][which] ??= text;
|
|
63
67
|
}
|
|
64
68
|
});
|
|
65
69
|
}
|
|
66
70
|
});
|
|
71
|
+
// If the text directory is non-empty:
|
|
72
|
+
if (Object.keys(texts).length) {
|
|
73
|
+
// For each path ID in it:
|
|
74
|
+
Object.keys(texts).forEach(pathID => {
|
|
75
|
+
const toolNames = Object.keys(texts[pathID]);
|
|
76
|
+
// If the element has only 1 text:
|
|
77
|
+
if (toolNames.length === 1) {
|
|
78
|
+
// Change the key to unanimous.
|
|
79
|
+
texts[pathID].unanimous = texts[pathID][toolNames[0]];
|
|
80
|
+
delete texts[pathID][toolNames[0]];
|
|
81
|
+
}
|
|
82
|
+
// Otherwise, i.e. if the element has more than 1 text:
|
|
83
|
+
else {
|
|
84
|
+
// If all the texts are identical:
|
|
85
|
+
if (
|
|
86
|
+
Object
|
|
87
|
+
.values(texts[pathID])
|
|
88
|
+
.slice(1)
|
|
89
|
+
.every(text => text === texts[pathID][toolNames[0]])
|
|
90
|
+
) {
|
|
91
|
+
// Consolidate the texts to 1 unanimous text.
|
|
92
|
+
texts[pathID].unanimous = texts[pathID][toolNames[0]];
|
|
93
|
+
toolNames.forEach(toolName => {
|
|
94
|
+
if (toolName !== toolNames[0]) {
|
|
95
|
+
delete texts[pathID][toolName];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
67
102
|
}
|
|
68
103
|
}
|
|
69
104
|
};
|