testilo 17.1.2 → 17.2.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
@@ -344,7 +344,8 @@ This is a valid Testaro job.
344
344
 
345
345
  If, however, you requested a merger **with** isolation, then Testilo would take cognizance of the fact that an `axe` test act is a target-modifying act. Testilo would therefore act as if another instance of the placeholder had been located in the script after the `axe` test act. So, copies of the same 6 acts that precede the `axe` test act would be inserted **after** the `axe` test act, too.
346
346
 
347
- Of the 9 tools providing tests for Testaro, 5 are target-modifying:
347
+ Of the 9 tools providing tests for Testaro, 6 are target-modifying:
348
+ - `alfa`
348
349
  - `aslint`
349
350
  - `axe`
350
351
  - `htmlcs`
package/merge.js CHANGED
@@ -4,7 +4,8 @@
4
4
  Arguments:
5
5
  0. script
6
6
  1. batch
7
- 2. whether to provide test isolation (no if omitted)
7
+ 2. requester
8
+ 3. whether to provide test isolation (no if omitted)
8
9
  */
9
10
 
10
11
  // ########## IMPORTS
@@ -17,6 +18,7 @@ require('dotenv').config();
17
18
  const stdRequester = process.env.REQUESTER;
18
19
  // Tools that alter the page.
19
20
  const contaminantNames = new Set([
21
+ 'alfa',
20
22
  'aslint',
21
23
  'axe',
22
24
  'htmlcs',
@@ -72,8 +74,7 @@ exports.merge = (script, batch, requester, isolate = false) => {
72
74
  act.type === 'test'
73
75
  && contaminantNames.has(act.which)
74
76
  && actIndex < acts.length - 1
75
- && nextAct.type !== 'placeholder'
76
- && (nextAct.type !== 'test')
77
+ && (nextAct.type === 'test')
77
78
  ) {
78
79
  acts[actIndex] = JSON.parse(JSON.stringify([act, lastPlaceholder]));
79
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "17.1.2",
3
+ "version": "17.2.1",
4
4
  "description": "Prepares and processes Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {
@@ -0,0 +1,72 @@
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.png">
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
+ </table>
30
+ </header>
31
+ <h2>Introduction</h2>
32
+ <p>This is a digest of a <a href="__reportURL__">report of results</a> from a battery of <a href="https://www.w3.org/WAI/">web accessibility</a> tests.</p>
33
+ <p>Nine different <dfn>tools</dfn> (Alfa, ASLint, Axe, Equal Access, HTML CodeSniffer, Nu Html Checker, QualWeb, Testaro, and WAVE) tested the web page of __org__ at __url__ to check its compliance with various <dfn>rules</dfn>. There were a total of about 960 rules, classified into about 290 accessibility <dfn>issues</dfn>.</p>
34
+ <p>The results were interpreted to yield an aggregate score of __total__, where 0 would be <q>perfect</q>.</p>
35
+ <h2>Total score</h2>
36
+ <p>The total score is the sum of five components.</p>
37
+ <table class="allBorder secondCellRight">
38
+ <caption>Score summary</caption>
39
+ <thead>
40
+ <tr><th>Component</th><th>Score</th><th>Description</th></tr>
41
+ </thead>
42
+ <tbody class="headersLeft">
43
+ <tr><th>total</th><td>__total__</td><td>Sum of the component scores</td></tr>
44
+ <tr><th>issue</th><td>__issue__</td><td>Severity and number of reported defects</td></tr>
45
+ <tr><th>tool</th><td>__tool__</td><td>Tool-by-tool defect ratings</td></tr>
46
+ <tr><th>prevention</th><td>__prevention__</td><td>Failed attempts by tools to test the page</td></tr>
47
+ <tr><th>log</th><td>__log__</td><td>Browser warnings about the page</td></tr>
48
+ <tr><th>latency</th><td>__latency__</td><td>Abnormal delay in page responses</td></tr>
49
+ </tbody>
50
+ </table>
51
+ <h2>Issue scores</h2>
52
+ <p>The score of an issue depends on the <dfn>severity</dfn> (user impact and certainty) of the issue and on how many instances were reported (by one or more tools).</p>
53
+ <table class="allBorder secondCellRight">
54
+ <caption>Issue scores</caption>
55
+ <thead>
56
+ <tr><th>Issue</th><th>Score</th></tr>
57
+ </thead>
58
+ <tbody class="headersLeft">
59
+ __issueRows__
60
+ </tbody>
61
+ </table>
62
+ <h2>Itemized issues</h2>
63
+ <p>The reported rule violations are itemized below, issue by issue. Additional details can be inspected in the <a href="__reportURL__">complete report</a>.</p>
64
+ __issueDetailRows__
65
+ <h2>Complete report</h2>
66
+ <pre>__report__</pre>
67
+ <footer>
68
+ <p class="date">Produced <time itemprop="datePublished" datetime="__dateISO__">__dateSlash__</time></p>
69
+ </footer>
70
+ </main>
71
+ </body>
72
+ </html>
@@ -0,0 +1,102 @@
1
+ // index: digester for scoring procedure tsp36.
2
+
3
+ // IMPORTS
4
+
5
+ // Module to classify tool rules into issues
6
+ const {issues} = require('../../score/tic36');
7
+ // Module to process files.
8
+ const fs = require('fs/promises');
9
+
10
+ // CONSTANTS
11
+
12
+ // Digester ID.
13
+ const id = 'tdp36';
14
+ // Newline with indentations.
15
+ const innerJoiner = '\n ';
16
+
17
+ // FUNCTIONS
18
+
19
+ // Makes strings HTML-safe.
20
+ const htmlEscape = textOrNumber => textOrNumber
21
+ .toString()
22
+ .replace(/&/g, '&amp;')
23
+ .replace(/</g, '&lt;');
24
+ // Gets a row of the score-summary table.
25
+ const getScoreRow = (componentName, score) => `<tr><th>${componentName}</th><td>${score}</td></tr>`;
26
+ // Adds parameters to a query for a digest.
27
+ const populateQuery = (report, query) => {
28
+ const {sources, jobData, score} = report;
29
+ const {script, target, requester} = sources;
30
+ const {scoreProcID, summary, details} = score;
31
+ query.ts = script;
32
+ query.sp = scoreProcID;
33
+ query.dp = id;
34
+ // Add the job data to the query.
35
+ query.dateISO = jobData.endTime.slice(0, 10);
36
+ query.dateSlash = query.dateISO.replace(/-/g, '/');
37
+ query.org = target.what;
38
+ query.url = target.which;
39
+ query.requester = requester;
40
+ query.reportURL = `${report.id}.json`;
41
+ // Add values for the score-summary table to the query.
42
+ const rows = {
43
+ summaryRows: [],
44
+ issueRows: []
45
+ };
46
+ ['total', 'issue', 'tool', 'prevention', 'log', 'latency'].forEach(sumItem => {
47
+ query[sumItem] = summary[sumItem];
48
+ rows.summaryRows.push(getScoreRow(sumItem, query[sumItem]));
49
+ });
50
+ // Sort the issue IDs in descending score order.
51
+ const issueIDs = Object.keys(details.issue);
52
+ issueIDs.sort((a, b) => details.issue[b].score - details.issue[a].score);
53
+ // Get rows for the issue-score table.
54
+ issueIDs.forEach(issueID => {
55
+ rows.issueRows.push(getScoreRow(issueID, details.issue[issueID].score));
56
+ });
57
+ // Add the rows to the query.
58
+ ['summaryRows', 'issueRows'].forEach(rowType => {
59
+ query[rowType] = rows[rowType].join(innerJoiner);
60
+ });
61
+ // Add paragraph groups about the issue details to the query.
62
+ const issueDetailRows = [];
63
+ issueIDs.forEach(issueID => {
64
+ issueDetailRows.push(`<h3 class="bars">Issue <code>${issueID}</code></h3>`);
65
+ issueDetailRows.push(`<p>Impact: ${issues[issueID].why || 'N/A'}</p>`);
66
+ issueDetailRows.push(`<p>WCAG: ${issues[issueID].wcag || 'N/A'}</p>`);
67
+ const issueData = details.issue[issueID];
68
+ issueDetailRows.push(`<p>Score: ${issueData.score}</p>`);
69
+ const toolIDs = Object.keys(issueData.tools);
70
+ toolIDs.forEach(toolID => {
71
+ issueDetailRows.push(`<h4>Complaints by <code>${toolID}</code></h5>`);
72
+ const ruleIDs = Object.keys(issueData.tools[toolID]);
73
+ ruleIDs.forEach(ruleID => {
74
+ const ruleData = issueData.tools[toolID][ruleID];
75
+ issueDetailRows.push(`<h5>Rule <code>${ruleID}</code></h5>`);
76
+ issueDetailRows.push(`<p>Description: ${ruleData.what}</p>`);
77
+ issueDetailRows.push(`<p>Count of instances: ${ruleData.complaints.countTotal}</p>`);
78
+ issueDetailRows.push('<h6>Complaint specifics</h6>');
79
+ issueDetailRows.push('<ul>');
80
+ ruleData.complaints.texts.forEach(text => {
81
+ issueDetailRows.push(` <li>${htmlEscape(text || '')}</li>`);
82
+ });
83
+ issueDetailRows.push('</ul>');
84
+ });
85
+ });
86
+ });
87
+ query.issueDetailRows = issueDetailRows.join(innerJoiner);
88
+ };
89
+ // Returns a digested report.
90
+ exports.digester = async report => {
91
+ // Create a query to replace placeholders.
92
+ const query = {};
93
+ populateQuery(report, query);
94
+ // Get the template.
95
+ let template = await fs.readFile(`${__dirname}/index.html`, 'utf8');
96
+ // Replace its placeholders.
97
+ Object.keys(query).forEach(param => {
98
+ template = template.replace(new RegExp(`__${param}__`, 'g'), query[param]);
99
+ });
100
+ // Return the digest.
101
+ return template;
102
+ };