testilo 10.3.1 → 11.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.
Files changed (71) hide show
  1. package/README.md +188 -190
  2. package/batch.js +60 -0
  3. package/call.js +9 -4
  4. package/compare.js +2 -2
  5. package/merge.js +0 -6
  6. package/package.json +1 -1
  7. package/procs/compare/cp20sqrt/index.js +7 -10
  8. package/procs/compare/{cp15b → tcp24}/index.html +5 -5
  9. package/procs/compare/{cp12a → tcp24}/index.js +13 -20
  10. package/procs/score/{tic24.js → tic26.js} +205 -199
  11. package/procs/score/tsp24.js +8 -2
  12. package/procs/score/tsp26.js +120 -0
  13. package/score.js +2 -8
  14. package/procs/compare/cp0/index.html +0 -46
  15. package/procs/compare/cp0/index.js +0 -70
  16. package/procs/compare/cp1/index.html +0 -46
  17. package/procs/compare/cp1/index.js +0 -71
  18. package/procs/compare/cp12a/index.html +0 -47
  19. package/procs/compare/cp12b/index.html +0 -47
  20. package/procs/compare/cp12b/index.js +0 -71
  21. package/procs/compare/cp14a/index.html +0 -47
  22. package/procs/compare/cp14a/index.js +0 -71
  23. package/procs/compare/cp15a/index.html +0 -47
  24. package/procs/compare/cp15a/index.js +0 -71
  25. package/procs/compare/cp15b/index.js +0 -74
  26. package/procs/compare/cp16a/index.html +0 -47
  27. package/procs/compare/cp16a/index.js +0 -74
  28. package/procs/compare/cp16b/index.html +0 -47
  29. package/procs/compare/cp16b/index.js +0 -74
  30. package/procs/digest/dp10a/index.html +0 -137
  31. package/procs/digest/dp10a/index.js +0 -402
  32. package/procs/digest/dp10b/index.html +0 -74
  33. package/procs/digest/dp10b/index.js +0 -130
  34. package/procs/digest/dp10c/index.html +0 -55
  35. package/procs/digest/dp10c/index.js +0 -129
  36. package/procs/digest/dp11a/index.html +0 -76
  37. package/procs/digest/dp11a/index.js +0 -127
  38. package/procs/digest/dp12a/index.html +0 -78
  39. package/procs/digest/dp12a/index.js +0 -126
  40. package/procs/digest/dp12b/index.html +0 -78
  41. package/procs/digest/dp12b/index.js +0 -126
  42. package/procs/digest/dp13a/index.html +0 -78
  43. package/procs/digest/dp13a/index.js +0 -126
  44. package/procs/digest/dp14a/index.html +0 -79
  45. package/procs/digest/dp14a/index.js +0 -126
  46. package/procs/digest/dp15a/index.html +0 -80
  47. package/procs/digest/dp15a/index.js +0 -126
  48. package/procs/digest/dp16a/index.html +0 -80
  49. package/procs/digest/dp16a/index.js +0 -126
  50. package/procs/digest/dp16b/index.html +0 -80
  51. package/procs/digest/dp16b/index.js +0 -126
  52. package/procs/digest/dp18a/index.html +0 -80
  53. package/procs/digest/dp18a/index.js +0 -129
  54. package/procs/digest/dp20c/index.html +0 -54
  55. package/procs/digest/dp20c/index.js +0 -117
  56. package/procs/digest/dp20d/index.html +0 -54
  57. package/procs/digest/dp20d/index.js +0 -121
  58. package/procs/digest/tdp09a/index.html +0 -126
  59. package/procs/digest/tdp09a/index.js +0 -381
  60. package/procs/digest/tdp22/index.html +0 -54
  61. package/procs/digest/tdp22/index.js +0 -120
  62. package/procs/score/tic21.js +0 -6868
  63. package/procs/score/tic22.js +0 -6911
  64. package/procs/score/tic23.js +0 -6924
  65. package/procs/score/tsp21.js +0 -720
  66. package/procs/score/tsp22.js +0 -720
  67. package/procs/score/tsp23.js +0 -720
  68. package/specs/batches/orgs.json +0 -43
  69. package/specs/scripts/ts21.json +0 -213
  70. package/specs/scripts/ts23.json +0 -219
  71. package/specs/scripts/ts24.json +0 -225
package/call.js CHANGED
@@ -124,11 +124,16 @@ const callDigest = async (digesterID, selector = '') => {
124
124
  }
125
125
  };
126
126
  // Fulfills a comparison request.
127
+ // Get the scored reports to be scored.
127
128
  const callCompare = async (compareProcID, comparisonNameBase) => {
128
- await compare(compareProcID, comparisonNameBase);
129
- console.log(
130
- `Comparison completed. Comparison proc: ${compareProcID}. Directory: ${comparisonDir}.`
131
- );
129
+ const reports = await getReports('scored');
130
+ const comparerDir = `${functionDir}/compare/${compareProcID}`;
131
+ const comparisonTemplate = await fs.readFile(`${comparerDir}/index.html`, 'utf8');
132
+ const comparer = require(`${comparerDir}/index`).getQuery;
133
+ const comparison = await compare(comparisonTemplate, comparer, reports);
134
+ const comparisonDir = `${reportDir}/comparative`;
135
+ await fs.writeFile(`${comparisonDir}/${comparisonNameBase}.html`, comparison);
136
+ console.log(`Comparison completed. Proc: ${compareProcID}. Directory: ${comparisonDir}.`);
132
137
  };
133
138
 
134
139
  // ########## OPERATION
package/compare.js CHANGED
@@ -9,11 +9,11 @@
9
9
  const replaceHolders = (template, query) => template
10
10
  .replace(/__([a-zA-Z]+)__/g, (ph, qp) => query[qp]);
11
11
  // Compares the scored reports and returns a comparison.
12
- exports.compare = (comparisonTemplate, comparer, reports) => {
12
+ exports.compare = async (comparisonTemplate, comparer, reports) => {
13
13
  // Create a query.
14
14
  const query = {};
15
15
  // Populate the query.
16
- comparer(reports, query);
16
+ await comparer(reports, query);
17
17
  // Use it to create a comparison.
18
18
  const comparison = replaceHolders(comparisonTemplate, query);
19
19
  // Return the comparison.
package/merge.js CHANGED
@@ -19,14 +19,8 @@ const stdRequester = process.env.REQUESTER;
19
19
  const contaminantNames = new Set([
20
20
  'axe',
21
21
  'continuum',
22
- 'focAll',
23
- 'focInd',
24
- 'focOp',
25
- 'hover',
26
22
  'htmlcs',
27
23
  'ibm',
28
- 'menuNav',
29
- 'textNodes',
30
24
  'wave'
31
25
  ]);
32
26
  // Tests that are immune to page alteration.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "10.3.1",
3
+ "version": "11.0.0",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {
@@ -14,26 +14,24 @@ const fs = require('fs/promises');
14
14
 
15
15
  // ########## CONSTANTS
16
16
 
17
- const reportDirScored = process.env.REPORTDIR_SCORED || 'reports/scored';
18
17
  const query = {};
19
18
 
20
19
  // ########## FUNCTIONS
21
20
 
22
21
  // Returns data on the targets.
23
22
  const getData = async scoredReports => {
24
- const reportCount = scoredReports.length;
25
23
  const bodyData = [];
26
24
  for (const report of scoredReports) {
27
- const {id, host, score} = report;
25
+ const {id, acts, sources, score} = report;
28
26
  bodyData.push({
29
27
  id,
30
- org: host.what,
31
- url: host.which,
28
+ org: sources.target.what,
29
+ url: acts[1].which,
32
30
  score: score.summary.total
33
31
  });
34
32
  };
35
33
  return {
36
- pageCount,
34
+ pageCount: scoredReports.length,
37
35
  bodyData
38
36
  }
39
37
  };
@@ -57,13 +55,12 @@ const getTableBody = async bodyData => {
57
55
  });
58
56
  return rows.join('\n ');
59
57
  };
60
- // Returns a query for a comparative table.
61
- exports.getQuery = async () => {
62
- const data = await getData();
58
+ // Populates a query for a comparative table.
59
+ exports.getQuery = async (scoredReports, query) => {
60
+ const data = await getData(scoredReports);
63
61
  query.pageCount = data.pageCount;
64
62
  query.tableBody = await getTableBody(data.bodyData);
65
63
  const date = new Date();
66
64
  query.dateISO = date.toISOString().slice(0, 10);
67
65
  query.dateSlash = query.dateISO.replace(/-/g, '/');
68
- return query;
69
66
  };
@@ -21,12 +21,12 @@
21
21
  <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>
22
22
  <p>The pages were:</p>
23
23
  <ol id="summary">
24
- <li>Tested by <a href="https://www.npmjs.com/package/testaro">Testaro</a> with procedure <code>tp15</code></li>
25
- <li>Scored by <a href="https://www.npmjs.com/package/testilo">Testilo</a> with procedure <code>sp15c</code></li>
26
- <li>Digested by Testilo with procedure <code>dp15a</code></li>
27
- <li>Compared by Testilo with procedure <code>cp15b</code></li>
24
+ <li>Tested by <a href="https://www.npmjs.com/package/testaro">Testaro</a> with script <code>ts20</code></li>
25
+ <li>Scored by <a href="https://www.npmjs.com/package/testilo">Testilo</a> with procedure <code>sp20b</code></li>
26
+ <li>Digested by Testilo with procedure <code>dp20d</code></li>
27
+ <li>Compared by Testilo with procedure <code>cp20a</code></li>
28
28
  </ol>
29
- <p>The Testaro procedure performs 1230 tests on each page. Of these, 24 tests are custom tests defined by Testaro, and the others belong to packages of tests created by others.</p>
29
+ <p>The script made Testaro perform 1230 automated accessibility tests drawn from nine different packages: Alfa, Axe, Continuum, Equal Access, HTML CodeSniffer, Nu Html Checker, Tenon, Testaro, and WAVE. The scoring procedure made Testilo assign a score to each page, with 0 being perfect.</p>
30
30
  <h2>Comparison</h2>
31
31
  <table class="allBorder">
32
32
  <caption>Accessibility scores of web pages</caption>
@@ -1,6 +1,6 @@
1
1
  /*
2
- cp12a.js
3
- Returns a query for an HTML page including a bar-graph table.
2
+ cp24.js
3
+ Returns a query for replacing placeholders in the associated template.
4
4
  */
5
5
 
6
6
  // ########## IMPORTS
@@ -12,31 +12,24 @@ const fs = require('fs/promises');
12
12
 
13
13
  // ########## CONSTANTS
14
14
 
15
- const reportDirScored = process.env.REPORTDIR_SCORED || 'reports/scored';
16
15
  const query = {};
17
16
 
18
17
  // ########## FUNCTIONS
19
18
 
20
- // Returns data on the hosts in the report directory.
21
- const getData = async () => {
22
- const reportDirAbs = `${__dirname}/../../../${reportDirScored}`;
23
- const reportFileNamesAll = await fs.readdir(reportDirAbs);
24
- const reportFileNamesSource = reportFileNamesAll.filter(fileName => fileName.endsWith('.json'));
25
- const pageCount = reportFileNamesSource.length;
19
+ // Returns data on the targets.
20
+ const getData = async scoredReports => {
26
21
  const bodyData = [];
27
- for (const fileName of reportFileNamesSource) {
28
- const fileJSON = await fs.readFile(`${reportDirAbs}/${fileName}`, 'utf8');
29
- const file = JSON.parse(fileJSON);
30
- const {id, host, score} = file;
22
+ for (const report of scoredReports) {
23
+ const {id, acts, sources, score} = report;
31
24
  bodyData.push({
32
25
  id,
33
- org: host.what,
34
- url: host.which,
26
+ org: sources.target.what,
27
+ url: acts[1].which,
35
28
  score: score.summary.total
36
29
  });
37
30
  };
38
31
  return {
39
- pageCount,
32
+ pageCount: scoredReports.length,
40
33
  bodyData
41
34
  }
42
35
  };
@@ -51,6 +44,7 @@ const getTableBody = async bodyData => {
51
44
  const {id, org, url, score} = item;
52
45
  const pageCell = `<th scope="row"><a href="${url}">${org}</a></th>`;
53
46
  const numCell = `<td><a href="digests/${id}.html">${score}</a></td>`;
47
+ // Make the bar width proportional.
54
48
  const barWidth = 100 * score / maxScore;
55
49
  const bar = `<rect height="100%" width="${barWidth}%" fill="red"></rect>`;
56
50
  const barCell = `<td aria-hidden="true"><svg width="100%" height="0.7em">${bar}</svg></td>`;
@@ -59,13 +53,12 @@ const getTableBody = async bodyData => {
59
53
  });
60
54
  return rows.join('\n ');
61
55
  };
62
- // Returns a query for a comparative table.
63
- exports.getQuery = async () => {
64
- const data = await getData();
56
+ // Populates a query for a comparative table.
57
+ exports.getQuery = async (scoredReports, query) => {
58
+ const data = await getData(scoredReports);
65
59
  query.pageCount = data.pageCount;
66
60
  query.tableBody = await getTableBody(data.bodyData);
67
61
  const date = new Date();
68
62
  query.dateISO = date.toISOString().slice(0, 10);
69
63
  query.dateSlash = query.dateISO.replace(/-/g, '/');
70
- return query;
71
64
  };