testilo 27.0.0 → 28.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.
package/package.json
CHANGED
|
@@ -16,10 +16,51 @@
|
|
|
16
16
|
<main>
|
|
17
17
|
<header>
|
|
18
18
|
<h1>Accessibility tracking report</h1>
|
|
19
|
-
<h2>Introduction</h2>
|
|
20
|
-
<p>This is tracking report <code>__id__</code>.</p>
|
|
21
|
-
<p>It tracks accessibility scores over time. A perfect score is 0. The tracking was performed by procedure __tp__.</p>
|
|
22
19
|
</header>
|
|
20
|
+
<h2>Introduction</h2>
|
|
21
|
+
<p>This is tracking report <code>__id__</code>.</p>
|
|
22
|
+
<p>It tracks accessibility scores over time. A perfect score is 0. The tracking was performed by Testilo procedure __tp__.</p>
|
|
23
|
+
<p>The results are presented first as a graph, and then as a table.</p>
|
|
24
|
+
<h2>Results as a graph</h2>
|
|
25
|
+
<figure id="graph">
|
|
26
|
+
<figcaption>Accessibility scores</figcaption>
|
|
27
|
+
</figure>
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/d3@7"></script>
|
|
29
|
+
<script src="https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6"></script>
|
|
30
|
+
<script type="module">
|
|
31
|
+
const summaryJSON = '__summaryJSON__';
|
|
32
|
+
const summary = JSON.parse(summaryJSON);
|
|
33
|
+
const graphData = [];
|
|
34
|
+
summary.data.forEach(result => {
|
|
35
|
+
graphData.push({
|
|
36
|
+
target: result.target.what,
|
|
37
|
+
time: new Date(`20${result.endTime}Z`),
|
|
38
|
+
score: result.score
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
const svg = Plot.plot({
|
|
42
|
+
style: 'overflow: visible;',
|
|
43
|
+
y: {grid: true},
|
|
44
|
+
marks: [
|
|
45
|
+
Plot.ruleY([0]),
|
|
46
|
+
Plot.lineY(graphData, {
|
|
47
|
+
x: 'time',
|
|
48
|
+
y: 'score',
|
|
49
|
+
stroke: 'target'
|
|
50
|
+
}),
|
|
51
|
+
Plot.text(graphData, Plot.selectLast({
|
|
52
|
+
x: 'time',
|
|
53
|
+
y: 'score',
|
|
54
|
+
z: 'target',
|
|
55
|
+
text: 'target',
|
|
56
|
+
textAnchor: 'start',
|
|
57
|
+
dx: 3
|
|
58
|
+
}))
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
document.getElementById('graph').insertAdjacentElement('beforeend', svg);
|
|
62
|
+
</script>
|
|
63
|
+
<h2>Results as a table</h2>
|
|
23
64
|
<table class="allBorder secondCellRight thirdCellRight">
|
|
24
65
|
<caption>Accessibility scores</caption>
|
|
25
66
|
<thead>
|
|
@@ -21,12 +21,19 @@ const digestURL = process.env.DIGEST_URL;
|
|
|
21
21
|
// FUNCTIONS
|
|
22
22
|
|
|
23
23
|
// Adds parameters to a query for a tracking report.
|
|
24
|
-
const populateQuery = (id, summary, query) => {
|
|
24
|
+
const populateQuery = async (id, summary, query) => {
|
|
25
25
|
// General parameters.
|
|
26
26
|
query.id = id;
|
|
27
27
|
query.tp = trackerID;
|
|
28
28
|
query.dateISO = getNowDate();
|
|
29
29
|
query.dateSlash = getNowDateSlash();
|
|
30
|
+
// JSON of pruned summary.
|
|
31
|
+
summary.data.forEach(result => {
|
|
32
|
+
delete result.id;
|
|
33
|
+
delete result.target.id;
|
|
34
|
+
delete result.target.which;
|
|
35
|
+
});
|
|
36
|
+
query.summaryJSON = JSON.stringify(summary);
|
|
30
37
|
// For each score:
|
|
31
38
|
const rows = [];
|
|
32
39
|
const results = summary.data;
|
|
@@ -51,7 +58,7 @@ const populateQuery = (id, summary, query) => {
|
|
|
51
58
|
exports.tracker = async (id, summary) => {
|
|
52
59
|
// Create a query to replace placeholders.
|
|
53
60
|
const query = {};
|
|
54
|
-
populateQuery(id, summary, query);
|
|
61
|
+
await populateQuery(id, summary, query);
|
|
55
62
|
// Get the template.
|
|
56
63
|
let template = await fs.readFile(`${__dirname}/index.html`, 'utf8');
|
|
57
64
|
// Replace its placeholders.
|