testilo 38.0.2 → 39.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/README.md CHANGED
@@ -786,7 +786,7 @@ To test the `digest` module, in the project directory you can execute the statem
786
786
 
787
787
  ### Summarization
788
788
 
789
- The `summarize` module of Testilo can summarize a scored report. The summary is an object that contains these properties from the report: `id`, `endTime`, `sources`, and `score` (the value of the `score.total` property of the report).
789
+ The `summarize` module of Testilo can summarize a scored report. The summary is an object that contains these properties from the report: `id`, `endTime`, `targetWhat` (description of the target), `url` (of the target), `sources`, and `score` (only the value of the `score.total` property of the report).
790
790
 
791
791
  #### Invocation
792
792
 
@@ -819,10 +819,6 @@ When a user invokes `summarize` in this example, the `call` module:
819
819
  - creates a _summary report_, an object containing three properties: `id` (an ID), `what` (a description, such as `'divisions'`), and `summaries` (the array of summaries).
820
820
  - writes the summary report in JSON format to the `summarized` subdirectory of the `REPORTDIR` directory, using the ID as the base of the file name.
821
821
 
822
- #### Summary reports
823
-
824
- A summary report serves as a necessary input to the `compare` and `track` modules described below. When a user invokes the `compare` module, a summary report is produced. A module can create a summary report by invoking `compare` multiple times on different scored reports, assembling the resulting summaries into an array, and creating an object like the one the `call` module creates for a user.
825
-
826
822
  ### Comparison
827
823
 
828
824
  If you use Testilo to perform a battery of tests on multiple targets, you may want a single report that compares the total scores received by the targets. Testilo can produce such a _comparison_.
@@ -864,7 +860,7 @@ node call compare 'state legislators' tcp99 240813
864
860
 
865
861
  When a user invokes `compare` in this example, the `call` module:
866
862
  - gets the comparison module from subdirectory `tcp99` of the subdirectory `compare` in the `FUNCTIONDIR` directory.
867
- - gets the first summary report whose file name begins with `'240813'` from the `summarized` subdirectory of the `REPORTDIR` directory.
863
+ - gets the last summary report whose file name begins with `'240813'` from the `summarized` subdirectory of the `REPORTDIR` directory.
868
864
  - creates an ID for the comparison.
869
865
  - creates the comparison as an HTML document.
870
866
  - writes the comparison in the `comparative` subdirectory of the `REPORTDIR` directory, with `state legislators` as a description and the ID as the base of the file name.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "38.0.2",
3
+ "version": "39.0.0",
4
4
  "description": "Prepares Testaro jobs and processes Testaro reports",
5
5
  "main": "call.js",
6
6
  "scripts": {
@@ -0,0 +1,42 @@
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="comparison of accessibility scores">
10
+ <meta name="keywords" content="accessibility a11y web testing">
11
+ <title>Accessibility score comparison: __what__</title>
12
+ <link rel="icon" href="favicon.ico">
13
+ <link rel="stylesheet" href="style.css">
14
+ </head>
15
+ <body>
16
+ <main>
17
+ <header>
18
+ <h1>Accessibility score comparison: __what__</h1>
19
+ </header>
20
+ <h2>Introduction</h2>
21
+ <p>This is comparison __id__.</p>
22
+ <p>The table below compares __pageCount__ web pages on <a href="https://www.w3.org/WAI/fundamentals/accessibility-intro/">accessibility</a>. The page names are links to the pages on the web. The scores are links to digests that explain in detail how the scores were computed.</p>
23
+ <p>The pages were tested by <a href="https://www.npmjs.com/package/testaro">Testaro</a>. Testaro used ten tools (Alfa, ASLint, Axe, Editoria11y, Equal Access, HTML CodeSniffer, Nu Html Checker, QualWeb, Testaro, and WAVE) to perform about 900 automated accessibility tests.</p>
24
+ <p><a href="https://www.npmjs.com/package/testilo">Testilo</a> classified the problems found by these tests into <dfn>issues</dfn> and assigned a <dfn>score</dfn> to each page. A perfect score would be 0. Higher scores indicate more issues, more instances of them, more serious issues, and more of the tools reporting instances of issues.</p>
25
+ <h2>Comparison</h2>
26
+ <table class="allBorder redBar">
27
+ <caption>Accessibility scores of web pages</caption>
28
+ <thead>
29
+ <tr><th scope="col">Page</th><th scope="col" colspan="2">Score (from best to worst)</tr>
30
+ </thead>
31
+ <tbody class="linkSmaller secondCellRight">
32
+ __tableBody__
33
+ </tbody>
34
+ </table>
35
+ <h2>Disclaimer</h2>
36
+ <p>Other procedures would yield different scores and rank orders among these pages.</p>
37
+ <footer>
38
+ <p class="date">Produced <time itemprop="datePublished" datetime="__dateISO__">__dateSlash__</time></p>
39
+ </footer>
40
+ </main>
41
+ </body>
42
+ </html>
@@ -0,0 +1,84 @@
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
+ /*
24
+ index
25
+ Compares scores in a summary report.
26
+ */
27
+
28
+ // ########## IMPORTS
29
+
30
+ // Module to access files.
31
+ const fs = require('fs/promises');
32
+ const {getBarCell, getNowDate, getNowDateSlash} = require('../../util');
33
+
34
+ // CONSTANTS
35
+
36
+ // Newlines with indentations.
37
+ const innestJoiner = '\n ';
38
+
39
+ // ########## FUNCTIONS
40
+
41
+ // Returns the maximum score.
42
+ const getMaxScore = summaryReport => summaryReport.summaries.reduce(
43
+ (max, result) => Math.max(max, result.score), 0
44
+ );
45
+ // Converts summary report data to a table body.
46
+ const getTableBody = async summaryReport => {
47
+ const maxScore = getMaxScore(summaryReport);
48
+ const rows = summaryReport.summaries
49
+ .sort((a, b) => a.score - b.score)
50
+ .map(result => {
51
+ const {id, score, targetWhat, url} = result;
52
+ const pageCell = `<th scope="row"><a href="${url}">${targetWhat}</a></th>`;
53
+ const scoreDestination = process.env.DIGEST_URL.replace('__id__', id);
54
+ const numCell = `<td class="num"><a href="${scoreDestination}">${score}</a></td>`;
55
+ // Make the bar width proportional.
56
+ const barCell = getBarCell(score, maxScore, 25, false);
57
+ const row = `<tr>${pageCell}${numCell}${barCell}</tr>`;
58
+ return row;
59
+ });
60
+ return rows.join(innestJoiner);
61
+ };
62
+ // Populates a query for a comparative table.
63
+ const populateQuery = exports.populateQuery = async (id, what, summaryReport, query) => {
64
+ query.id = id;
65
+ query.what = what;
66
+ query.pageCount = summaryReport.summaries.length;
67
+ query.tableBody = await getTableBody(summaryReport);
68
+ query.dateISO = getNowDate();
69
+ query.dateSlash = getNowDateSlash();
70
+ };
71
+ // Returns a comparison.
72
+ exports.comparer = async (id, what, summaryReport) => {
73
+ // Create a query to replace placeholders.
74
+ const query = {};
75
+ populateQuery(id, what, summaryReport, query);
76
+ // Get the template.
77
+ let template = await fs.readFile(`${__dirname}/index.html`, 'utf8');
78
+ // Replace its placeholders.
79
+ Object.keys(query).forEach(param => {
80
+ template = template.replace(new RegExp(`__${param}__`, 'g'), query[param]);
81
+ });
82
+ // Return the comparison.
83
+ return template;
84
+ };
@@ -53,8 +53,6 @@ const populateQuery = async (id, what, summaryReport, query) => {
53
53
  // JSON of summary report.
54
54
  const {summaries} = summaryReport;
55
55
  query.summaryReportJSON = JSON.stringify(summaryReport);
56
- // Legend.
57
-
58
56
  // Get an array of target descriptions and assign to each an ID.
59
57
  const rows = [];
60
58
  const targets = Array
package/summarize.js CHANGED
@@ -34,9 +34,12 @@ require('dotenv').config();
34
34
 
35
35
  // Returns a report summary.
36
36
  exports.summarize = report => {
37
- const {id, jobData, score, sources} = report;
37
+ const {id, jobData, score, sources, target} = report;
38
+ const foundTarget = target || sources.target;
38
39
  const summary = {
39
40
  id: id || null,
41
+ url: foundTarget && (foundTarget.url || foundTarget.which) || null,
42
+ targetWhat: foundTarget.what || null,
40
43
  endTime: jobData && jobData.endTime || null,
41
44
  sources: sources || null,
42
45
  score: score && score.summary && score.summary.total || null