testilo 41.3.0 → 41.4.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/digest/tdp49/index.html +161 -0
- package/procs/digest/tdp49/index.js +240 -0
package/package.json
CHANGED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<!DOCTYPE HTML>
|
|
2
|
+
<html lang="en-US">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="author" content="Testilo">
|
|
7
|
+
<meta name="creator" content="Testilo">
|
|
8
|
+
<meta name="publisher" name="Testilo">
|
|
9
|
+
<meta name="description" content="report of accessibility testing of a web page">
|
|
10
|
+
<meta name="keywords" content="accessibility a11y web testing">
|
|
11
|
+
<title>Accessibility digest</title>
|
|
12
|
+
<link rel="icon" href="favicon.ico">
|
|
13
|
+
<link rel="stylesheet" href="style.css">
|
|
14
|
+
<script id="script" type="module">
|
|
15
|
+
const sortByA = document.getElementById('sortByA');
|
|
16
|
+
const sortByB = document.getElementById('sortByB');
|
|
17
|
+
const sortBasisSpan = document.getElementById('sortBasis');
|
|
18
|
+
const sortBasisASpan = document.getElementById('sortBasisA');
|
|
19
|
+
const sortBasisBSpan = document.getElementById('sortBasisB');
|
|
20
|
+
const sumBody = document.getElementById('sumBody');
|
|
21
|
+
const rows = Array.from(sumBody.children);
|
|
22
|
+
const sortBases = {
|
|
23
|
+
WCAG: {
|
|
24
|
+
col: 1,
|
|
25
|
+
A: 'weight',
|
|
26
|
+
B: 'score'
|
|
27
|
+
},
|
|
28
|
+
weight: {
|
|
29
|
+
col: 2,
|
|
30
|
+
A: 'WCAG',
|
|
31
|
+
B: 'score'
|
|
32
|
+
},
|
|
33
|
+
score: {
|
|
34
|
+
col: 3,
|
|
35
|
+
A: 'WCAG',
|
|
36
|
+
B: 'weight'
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
// FUNCTION DEFINITION START
|
|
40
|
+
const sortRowsBy = basis => {
|
|
41
|
+
if (basis === 'WCAG') {
|
|
42
|
+
rows.sort((a, b) => {
|
|
43
|
+
const sorters = [a, b].map(row => {
|
|
44
|
+
const wcagParts = row.children[sortBases[basis].col].textContent.split('.');
|
|
45
|
+
const wcagNums = wcagParts.map(part => Number.parseInt(part, 10));
|
|
46
|
+
return 100 * (wcagNums[0] || 0) + 20 * (wcagNums[1] || 0) + (wcagNums[2] || 0);
|
|
47
|
+
});
|
|
48
|
+
return sorters[0] - sorters[1];
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else if (basis === 'weight') {
|
|
52
|
+
rows.sort((a, b) => {
|
|
53
|
+
const sorters = [a, b].map(row => row.children[sortBases[basis].col].textContent);
|
|
54
|
+
return sorters[1] - sorters[0];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else if (basis === 'score') {
|
|
58
|
+
rows.sort((a, b) => {
|
|
59
|
+
const sorters = [a, b]
|
|
60
|
+
.map(row => Number.parseInt(row.children[sortBases[basis].col].textContent));
|
|
61
|
+
return sorters[1] - sorters[0];
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
sumBody.textContent = '';
|
|
65
|
+
rows.forEach(row => {
|
|
66
|
+
sumBody.appendChild(row);
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
// FUNCTION DEFINITION END
|
|
70
|
+
// When a sort button is activated:
|
|
71
|
+
document.getElementById('sortButtons').addEventListener('click', event => {
|
|
72
|
+
const whichButton = event.target.id.slice(-1);
|
|
73
|
+
const oldBasis = sortBasisSpan.textContent;
|
|
74
|
+
const newBasis = sortBases[oldBasis][whichButton];
|
|
75
|
+
// Re-sort the table.
|
|
76
|
+
sortRowsBy(newBasis);
|
|
77
|
+
// Revise the variable texts.
|
|
78
|
+
sortBasisSpan.textContent = newBasis;
|
|
79
|
+
sortBasisASpan.textContent = sortBases[newBasis].A;
|
|
80
|
+
sortBasisBSpan.textContent = sortBases[newBasis].B;
|
|
81
|
+
});
|
|
82
|
+
</script>
|
|
83
|
+
</head>
|
|
84
|
+
<body>
|
|
85
|
+
<main>
|
|
86
|
+
<header>
|
|
87
|
+
<h1>Accessibility digest</h1>
|
|
88
|
+
<h2>Contents</h2>
|
|
89
|
+
<ul>
|
|
90
|
+
<li><a href="#intro">Introduction</a></li>
|
|
91
|
+
<li><a href="#summary">Issue summary</a></li>
|
|
92
|
+
<li><a href="#itemization">Itemized issues</a></li>
|
|
93
|
+
<li><a href="#elements">Elements with issues</a></li>
|
|
94
|
+
</ul>
|
|
95
|
+
<table class="allBorder">
|
|
96
|
+
<caption>Synopsis</caption>
|
|
97
|
+
<tr><th>Page</th><td>__org__</td></tr>
|
|
98
|
+
<tr><th>URL</th><td>__url__</td></tr>
|
|
99
|
+
<tr><th>Test date</th><td>__dateSlash__</td></tr>
|
|
100
|
+
<tr><th>Score</th><td>__total__</td></tr>
|
|
101
|
+
</table>
|
|
102
|
+
<table class="allBorder">
|
|
103
|
+
<caption>Configuration</caption>
|
|
104
|
+
<tr><th>Redirections</th><td>__redirections__</td></tr>
|
|
105
|
+
<tr><th>Tool isolation</th><td>__isolation__</td></tr>
|
|
106
|
+
<tr><th>Report format(s)</th><td>__standard__</td></tr>
|
|
107
|
+
<tr><th>Requester</th><td>__requester__</td></tr>
|
|
108
|
+
<tr><th>Device</th><td>__device__</td></tr>
|
|
109
|
+
<tr><th>Browser type</th><td>__browser__</td></tr>
|
|
110
|
+
<tr><th>Reduced motion</th><td>__motion__</td></tr>
|
|
111
|
+
<tr><th>Tested by</th><td>Testaro__agent__, procedure <code>__ts__</code></td></tr>
|
|
112
|
+
<tr><th>Scored by</th><td>Testilo, procedure <code>__sp__</code></td></tr>
|
|
113
|
+
<tr><th>Digested by</th><td>Testilo, procedure <code>__dp__</code></td></tr>
|
|
114
|
+
<tr>
|
|
115
|
+
<th>Full report</th>
|
|
116
|
+
<td><a href="__reportURL__"><code>__reportURL__</code></a></td>
|
|
117
|
+
</tr>
|
|
118
|
+
</table>
|
|
119
|
+
</header>
|
|
120
|
+
<h2 id="intro">Introduction</h2>
|
|
121
|
+
<p>How <a href="https://www.w3.org/WAI/">accessible</a> is the __org__ web page at <a href="__url__"><code>__url__</code></a>?</p>
|
|
122
|
+
<p>This digest can help answer that question. Ten different tools (Alfa, ASLint, Axe, Editoria11y, Equal Access, HTML CodeSniffer, Nu Html Checker, QualWeb, Testaro, and WAVE) tested the page to check its compliance with their accessibility rules. In all, the tools define about 990 rules, which are classified here into about 310 accessibility issues.</p>
|
|
123
|
+
<p>The results were interpreted to yield a score, with 0 being ideal. The score for this page was __total__, the sum of __issueCount__ for the count of issues, __issue__ for specific issues, __solo__ for unclassified rule violations, __tool__ for tool-by-tool ratings, __element__ for the count of violating elements, __prevention__ for the page preventing tools from running, __log__ for browser warnings, and __latency__ for delayed page responses.</p>
|
|
124
|
+
<h2 id="summary">Issue summary</h2>
|
|
125
|
+
<h3>Details about this summary</h3>
|
|
126
|
+
<ul>
|
|
127
|
+
<li>This table shows the numbers of rule violations (<q>instances</q>) reported by one or more tools, classified by issue.</li>
|
|
128
|
+
<li>Tools often disagree on instance counts, because of non-equivalent rules or invalid tests. You can inspect the <a href="__reportURL__">full report</a> to diagnose differences.</li>
|
|
129
|
+
<li>The <q>WCAG</q> value is the principle, guideline, or success criterion of the <a href="https://www.w3.org/TR/WCAG22/">Web Content Accessibility Guidelines</a> most relevant to the issue.</li>
|
|
130
|
+
<li>The <q>Weight</q> value estimates the importance of an instance of the issue, from 1 (minor or advisory) to 4 (serious).</li>
|
|
131
|
+
<li>The <q>Score</q> value is the contribution of the instances of the issue to the page score.</li>
|
|
132
|
+
<li>An instance count of 0 means the tool has a rule belonging to the issue but reported no violations of that rule, although at least one tool reported at least one violation.</li>
|
|
133
|
+
<li>You can sort this table by WCAG, weight, or score.</li>
|
|
134
|
+
</ul>
|
|
135
|
+
<h3>The summary</h3>
|
|
136
|
+
<p role="status">Sorting is by <span id="sortBasis">score</span>.</p>
|
|
137
|
+
<p id="sortButtons">
|
|
138
|
+
<button id="sortButtonA" type="button">Sort by <span id="sortBasisA">WCAG</span></button>
|
|
139
|
+
<button id="sortButtonB" type="button">Sort by <span id="sortBasisB">weight</span></button>
|
|
140
|
+
</p>
|
|
141
|
+
<table class="allBorder thirdCellRight">
|
|
142
|
+
<caption>How many violations each tool reported, by issue</caption>
|
|
143
|
+
<thead>
|
|
144
|
+
<tr><th>Issue</th><th>WCAG</th><th>Weight</th><th>Score</th><th>Instance counts</th></tr>
|
|
145
|
+
</thead>
|
|
146
|
+
<tbody id="sumBody" class="headersLeft">
|
|
147
|
+
__issueRows__
|
|
148
|
+
</tbody>
|
|
149
|
+
</table>
|
|
150
|
+
<h2 id="itemization">Itemized issues</h2>
|
|
151
|
+
<p>The reported rule violations are itemized below, issue by issue. Additional details can be inspected in the <a href="__reportURL__">full report</a>.</p>
|
|
152
|
+
__issueDetailRows__
|
|
153
|
+
<h2 id="elements">Elements with issues</h2>
|
|
154
|
+
<p>Elements exhibiting issues:</p>
|
|
155
|
+
__elementRows__
|
|
156
|
+
<footer>
|
|
157
|
+
<p class="date">Produced <time itemprop="datePublished" datetime="__dateISO__">__dateSlash__</time></p>
|
|
158
|
+
</footer>
|
|
159
|
+
</main>
|
|
160
|
+
</body>
|
|
161
|
+
</html>
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/*
|
|
2
|
+
© 2024 CVS Health and/or one of its affiliates. 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
|
+
// index: digester for scoring procedure tsp43.
|
|
24
|
+
|
|
25
|
+
// IMPORTS
|
|
26
|
+
|
|
27
|
+
// Module to keep secrets.
|
|
28
|
+
require('dotenv').config();
|
|
29
|
+
// Module to classify tool rules into issues
|
|
30
|
+
const {issues} = require('../../score/tic45');
|
|
31
|
+
// Module to process files.
|
|
32
|
+
const fs = require('fs/promises');
|
|
33
|
+
// Utility module.
|
|
34
|
+
const {getNowDate, getNowDateSlash} = require('../../util');
|
|
35
|
+
|
|
36
|
+
// CONSTANTS
|
|
37
|
+
|
|
38
|
+
// Digester ID.
|
|
39
|
+
const digesterID = 'tdp48';
|
|
40
|
+
// Newline with indentations.
|
|
41
|
+
const innerJoiner = '\n ';
|
|
42
|
+
const outerJoiner = '\n ';
|
|
43
|
+
// Directory of WCAG links.
|
|
44
|
+
const wcagPhrases = {};
|
|
45
|
+
|
|
46
|
+
// FUNCTIONS
|
|
47
|
+
|
|
48
|
+
// Gets a row of the score-summary table.
|
|
49
|
+
const getScoreRow = (componentName, score) => `<tr><th>${componentName}</th><td>${score}</td></tr>`;
|
|
50
|
+
// Gets a WCAG link or, if not obtainable, a numeric identifier.
|
|
51
|
+
const getWCAGTerm = wcag => {
|
|
52
|
+
const wcagPhrase = wcagPhrases[wcag];
|
|
53
|
+
const wcagTerm = wcagPhrase
|
|
54
|
+
? `<a href="https://www.w3.org/WAI/WCAG22/Understanding/${wcagPhrase}.html">${wcag}</a>`
|
|
55
|
+
: wcag;
|
|
56
|
+
return wcagTerm;
|
|
57
|
+
};
|
|
58
|
+
// Gets a row of the issue-score-summary table.
|
|
59
|
+
const getIssueScoreRow = (issueConstants, issueDetails) => {
|
|
60
|
+
const {summary, wcag, weight} = issueConstants;
|
|
61
|
+
const wcagTerm = getWCAGTerm(wcag);
|
|
62
|
+
const {instanceCounts, score} = issueDetails;
|
|
63
|
+
const toolList = Object
|
|
64
|
+
.keys(instanceCounts)
|
|
65
|
+
.map(tool => `<code>${tool}</code>:${instanceCounts[tool]}`)
|
|
66
|
+
.join(', ');
|
|
67
|
+
return `<tr><th>${summary}</th><td class="center">${wcagTerm}<td class="right num">${weight}</td><td class="right num">${score}</td><td>${toolList}</td></tr>`;
|
|
68
|
+
};
|
|
69
|
+
// Populates the directory of WCAG understanding verbal IDs.
|
|
70
|
+
const getWCAGPhrases = async () => {
|
|
71
|
+
// Get the copy of file https://raw.githubusercontent.com/w3c/wcag/main/guidelines/wcag.json.
|
|
72
|
+
const wcagJSON = await fs.readFile(`${__dirname}/../../../wcag.json`, 'utf8');
|
|
73
|
+
const wcag = JSON.parse(wcagJSON);
|
|
74
|
+
const {principles} = wcag;
|
|
75
|
+
// For each principle in it:
|
|
76
|
+
principles.forEach(principle => {
|
|
77
|
+
// If it is usable:
|
|
78
|
+
if (principle.num && principle.id && principle.id.startsWith('WCAG2:')) {
|
|
79
|
+
// Add it to the directory.
|
|
80
|
+
wcagPhrases[principle.num] = principle.id.slice(6);
|
|
81
|
+
const {guidelines} = principle;
|
|
82
|
+
// For each guideline in the principle:
|
|
83
|
+
guidelines.forEach(guideline => {
|
|
84
|
+
// If it is usable:
|
|
85
|
+
if (guideline.num && guideline.id && guideline.id.startsWith('WCAG2:')) {
|
|
86
|
+
// Add it to the directory.
|
|
87
|
+
wcagPhrases[guideline.num] = guideline.id.slice(6);
|
|
88
|
+
const {successcriteria} = guideline;
|
|
89
|
+
// For each success criterion in the guideline:
|
|
90
|
+
successcriteria.forEach(successCriterion => {
|
|
91
|
+
// If it is usable:
|
|
92
|
+
if (
|
|
93
|
+
successCriterion.num
|
|
94
|
+
&& successCriterion.id
|
|
95
|
+
&& successCriterion.id.startsWith('WCAG2:')
|
|
96
|
+
) {
|
|
97
|
+
// Add it to the directory.
|
|
98
|
+
wcagPhrases[successCriterion.num] = successCriterion.id.slice(6);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
// Adds parameters to a query for a digest.
|
|
107
|
+
const populateQuery = async (report, query) => {
|
|
108
|
+
const {
|
|
109
|
+
browserID, device, id, isolate, lowMotion, score, sources, standard, strict, target
|
|
110
|
+
} = report;
|
|
111
|
+
const {agent, requester, script} = sources;
|
|
112
|
+
const {scoreProcID, summary, details} = score;
|
|
113
|
+
query.ts = script;
|
|
114
|
+
query.sp = scoreProcID;
|
|
115
|
+
query.dp = digesterID;
|
|
116
|
+
// Add the job data to the query.
|
|
117
|
+
query.dateISO = getNowDate();
|
|
118
|
+
query.dateSlash = getNowDateSlash();
|
|
119
|
+
query.org = target.what;
|
|
120
|
+
query.url = target.url;
|
|
121
|
+
query.redirections = strict ? 'prohibited' : 'permitted';
|
|
122
|
+
query.isolation = isolate ? 'yes' : 'no';
|
|
123
|
+
query.standard
|
|
124
|
+
= ['original', 'standard', 'original and standard'][['no', 'only', 'also'].indexOf(standard)];
|
|
125
|
+
query.motion = lowMotion ? 'requested' : 'not requested';
|
|
126
|
+
query.requester = requester;
|
|
127
|
+
query.device = device.id;
|
|
128
|
+
query.browser = browserID;
|
|
129
|
+
query.agent = agent ? ` on agent ${agent}` : '';
|
|
130
|
+
query.reportURL = process.env.SCORED_REPORT_URL.replace('__id__', id);
|
|
131
|
+
// Populate the WCAG phrase directory.
|
|
132
|
+
await getWCAGPhrases();
|
|
133
|
+
// Add values for the score-summary table to the query.
|
|
134
|
+
const rows = {
|
|
135
|
+
summaryRows: [],
|
|
136
|
+
issueRows: []
|
|
137
|
+
};
|
|
138
|
+
['total', 'issueCount', 'issue', 'solo', 'tool', 'element', 'prevention', 'log', 'latency']
|
|
139
|
+
.forEach(sumItem => {
|
|
140
|
+
query[sumItem] = summary[sumItem];
|
|
141
|
+
rows.summaryRows.push(getScoreRow(sumItem, query[sumItem]));
|
|
142
|
+
});
|
|
143
|
+
// Sort the issue IDs in descending score order.
|
|
144
|
+
const issueIDs = Object.keys(details.issue);
|
|
145
|
+
issueIDs.sort((a, b) => details.issue[b].score - details.issue[a].score);
|
|
146
|
+
// Get rows for the issue-score table.
|
|
147
|
+
issueIDs.forEach(issueID => {
|
|
148
|
+
if (issues[issueID]) {
|
|
149
|
+
rows.issueRows.push(getIssueScoreRow(issues[issueID], details.issue[issueID]));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
console.log(`ERROR: Issue ${issueID} not found`);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
// Add the rows to the query.
|
|
156
|
+
['summaryRows', 'issueRows'].forEach(rowType => {
|
|
157
|
+
query[rowType] = rows[rowType].join(innerJoiner);
|
|
158
|
+
});
|
|
159
|
+
// Add paragraph groups about the issue details to the query.
|
|
160
|
+
const issueDetailRows = [];
|
|
161
|
+
issueIDs.forEach(issueID => {
|
|
162
|
+
const issueSummary = issues[issueID].summary;
|
|
163
|
+
issueDetailRows.push(`<h3 class="bars">Issue: ${issueSummary}</h3>`);
|
|
164
|
+
issueDetailRows.push(`<p>Impact: ${issues[issueID].why || 'N/A'}</p>`);
|
|
165
|
+
const wcag = issues[issueID].wcag;
|
|
166
|
+
const wcagTerm = wcag ? getWCAGTerm(wcag) : 'N/A';
|
|
167
|
+
issueDetailRows.push(`<p>WCAG: ${wcagTerm}</p>`);
|
|
168
|
+
const issueData = details.issue[issueID];
|
|
169
|
+
issueDetailRows.push(`<p>Score: ${issueData.score}</p>`);
|
|
170
|
+
issueDetailRows.push('<h4>Elements</h4>');
|
|
171
|
+
const issuePaths = details.element[issueID];
|
|
172
|
+
if (issuePaths.length) {
|
|
173
|
+
issueDetailRows.push('<ul>');
|
|
174
|
+
issuePaths.forEach(pathID => {
|
|
175
|
+
issueDetailRows.push(` <li>${pathID}</li>`);
|
|
176
|
+
});
|
|
177
|
+
issueDetailRows.push('</ul>');
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
issueDetailRows.push('<p>None identified</p>');
|
|
181
|
+
}
|
|
182
|
+
const toolIDs = Object.keys(issueData.tools);
|
|
183
|
+
toolIDs.forEach(toolID => {
|
|
184
|
+
issueDetailRows.push(`<h4>Violations of <code>${toolID}</code> rules</h4>`);
|
|
185
|
+
const ruleIDs = Object.keys(issueData.tools[toolID]);
|
|
186
|
+
ruleIDs.forEach(ruleID => {
|
|
187
|
+
const ruleData = issueData.tools[toolID][ruleID];
|
|
188
|
+
issueDetailRows.push(`<h5>Rule <code>${ruleID}</code></h5>`);
|
|
189
|
+
issueDetailRows.push(`<p>Description: ${ruleData.what}</p>`);
|
|
190
|
+
issueDetailRows.push(`<p>Count of instances: ${ruleData.complaints.countTotal}</p>`);
|
|
191
|
+
/*
|
|
192
|
+
This fails unless the caller handles such URLs and has compatible scored report URLs.
|
|
193
|
+
const href = `${query.reportURL}?tool=${toolID}&rule=${ruleID}`;
|
|
194
|
+
const detailLabel = `Issue ${issueSummary} tool ${toolID} rule ${ruleID} instance details`;
|
|
195
|
+
issueDetailRows.push(
|
|
196
|
+
`<p><a href="${href}" aria-label="${detailLabel}">Instance details</a></p>`
|
|
197
|
+
);
|
|
198
|
+
*/
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
query.issueDetailRows = issueDetailRows.join(outerJoiner);
|
|
203
|
+
// Add paragraphs about the elements to the query.
|
|
204
|
+
const elementRows = [];
|
|
205
|
+
const issueElements = {};
|
|
206
|
+
Object.keys(details.element).forEach(issueID => {
|
|
207
|
+
const pathIDs = details.element[issueID];
|
|
208
|
+
pathIDs.forEach(pathID => {
|
|
209
|
+
issueElements[pathID] ??= [];
|
|
210
|
+
issueElements[pathID].push(issueID);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
const sortedPathIDs = Object.keys(issueElements).sort();
|
|
214
|
+
sortedPathIDs.forEach(pathID => {
|
|
215
|
+
const elementIssues = issueElements[pathID];
|
|
216
|
+
if (elementIssues) {
|
|
217
|
+
elementRows.push(
|
|
218
|
+
`<h5>Element <code>${pathID}</code></h5>`,
|
|
219
|
+
'<ul>',
|
|
220
|
+
... elementIssues.map(issueID => ` <li>${issues[issueID].summary}</li>`).sort(),
|
|
221
|
+
'</ul>'
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
query.elementRows = elementRows.join(outerJoiner);
|
|
226
|
+
};
|
|
227
|
+
// Returns a digested report.
|
|
228
|
+
exports.digester = async report => {
|
|
229
|
+
// Create a query to replace placeholders.
|
|
230
|
+
const query = {};
|
|
231
|
+
await populateQuery(report, query);
|
|
232
|
+
// Get the template.
|
|
233
|
+
let template = await fs.readFile(`${__dirname}/index.html`, 'utf8');
|
|
234
|
+
// Replace its placeholders.
|
|
235
|
+
Object.keys(query).forEach(param => {
|
|
236
|
+
template = template.replace(new RegExp(`__${param}__`, 'g'), query[param]);
|
|
237
|
+
});
|
|
238
|
+
// Return the digest.
|
|
239
|
+
return template;
|
|
240
|
+
};
|