testilo 25.0.3 → 25.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "25.0.3",
3
+ "version": "25.1.1",
4
4
  "description": "Prepares and processes Testaro reports",
5
5
  "main": "call.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  <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>
23
23
  <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>
24
24
  <h2>Comparison</h2>
25
- <table class="allBorder">
25
+ <table class="allBorder redBar">
26
26
  <caption>Accessibility scores of web pages</caption>
27
27
  <thead>
28
28
  <tr><th scope="col">Page</th><th scope="col" colspan="2">Score (from best to worst)</tr>
@@ -52,7 +52,7 @@ const getTableBody = async bodyData => {
52
52
  const pageCell = `<th scope="row"><a href="${url}">${org}</a></th>`;
53
53
  const numCell = `<td><a href="testu/digest?jobID=${id}">${score}</a></td>`;
54
54
  // Make the bar width proportional.
55
- const barCell = getBarCell(score, maxScore);
55
+ const barCell = getBarCell(score, maxScore, 25, false);
56
56
  const row = `<tr>${pageCell}${numCell}${barCell}</tr>`;
57
57
  return row;
58
58
  });
@@ -39,7 +39,7 @@
39
39
  <p>This <q>difgest</q> summarizes the differences between the scores from the two accessibility audits referenced in the synopsis above. A perfect score would be 0.</p>
40
40
  <h2>Issue summary</h2>
41
41
  <p>Issues are ordered from the one on which B was most superior to the one on which A was most superior.</p>
42
- <table class="allBorder">
42
+ <table class="allBorder redBar">
43
43
  <caption>Differences in issue scores</caption>
44
44
  <thead>
45
45
  <tr><th>Issue</th><th>WCAG</th><th>Score A</th><th>Score B</th><th>A &minus; B</th><th>A superiority</th><th>B superiority</th></tr>
@@ -20,20 +20,25 @@ const innerJoiner = '\n ';
20
20
 
21
21
  // FUNCTIONS
22
22
 
23
- // Gets a row of the issue-score-summary table.
24
- const getIssueScoreRow = (summary, wcag, scoreA, scoreB, bSuperiorityMax, aSuperiorityMax) => {
23
+ // Gets a row of the issue-score-summary table with a two-column bar graph.
24
+ const getIssueScoreRow = (summary, wcag, scoreA, scoreB, aSuperiorityMax, bSuperiorityMax) => {
25
+ const svgWidthSum = 25;
26
+ const maxSum = aSuperiorityMax + bSuperiorityMax;
27
+ const aSVGWidth = svgWidthSum * aSuperiorityMax / maxSum;
28
+ const bSVGWidth = svgWidthSum * bSuperiorityMax / maxSum;
25
29
  const bSuperiority = scoreA - scoreB;
26
- const barCell = getBarCell(
27
- Math.abs(bSuperiority), bSuperiority > 0 ? bSuperiorityMax : aSuperiorityMax, bSuperiority < 0
28
- );
29
30
  const cells = [
30
31
  `<th>${summary}</th>`,
31
32
  `<td class="center">${wcag}</td>`,
32
33
  `<td class="right">${scoreA}</td>`,
33
34
  `<td class="right">${scoreB}</td>`,
34
35
  `<td class="right">${scoreA - scoreB}</td>`,
35
- bSuperiority < 0 ? barCell : '<td></td>',
36
- bSuperiority > 0 ? barCell : '<td></td>'
36
+ bSuperiority < 0
37
+ ? getBarCell(Math.abs(bSuperiority), aSuperiorityMax, aSVGWidth, true)
38
+ : '<td aria-hidden="true" class="right"></td>',
39
+ bSuperiority > 0
40
+ ? getBarCell(Math.abs(bSuperiority), bSuperiorityMax, bSVGWidth, false)
41
+ : '<td aria-hidden="true"></td>'
37
42
  ];
38
43
  return `<tr>${cells.join('')}</tr>`;
39
44
  };
@@ -75,16 +80,14 @@ const populateQuery = (reportA, reportB, query) => {
75
80
  // Sort the issue data in descending order of B less A scores.
76
81
  issuesData.sort((i, j) => i.scoreB - i.scoreA - j.scoreB + j.scoreA);
77
82
  // Get rows for the issue-score table.
78
- const bSuperiorityMax = Math.max(0, issuesData[0].scoreA - issuesData[0].scoreB);
79
83
  const lastIssue = issuesData[issueIDs.size - 1];
80
84
  const aSuperiorityMax = Math.max(0, lastIssue.scoreB - lastIssue.scoreA);
85
+ const bSuperiorityMax = Math.max(0, issuesData[0].scoreA - issuesData[0].scoreB);
81
86
  const issueRows = [];
82
87
  issuesData.forEach(issueData => {
83
88
  const {id, what, wcag, scoreA, scoreB} = issueData;
84
89
  if (issues[id]) {
85
- issueRows.push(
86
- getIssueScoreRow(what, wcag, scoreA, scoreB, bSuperiorityMax, aSuperiorityMax)
87
- );
90
+ issueRows.push(getIssueScoreRow(what, wcag, scoreA, scoreB, aSuperiorityMax, bSuperiorityMax));
88
91
  }
89
92
  else {
90
93
  console.log(`ERROR: Issue ${id} not found`);
package/procs/util.js CHANGED
@@ -63,12 +63,17 @@ exports.getRandomString = length => {
63
63
  }
64
64
  return chars.join('');
65
65
  };
66
- // Returns a graph bar.
67
- exports.getBarCell = (num, max, isRight = false) => {
68
- // Make the bar width proportional.
69
- const barWidth = 100 * num / max;
70
- const xAtt = isRight ? ` x=${100 - barWidth}%` : '';
71
- const bar = `<rect height="100%"${xAtt} width="${barWidth}%" fill="red"></rect>`;
72
- const barCell = `<td aria-hidden="true"><svg width="100%" height="0.7em">${bar}</svg></td>`;
73
- return barCell;
66
+ // Returns a horizontal SVG graph bar.
67
+ const getSVGBar = (num, max, isRight) => {
68
+ const widthFrac = 100 * num / max;
69
+ const x = isRight ? `${100 - widthFrac}%` : '0';
70
+ return `<rect height="100%" x="${x}" width="${widthFrac}%"></rect>`;
71
+ };
72
+ // Returns a table cell containing an SVG graph bar.
73
+ exports.getBarCell = (num, colMax, svgWidth, isRight = false) => {
74
+ const bar = getSVGBar(num, colMax, isRight);
75
+ const svg = `<svg height="0.7rem" width="${svgWidth}rem">${bar}</svg>`;
76
+ const rightClass = isRight ? ' class="right"' : '';
77
+ const cell = `<td aria-hidden="true"${rightClass}>${svg}</td>`;
78
+ return cell;
74
79
  };