testilo 33.1.0 → 33.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "33.1.0",
3
+ "version": "33.2.1",
4
4
  "description": "Prepares and processes Testaro reports",
5
5
  "main": "call.js",
6
6
  "scripts": {
@@ -22,47 +22,80 @@
22
22
  <p>It tracks accessibility scores over time. A perfect score is 0. The tracking was performed by Testilo procedure <code>__tp__</code>.</p>
23
23
  <p>The results are presented first as a graph, and then as a table.</p>
24
24
  <h2>Results as a graph</h2>
25
+ <h3>Legend</h3>
26
+ <ul id="legendItems">
27
+ __legendItems__
28
+ </ul>
29
+ <h3>Line graph</h3>
25
30
  <figure id="graph">
26
31
  <figcaption>Accessibility scores</figcaption>
27
32
  </figure>
28
33
  <script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
29
34
  <script src="https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6"></script>
30
- <script type="module">
35
+ <script type="module" defer>
31
36
  const summaryReportJSON = '__summaryReportJSON__';
32
37
  const summaryReport = JSON.parse(summaryReportJSON);
33
38
  const graphData = [];
39
+ const targetIDs = {};
40
+ Array.from(document.getElementById('legendItems').children).forEach(li => {
41
+ const targetData = li.textContent.split(': ');
42
+ targetIDs[targetData[1]] = targetData[0];
43
+ });
34
44
  summaryReport.summaries.forEach(result => {
45
+ const {what} = result.sources.target;
35
46
  graphData.push({
36
- target: result.sources.target.what,
47
+ targetID: targetIDs[what],
48
+ targetWhat: what,
37
49
  time: new Date(`20${result.endTime}Z`),
38
50
  score: result.score
39
51
  });
40
52
  });
41
53
  const svg = Plot.plot({
42
54
  style: 'overflow: visible;',
55
+ height: 600,
43
56
  y: {grid: true},
44
57
  marks: [
45
58
  Plot.ruleY([0]),
46
59
  Plot.lineY(graphData, {
47
60
  x: 'time',
48
61
  y: 'score',
49
- stroke: 'target',
50
- marker: 'circle-stroke'
62
+ stroke: 'targetID'
63
+ }),
64
+ Plot.dot(graphData, {
65
+ x: 'time',
66
+ y: 'score',
67
+ z: 'targetID',
68
+ r: 9
51
69
  }),
52
70
  Plot.text(graphData, {
53
71
  x: 'time',
54
72
  y: 'score',
55
- z: 'target',
56
- text: 'target',
73
+ z: 'targetID',
74
+ text: 'targetID',
75
+ textAnchor: 'middle'
76
+ }),
77
+ Plot.text(graphData, Plot.selectFirst({
78
+ x: 'time',
79
+ y: 'score',
80
+ z: 'targetID',
81
+ text: 'targetWhat',
82
+ textAnchor: 'start',
83
+ dx: 15
84
+ })),
85
+ Plot.text(graphData, Plot.selectLast({
86
+ x: 'time',
87
+ y: 'score',
88
+ z: 'targetID',
89
+ text: 'targetWhat',
57
90
  textAnchor: 'start',
58
- dx: 3
59
- })
91
+ dx: 15
92
+ }))
60
93
  ]
61
94
  });
62
95
  document.getElementById('graph').insertAdjacentElement('beforeend', svg);
63
96
  </script>
64
97
  <h2>Results as a table</h2>
65
- <table class="allBorder secondCellRight thirdCellRight">
98
+ <table class="allBorder secondCellRight">
66
99
  <caption>Accessibility scores</caption>
67
100
  <thead>
68
101
  <tr>
@@ -28,24 +28,35 @@ const populateQuery = async (id, what, summaryReport, query) => {
28
28
  query.tp = trackerID;
29
29
  query.dateISO = getNowDate();
30
30
  query.dateSlash = getNowDateSlash();
31
- // JSON of pruned summary report.
31
+ // JSON of summary report.
32
32
  const {summaries} = summaryReport;
33
- summaries.forEach(result => {
34
- delete result.sources.target.id;
35
- });
36
33
  query.summaryReportJSON = JSON.stringify(summaryReport);
37
- // For each score:
34
+ // Legend.
35
+
36
+ // Get an array of target descriptions and assign to each an ID.
38
37
  const rows = [];
39
- const targetWhats = Array.from(new Set(summaries.map(result => result.sources.target.what))).sort();
38
+ const targets = Array
39
+ .from(new Set(summaries.map(result => result.sources.target.what)))
40
+ .sort()
41
+ .map((targetWhat, index) => [alphaNumOf(index), targetWhat]);
42
+ const targetIDs = {};
43
+ targets.forEach(target => {
44
+ targetIDs[target[1]] = target[0];
45
+ });
46
+ // Add legend items to the query.
47
+ const legendItems = targets.map(target => `<li>${target[0]}: ${target[1]}</li>`);
48
+ query.legendItems = legendItems.join('\n ');
49
+ // For each result:
40
50
  summaries.forEach(result => {
41
- // Create an HTML table row for it.
51
+ // Create a date-time cell.
42
52
  const timeCell = `<td>${result.endTime}</td>`;
53
+ // Create a score cell.
43
54
  const digestLinkDestination = digestURL.replace('__id__', result.id);
44
55
  const scoreCell = `<td><a href=${digestLinkDestination}>${result.score}</a></td>`;
56
+ // Create a target cell.
45
57
  const {target} = result.sources;
46
- const targetID = alphaNumOf(targetWhats.indexOf(target.what));
47
58
  const targetLink = `<a href="${target.which}">${target.what}</a>`;
48
- const targetCell = `<td>${targetID}: ${targetLink}</td>`;
59
+ const targetCell = `<td>${targetIDs[target.what]}: ${targetLink}</td>`;
49
60
  const row = `<tr>${[timeCell, scoreCell, targetCell].join('')}</tr>`;
50
61
  // Add the row to the array of rows.
51
62
  rows.push(row);
package/track.js CHANGED
@@ -18,5 +18,6 @@ exports.track = async (tracker, what, summaryReport) => {
18
18
  // Use the tracker to create a tracking report.
19
19
  const id = getFileID(2);
20
20
  const trackingReport = await tracker(id, what, summaryReport);
21
+ // Return an ID usable for the report and the report.
21
22
  return [id, trackingReport];
22
23
  };