testilo 45.0.0 → 46.0.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 +69 -0
package/package.json
CHANGED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
© 2025 Jonathan Robert Pool. All rights reserved.
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
excerpts
|
|
25
|
+
Excerpt collation proc
|
|
26
|
+
|
|
27
|
+
Adds a directory of element excerpts to a Testaro report.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
// FUNCTIONS
|
|
31
|
+
|
|
32
|
+
// Adds a directory of element excerpts to a Testaro report.
|
|
33
|
+
exports.collateExcerpts = report => {
|
|
34
|
+
const {acts} = report;
|
|
35
|
+
// If there are any acts in the report:
|
|
36
|
+
if (Array.isArray(acts) && acts.length) {
|
|
37
|
+
// Get those that are test acts.
|
|
38
|
+
const testActs = acts.filter(act => act.type === 'test');
|
|
39
|
+
// If there are any:
|
|
40
|
+
if (testActs.length) {
|
|
41
|
+
// Initialize an excerpt directory in the report in place.
|
|
42
|
+
const excerpts = report.excerpts = {};
|
|
43
|
+
// For each test act:
|
|
44
|
+
testActs.forEach(act => {
|
|
45
|
+
const {which, standardResult} = act;
|
|
46
|
+
// If a valid non-empty standard result exists:
|
|
47
|
+
if (
|
|
48
|
+
standardResult
|
|
49
|
+
&& standardResult.totals
|
|
50
|
+
&& standardResult.totals.length === 4
|
|
51
|
+
&& standardResult.instances
|
|
52
|
+
&& standardResult.instances.length
|
|
53
|
+
) {
|
|
54
|
+
// For each instance of the tool:
|
|
55
|
+
standardResult.instances.forEach(instance => {
|
|
56
|
+
// Get the excerpt and path ID, if any, of the element.
|
|
57
|
+
const {excerpt, pathID} = instance;
|
|
58
|
+
// If both exist and the directory contains no excerpt for the path ID and tool:
|
|
59
|
+
if (excerpt && pathID && ! excerpts[pathID][which]) {
|
|
60
|
+
// Add the excerpt to the directory.
|
|
61
|
+
excerpts[pathID] ??= {};
|
|
62
|
+
excerpts[pathID][which] = excerpt;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|