testilo 33.4.0 → 33.4.1

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
@@ -917,8 +917,7 @@ A module can invoke `credit()` in this way:
917
917
  ```javaScript
918
918
  const {credit} = require('testilo/credit');
919
919
  const reportScores = […];
920
- credit('June 2025', reportScores)
921
- .then(creditReport => {…});
920
+ const creditReport = credit('June 2025', reportScores);
922
921
  ```
923
922
 
924
923
  The first argument to `credit()` is a description to be included in the credit report. The second argument is an array of `score` properties of scored report objects. The `credit()` function returns a credit report. The invoking module can further dispose of the credit report as needed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "33.4.0",
3
+ "version": "33.4.1",
4
4
  "description": "Prepares Testaro jobs and processes Testaro reports",
5
5
  "main": "call.js",
6
6
  "scripts": {
@@ -29,7 +29,7 @@ const getIssueScoreRow = (summary, wcag, score, tools) => {
29
29
  };
30
30
  // Adds parameters to a query for a digest.
31
31
  const populateQuery = (report, query) => {
32
- const {id, sources, jobData, score} = report;
32
+ const {id, sources, score} = report;
33
33
  const {script, target, requester} = sources;
34
34
  const {scoreProcID, summary, details} = score;
35
35
  query.ts = script;
@@ -0,0 +1,59 @@
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
+ </head>
15
+ <body>
16
+ <main>
17
+ <header>
18
+ <h1>Accessibility digest</h1>
19
+ <table class="allBorder">
20
+ <caption>Synopsis</caption>
21
+ <tr><th>Page</th><td>__org__</td></tr>
22
+ <tr><th>URL</th><td>__url__</td></tr>
23
+ <tr><th>Requester</th><td>__requester__</td></tr>
24
+ <tr><th>Test date</th><td>__dateSlash__</td></tr>
25
+ <tr><th>Score</th><td>__total__</td></tr>
26
+ <tr><th>Tested by</th><td>Testaro, procedure <code>__ts__</code></td></tr>
27
+ <tr><th>Scored by</th><td>Testilo, procedure <code>__sp__</code></td></tr>
28
+ <tr><th>Digested by</th><td>Testilo, procedure <code>__dp__</code></td></tr>
29
+ <tr>
30
+ <th>Full report</th>
31
+ <td><a href="__reportURL__"><code>__reportURL__</code></a></td>
32
+ </tr>
33
+ </table>
34
+ </header>
35
+ <h2>Introduction</h2>
36
+ <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>
37
+ <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>
38
+ <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, __prevention__ for the page preventing tools from running, __log__ for browser warnings, and __latency__ for delayed page responses.</p>
39
+ <h2>Issue summary</h2>
40
+ <p>This table shows the issues discovered by one or more tools. When an instance count is 0, that means the tool has a test for the issue but the page passed that test.</p>
41
+ <p>Why do instance counts differ among tools? Possibly because the tests are not really equivalent, or a test is unreliable. You can inspect the <a href="__reportURL__">full report</a> to diagnose differences.</p>
42
+ <table class="allBorder thirdCellRight">
43
+ <caption>Summary of issues</caption>
44
+ <thead>
45
+ <tr><th>Issue</th><th>WCAG</th><th>Score</th><th>Instance counts</th></tr>
46
+ </thead>
47
+ <tbody class="headersLeft">
48
+ __issueRows__
49
+ </tbody>
50
+ </table>
51
+ <h2>Itemized issues</h2>
52
+ <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>
53
+ __issueDetailRows__
54
+ <footer>
55
+ <p class="date">Produced <time itemprop="datePublished" datetime="__dateISO__">__dateSlash__</time></p>
56
+ </footer>
57
+ </main>
58
+ </body>
59
+ </html>
@@ -0,0 +1,111 @@
1
+ // index: digester for scoring procedure tsp40.
2
+
3
+ // IMPORTS
4
+
5
+ // Module to keep secrets.
6
+ require('dotenv').config();
7
+ // Module to classify tool rules into issues
8
+ const {issues} = require('../../score/tic40');
9
+ // Module to process files.
10
+ const fs = require('fs/promises');
11
+ // Utility module.
12
+ const {getNowDate, getNowDateSlash} = require('../../util');
13
+
14
+ // CONSTANTS
15
+
16
+ // Digester ID.
17
+ const digesterID = 'tdp41';
18
+ // Newline with indentations.
19
+ const innerJoiner = '\n ';
20
+
21
+ // FUNCTIONS
22
+
23
+ // Gets a row of the score-summary table.
24
+ const getScoreRow = (componentName, score) => `<tr><th>${componentName}</th><td>${score}</td></tr>`;
25
+ // Gets a row of the issue-score-summary table.
26
+ const getIssueScoreRow = (issueConstants, issueDetails) => {
27
+ const {summary, wcag} = issueConstants;
28
+ const {instanceCounts, score} = issueDetails;
29
+ const toolList = Object
30
+ .keys(instanceCounts)
31
+ .map(tool => `<code>${tool}</code>:${instanceCounts[tool]}`)
32
+ .join(', ');
33
+ return `<tr><th>${summary}</th><td class="center">${wcag}<td class="right num">${score}</td><td>${toolList}</td></tr>`;
34
+ };
35
+ // Adds parameters to a query for a digest.
36
+ const populateQuery = (report, query) => {
37
+ const {id, sources, score} = report;
38
+ const {script, target, requester} = sources;
39
+ const {scoreProcID, summary, details} = score;
40
+ query.ts = script;
41
+ query.sp = scoreProcID;
42
+ query.dp = digesterID;
43
+ // Add the job data to the query.
44
+ query.dateISO = getNowDate();
45
+ query.dateSlash = getNowDateSlash();
46
+ query.org = target.what;
47
+ query.url = target.which;
48
+ query.requester = requester;
49
+ query.reportURL = process.env.SCORED_REPORT_URL.replace('__id__', id);
50
+ // Add values for the score-summary table to the query.
51
+ const rows = {
52
+ summaryRows: [],
53
+ issueRows: []
54
+ };
55
+ ['total', 'issueCount', 'issue', 'solo', 'tool', 'prevention', 'log', 'latency']
56
+ .forEach(sumItem => {
57
+ query[sumItem] = summary[sumItem];
58
+ rows.summaryRows.push(getScoreRow(sumItem, query[sumItem]));
59
+ });
60
+ // Sort the issue IDs in descending score order.
61
+ const issueIDs = Object.keys(details.issue);
62
+ issueIDs.sort((a, b) => details.issue[b].score - details.issue[a].score);
63
+ // Get rows for the issue-score table.
64
+ issueIDs.forEach(issueID => {
65
+ if (issues[issueID]) {
66
+ rows.issueRows.push(getIssueScoreRow(issues[issueID], details.issue[issueID]));
67
+ }
68
+ else {
69
+ console.log(`ERROR: Issue ${issueID} not found`);
70
+ }
71
+ });
72
+ // Add the rows to the query.
73
+ ['summaryRows', 'issueRows'].forEach(rowType => {
74
+ query[rowType] = rows[rowType].join(innerJoiner);
75
+ });
76
+ // Add paragraph groups about the issue details to the query.
77
+ const issueDetailRows = [];
78
+ issueIDs.forEach(issueID => {
79
+ issueDetailRows.push(`<h3 class="bars">Issue: ${issues[issueID].summary}</h3>`);
80
+ issueDetailRows.push(`<p>Impact: ${issues[issueID].why || 'N/A'}</p>`);
81
+ issueDetailRows.push(`<p>WCAG: ${issues[issueID].wcag || 'N/A'}</p>`);
82
+ const issueData = details.issue[issueID];
83
+ issueDetailRows.push(`<p>Score: ${issueData.score}</p>`);
84
+ const toolIDs = Object.keys(issueData.tools);
85
+ toolIDs.forEach(toolID => {
86
+ issueDetailRows.push(`<h4>Violations of <code>${toolID}</code> rules</h5>`);
87
+ const ruleIDs = Object.keys(issueData.tools[toolID]);
88
+ ruleIDs.forEach(ruleID => {
89
+ const ruleData = issueData.tools[toolID][ruleID];
90
+ issueDetailRows.push(`<h5>Rule <code>${ruleID}</code></h5>`);
91
+ issueDetailRows.push(`<p>Description: ${ruleData.what}</p>`);
92
+ issueDetailRows.push(`<p>Count of instances: ${ruleData.complaints.countTotal}</p>`);
93
+ });
94
+ });
95
+ });
96
+ query.issueDetailRows = issueDetailRows.join(innerJoiner);
97
+ };
98
+ // Returns a digested report.
99
+ exports.digester = async report => {
100
+ // Create a query to replace placeholders.
101
+ const query = {};
102
+ populateQuery(report, query);
103
+ // Get the template.
104
+ let template = await fs.readFile(`${__dirname}/index.html`, 'utf8');
105
+ // Replace its placeholders.
106
+ Object.keys(query).forEach(param => {
107
+ template = template.replace(new RegExp(`__${param}__`, 'g'), query[param]);
108
+ });
109
+ // Return the digest.
110
+ return template;
111
+ };
package/reconcile.js ADDED
@@ -0,0 +1,18 @@
1
+ /*
2
+ reconcile.js
3
+ Creates a reconciliation report from a scored report.
4
+ Arguments:
5
+ 0. Reconciling function.
6
+ 1. Scored report.
7
+ */
8
+
9
+ // ########## FUNCTIONS
10
+
11
+ // Reconciles the tools in the scored report and returns a reconciliation report.
12
+ exports.reconcile = async (reconciler, report) => {
13
+ // Create a reconciliation report.
14
+ const reconciliation = await reconciler(report);
15
+ console.log(`Report ${report.id} tools reconciled`);
16
+ // Return the reconciliation report.
17
+ return reconciliation;
18
+ };
@@ -29,6 +29,9 @@ caption {
29
29
  font-weight: 700;
30
30
  font-style: italic;
31
31
  }
32
+ .center {
33
+ text-align: center;
34
+ }
32
35
  code {
33
36
  font-family: sans-serif;
34
37
  color: #832703;
@@ -78,9 +81,15 @@ input {
78
81
  legend {
79
82
  font-weight: 700;
80
83
  }
84
+ .num {
85
+ font-family: monospace;
86
+ }
81
87
  pre {
82
88
  white-space: break-spaces;
83
89
  }
90
+ .right {
91
+ text-align: right;
92
+ }
84
93
  .secondCellRight td:nth-child(2) {
85
94
  text-align: right;
86
95
  }