testilo 10.0.0 → 10.0.2

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/call.js CHANGED
@@ -100,7 +100,7 @@ const callScore = async (scorerID, selector = '') => {
100
100
  // Fulfills a digesting request.
101
101
  const callDigest = async (digesterID, selector = '') => {
102
102
  // Get the scored reports to be digested.
103
- const reports = getReports('scored', selector);
103
+ const reports = await getReports('scored', selector);
104
104
  // If any exist:
105
105
  if (reports.length) {
106
106
  const digesterDir = `${functionDir}/digest/${digesterID}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "10.0.0",
3
+ "version": "10.0.2",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {
@@ -0,0 +1,54 @@
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>__totalScore__</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 results from a battery of accessibility Tests.</p>
33
+ <p>The battery includes 1351 automated accessibility tests drawn from ten different packages: Alfa, Axe, Continuum, Equal Access, HTML CodeSniffer, Nu Html Checker, QualWeb, Tenon, Testaro, and WAVE.</p>
34
+ <p>These tests were run on the web page named above and gave the page a score of __totalScore__, where 0 would be <q>perfect</q>.</p>
35
+ <h2>Score summary</h2>
36
+ <table class="allBorder secondCellRight">
37
+ <caption>Score components</caption>
38
+ <tbody class="headersLeft">
39
+ __scoreRows__
40
+ </tbody>
41
+ </table>
42
+ <h2>Issue summary</h2>
43
+ <h3>Special issues</h3>
44
+ __specialSummary__
45
+ <h3>Classified issues</h3>
46
+ __groupSummary__
47
+ <h2>Complete report</h2>
48
+ <pre>__report__</pre>
49
+ <footer>
50
+ <p class="date">Produced <time itemprop="datePublished" datetime="__dateISO__">__dateSlash__</time></p>
51
+ </footer>
52
+ </main>
53
+ </body>
54
+ </html>
@@ -0,0 +1,121 @@
1
+ /*
2
+ index: digester for scoring procedure tsp22.
3
+ Creator of parameters for substitution into index.html.
4
+ */
5
+
6
+ // CONSTANTS
7
+
8
+ // Newlines with indentations.
9
+ const joiner = '\n ';
10
+ const innerJoiner = '\n ';
11
+ const specialMessages = {
12
+ log: 'This is based on the amount of browser error logging and miscellaneous logging during the tests.',
13
+ preventions: 'This is based on tests that the page did not allow to be run. That impedes accessibility progress and risks interfering with tools that users with disabilities need.',
14
+ solos: 'This is based on issues reported by unclassified tests. Details are in the report.'
15
+ };
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 = (component, score) => `<tr><th>${component}</th><td>${score}</td></tr>`;
26
+ // Gets the start of a paragraph about a special score.
27
+ const getSpecialPStart = (summary, scoreID) =>
28
+ `<p><span class="componentID">${scoreID}</span>: Score ${summary[scoreID]}.`;
29
+ // Adds parameters to a query for a digest.
30
+ exports.makeQuery = (report, query) => {
31
+ // Add an HTML-safe copy of the report to the query to be appended to the digest.
32
+ const {job, jobData, score} = report;
33
+ const {sources} = job;
34
+ const {host, requester} = sources;
35
+ const reportJSON = JSON.stringify(report, null, 2);
36
+ const reportJSONSafe = htmlEscape(reportJSON);
37
+ query.report = reportJSONSafe;
38
+ query.ts = 'ts21';
39
+ query.sp = 'tsp22';
40
+ query.dp = 'tdp22';
41
+ // Add the job data to the query.
42
+ query.dateISO = jobData.endTime.slice(0, 10);
43
+ query.dateSlash = query.dateISO.replace(/-/g, '/');
44
+ query.org = host.what;
45
+ query.url = host.which;
46
+ query.requester = requester;
47
+ const {groupDetails, summary} = score;
48
+ const {total, groups} = summary;
49
+ if (typeof total === 'number') {
50
+ query.totalScore = total;
51
+ }
52
+ else {
53
+ console.log('ERROR: missing or invalid total score');
54
+ return;
55
+ }
56
+ // Add the total and any special rows of the score-summary table to the query.
57
+ const scoreRows = [];
58
+ const specialComponentIDs = ['log', 'preventions', 'solos'];
59
+ ['total'].concat(specialComponentIDs).forEach(item => {
60
+ if (summary[item]) {
61
+ scoreRows.push(getScoreRow(item, summary[item]));
62
+ }
63
+ });
64
+ // Add the group rows of the score-summary table to the query.
65
+ groups.forEach(group => {
66
+ scoreRows.push(getScoreRow(`${group.groupName}`, group.score));
67
+ });
68
+ query.scoreRows = scoreRows.join(innerJoiner);
69
+ // If the score has any special components:
70
+ const scoredSpecialIDs = specialComponentIDs.filter(item => summary[item]);
71
+ if (scoredSpecialIDs.length) {
72
+ // Add paragraphs about them for the issue summary to the query.
73
+ const specialPs = [];
74
+ scoredSpecialIDs.forEach(id => {
75
+ specialPs.push(`${getSpecialPStart(summary, id)} ${specialMessages[id]}`);
76
+ });
77
+ query.specialSummary = specialPs.join(joiner);
78
+ }
79
+ // Otherwise, i.e. if the score has no special components:
80
+ else {
81
+ // Add a paragraph stating this for the issue summary to the query.
82
+ query.specialSummary = '<p>No special issues contributed to the score.</p>'
83
+ }
84
+ // If the score has any classified issues as components:
85
+ if (groups.length) {
86
+ // Add paragraphs about them for the group summary to the query.
87
+ const groupSummaryItems = [];
88
+ groups.forEach(group => {
89
+ const {groupName, score} = group;
90
+ const groupHeading = `<h4>Issue ${groupName}</h4>`;
91
+ const wcagP = `<p>WCAG: ${groupDetails.groups[groupName].wcag || 'N/A'}</p>`;
92
+ const scoreP = `<p>Score: ${score}</p>`;
93
+ const issueIntroP = '<p>Issue reports in this category:</p>';
94
+ const groupListItems = [];
95
+ const groupData = groupDetails.groups[groupName];
96
+ const packageIDs = Object.keys(groupData);
97
+ packageIDs.forEach(packageID => {
98
+ const testIDs = Object.keys(groupData.packages[packageID]);
99
+ testIDs.forEach(testID => {
100
+ const testData = groupData.packages[packageID][testID];
101
+ const {score, what} = testData;
102
+ const listItem =
103
+ `<li>Package <code>${packageID}</code>, test <code>${testID}</code>, score ${score} (${what})</li>`;
104
+ groupListItems.push(listItem);
105
+ });
106
+ });
107
+ const groupList = [
108
+ '<ul>',
109
+ groupListItems.join('\n '),
110
+ '</ul>'
111
+ ].join(joiner);
112
+ groupSummaryItems.push(groupHeading, wcagP, scoreP, issueIntroP, groupList);
113
+ });
114
+ query.groupSummary = groupSummaryItems.join(joiner);
115
+ }
116
+ // Otherwise, i.e. if the score has no classified issues as components:
117
+ else {
118
+ // Add a paragraph stating this for the group summary to the query.
119
+ query.groupSummary = '<p>No classified issues contributed to the score.</p>'
120
+ }
121
+ };