testilo 33.2.0 → 33.2.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/README.md CHANGED
@@ -794,11 +794,15 @@ When a user invokes `summarize` in this example, the `call` module:
794
794
  - creates a _summary report_, an object containing three properties: an ID, a description (here `'divisions'`), and the array of summaries.
795
795
  - writes the summary report in JSON format to the `summarized` subdirectory of the `REPORTDIR` directory, using the ID as the base of the file name.
796
796
 
797
+ #### Summary reports
798
+
799
+ A summary report serves as a necessary input to the `compare` and `track` modules described below. When a user invokes the `compare` module, a summary report is produced. A module can create a summary report by invoking `compare` multiple times on different scored reports, assembling the resulting summaries into an array, and creating an object like the one the `call` module creates for a user.
800
+
797
801
  ### Comparison
798
802
 
799
803
  If you use Testilo to perform a battery of tests on multiple targets, you may want a single report that compares the total scores received by the targets. Testilo can produce such a _comparison_.
800
804
 
801
- The `compare` module compares the scores in a summary report. Its `compare()` function takes two arguments:
805
+ The `compare` module compares the scores in a summary report. The `compare()` function of the `compare` module takes two arguments:
802
806
  - a comparison function
803
807
  - a summary report
804
808
 
@@ -866,7 +870,7 @@ const summaryReport = …;
866
870
  const [reportID, 'main competitors', trackReport] = track(tracker, summaryReport);
867
871
  ```
868
872
 
869
- The `track()` function returns an ID and an HTML tracking report that shows data for all of the results in the summary report and identifies “main competitors” as its subject. The invoking module can further dispose of the tracking report as needed.
873
+ The `track()` function returns, as an array, an ID and an HTML tracking report that shows data for all of the results in the summary report and identifies “main competitors” as its subject. The invoking module can further dispose of the tracking report as needed.
870
874
 
871
875
  ##### By a user
872
876
 
@@ -940,4 +944,4 @@ Work on the functionalities of Testaro and Testilo began in 2017. It was named [
940
944
 
941
945
  ## Etymology
942
946
 
943
- “Testilo” means “testing tool” in Esperanto.
947
+ “Testilo” means “testing utility” in Esperanto.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testilo",
3
- "version": "33.2.0",
3
+ "version": "33.2.2",
4
4
  "description": "Prepares and processes Testaro reports",
5
5
  "main": "call.js",
6
6
  "scripts": {
@@ -22,32 +22,44 @@
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
- targetID: result.sources.target.id,
37
- targetWhat: result.sources.target.what,
47
+ targetID: targetIDs[what],
48
+ targetWhat: what,
38
49
  time: new Date(`20${result.endTime}Z`),
39
50
  score: result.score
40
51
  });
41
52
  });
42
53
  const svg = Plot.plot({
43
54
  style: 'overflow: visible;',
55
+ height: 600,
44
56
  y: {grid: true},
45
57
  marks: [
46
58
  Plot.ruleY([0]),
47
59
  Plot.lineY(graphData, {
48
60
  x: 'time',
49
61
  y: 'score',
50
- stroke: 'targetWhat'
62
+ stroke: 'targetID'
51
63
  }),
52
64
  Plot.dot(graphData, {
53
65
  x: 'time',
@@ -83,7 +95,7 @@
83
95
  document.getElementById('graph').insertAdjacentElement('beforeend', svg);
84
96
  </script>
85
97
  <h2>Results as a table</h2>
86
- <table class="allBorder secondCellRight thirdCellRight">
98
+ <table class="allBorder secondCellRight">
87
99
  <caption>Accessibility scores</caption>
88
100
  <thead>
89
101
  <tr>
@@ -31,18 +31,32 @@ const populateQuery = async (id, what, summaryReport, query) => {
31
31
  // JSON of summary report.
32
32
  const {summaries} = summaryReport;
33
33
  query.summaryReportJSON = JSON.stringify(summaryReport);
34
- // For each score:
34
+ // Legend.
35
+
36
+ // Get an array of target descriptions and assign to each an ID.
35
37
  const rows = [];
36
- 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:
37
50
  summaries.forEach(result => {
38
- // Create an HTML table row for it.
51
+ // Create a date-time cell.
39
52
  const timeCell = `<td>${result.endTime}</td>`;
53
+ // Create a score cell.
40
54
  const digestLinkDestination = digestURL.replace('__id__', result.id);
41
55
  const scoreCell = `<td><a href=${digestLinkDestination}>${result.score}</a></td>`;
56
+ // Create a target cell.
42
57
  const {target} = result.sources;
43
- const targetID = alphaNumOf(targetWhats.indexOf(target.what));
44
58
  const targetLink = `<a href="${target.which}">${target.what}</a>`;
45
- const targetCell = `<td>${targetID}: ${targetLink}</td>`;
59
+ const targetCell = `<td>${targetIDs[target.what]}: ${targetLink}</td>`;
46
60
  const row = `<tr>${[timeCell, scoreCell, targetCell].join('')}</tr>`;
47
61
  // Add the row to the array of rows.
48
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
  };