testilo 13.2.2 → 13.3.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": "13.2.2",
3
+ "version": "13.3.1",
4
4
  "description": "Client that scores and digests Testaro reports",
5
5
  "main": "aim.js",
6
6
  "scripts": {
@@ -56,7 +56,8 @@
56
56
  __issueRows__
57
57
  </tbody>
58
58
  </table>
59
- <h2>Complete report</h2>
59
+ <h2>Issues</h2>
60
+ __issueDetailRows__
60
61
  <pre>__report__</pre>
61
62
  <footer>
62
63
  <p class="date">Produced <time itemprop="datePublished" datetime="__dateISO__">__dateSlash__</time></p>
@@ -30,7 +30,6 @@ const populateQuery = (report, query) => {
30
30
  const {sources, jobData, score} = report;
31
31
  const {script, target, requester} = sources;
32
32
  const {scoreProcID, summary, details} = score;
33
- const {total} = summary;
34
33
  query.ts = script;
35
34
  query.sp = scoreProcID;
36
35
  query.dp = id;
@@ -41,55 +40,51 @@ const populateQuery = (report, query) => {
41
40
  query.url = target.which;
42
41
  query.requester = requester;
43
42
  // Add values for the score-summary table to the query.
44
- ['total', 'issue', 'tool', 'prevention', 'log', 'latency'].forEach(sumItem => {
45
- query[sumItem] = summary[sumItem];
46
- });
47
43
  const rows = {
48
44
  summaryRows: [],
49
45
  issueRows: []
50
46
  };
51
- const componentIDs = ['issues', 'tools', 'preventions', 'log', 'latency'];
52
- ['total'].concat(componentIDs).forEach(itemID => {
53
- if (summary[itemID]) {
54
- rows.summaryRows.push(getScoreRow(itemID, summary[itemID]));
55
- }
47
+ ['total', 'issue', 'tool', 'prevention', 'log', 'latency'].forEach(sumItem => {
48
+ query[sumItem] = summary[sumItem];
49
+ rows.summaryRows.push(getScoreRow(sumItem, query[sumItem]));
56
50
  });
57
- // Get rows for an issue-score table.
58
- Object.keys(details.issue).forEach(issueID => {
51
+ // Sort the issue IDs in descending score order.
52
+ const issueIDs = Object.keys(details.issue);
53
+ issueIDs.sort((a, b) => details.issue[b].score - details.issue[a].score);
54
+ // Get rows for the issue-score table.
55
+ issueIDs.forEach(issueID => {
59
56
  rows.issueRows.push(getScoreRow(issueID, details.issue[issueID].score));
60
57
  });
61
58
  // Add the rows to the query.
62
59
  ['summaryRows', 'issueRows'].forEach(rowType => {
63
60
  query[rowType] = rows[rowType].join(innerJoiner);
64
61
  });
65
- // Add paragraphs about the issues to the query.
66
- const issueSummaryItems = [];
67
- Object.keys(details.issue).forEach(issueID => {
68
- const issueHeading = `<h4>Issue ${issueID}</h4>`;
69
- const wcagP = `<p>WCAG: ${issueClasses[issueID].wcag || 'N/A'}</p>`;
70
- const scoreP = `<p>Score: ${details.issue[issueID]}</p>`;
71
- const issueIntroP = '<p>Issue reports in this category:</p>';
72
- const issueListItems = [];
62
+ // Add paragraph groups about the issue details to the query.
63
+ const issueDetailRows = [];
64
+ issueIDs.forEach(issueID => {
65
+ issueDetailRows.push(`<h3>Issue <code>${issueID}</code></h3>`);
66
+ issueDetailRows.push(`<p>WCAG: ${issueClasses[issueID].wcag || 'N/A'}</p>`);
73
67
  const issueData = details.issue[issueID];
68
+ issueDetailRows.push(`<p>Score: ${issueData.score}</p>`);
74
69
  const toolIDs = Object.keys(issueData.tools);
75
70
  toolIDs.forEach(toolID => {
76
- const testIDs = Object.keys(issueData.tools[toolID]);
77
- testIDs.forEach(testID => {
78
- const testData = issueData.tools[toolID][testID];
79
- const {score, what} = testData;
80
- const listItem =
81
- `<li>Package <code>${toolID}</code>, test <code>${testID}</code>, score ${score} (${what})</li>`;
82
- issueListItems.push(listItem);
71
+ issueDetailRows.push(`<h4>Complaints by <code>${toolID}</code></h5>`);
72
+ const ruleIDs = Object.keys(issueData.tools[toolID]);
73
+ ruleIDs.forEach(ruleID => {
74
+ issueDetailRows.push(`<h5>Rule <code>${ruleID}</code></h5>`);
75
+ issueDetailRows.push(
76
+ `<p>Count of instances: ${issueData.tools[toolID][ruleID].complaints.countTotal}</p>`
77
+ );
78
+ issueDetailRows.push('<h6>Complaint specifics</h6>');
79
+ issueDetailRows.push('<ul>');
80
+ issueData.tools[toolID][ruleID].complaints.texts.forEach(text => {
81
+ issueDetailRows.push(` <li>${htmlEscape(text || '')}</li>`);
82
+ });
83
+ issueDetailRows.push('</ul>');
83
84
  });
84
85
  });
85
- const issueList = [
86
- '<ul>',
87
- issueListItems.join('\n '),
88
- '</ul>'
89
- ].join(joiner);
90
- issueSummaryItems.push(issueHeading, wcagP, scoreP, issueIntroP, issueList);
91
86
  });
92
- query.issueSummary = issueSummaryItems.join(joiner);
87
+ query.issueDetailRows = issueDetailRows.join(innerJoiner);
93
88
  // Add an HTML-safe copy of the report to the query to be appended to the digest.
94
89
  const reportJSON = JSON.stringify(report, null, 2);
95
90
  const reportJSONSafe = htmlEscape(reportJSON);
@@ -97,7 +92,7 @@ const populateQuery = (report, query) => {
97
92
  };
98
93
  // Returns a digested report.
99
94
  exports.digester = async report => {
100
- // Create a query to replace plateholders.
95
+ // Create a query to replace placeholders.
101
96
  const query = {};
102
97
  populateQuery(report, query);
103
98
  // Get the template.