testaro 16.1.0 → 16.3.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.
@@ -1,94 +0,0 @@
1
- /*
2
- allCaps
3
- Related to Tenon rule 153.
4
- This test reports leaf elements whose text contents contain at least one substring of upper-case
5
- letters, hyphen-minuses, and spaces at least 8 characters long and no lower-case letters. Blocks
6
- of upper-case text are difficult to read.
7
- */
8
- // Runs the test and returns the results.
9
- exports.reporter = async (page, withItems) => {
10
- // Identify the elements with upper-case text longer than 7 characters.
11
- const data = await page.$$eval('body *', (elements, withItems) => {
12
- // Returns a space-minimized copy of a string.
13
- const compact = string => string
14
- .replace(/[\t\n]/g, '')
15
- .replace(/\s{2,}/g, ' ')
16
- .trim()
17
- .slice(0, 100);
18
- // Get the leaf elements.
19
- const leafElements = elements.filter(element => ! element.children.length);
20
- // Get those with text contents longer than 7 characters.
21
- const textElements = leafElements.filter(element => compact(element.textContent).length > 7);
22
- // Get those that are reportable.
23
- const allCapElements = textElements.filter(element => {
24
- const {textContent} = element;
25
- const elementText = compact(textContent);
26
- if (elementText === elementText.toUpperCase() && /[-A-Z ]{8}/.test(elementText)) {
27
- return true;
28
- }
29
- else {
30
- const styleDec = window.getComputedStyle(element);
31
- return styleDec['text-transform'] === 'uppercase' && /[-A-Za-z ]{8}/.test(elementText);
32
- }
33
- });
34
- // Initialize the result.
35
- const data = {
36
- total: allCapElements.length
37
- };
38
- // If itemization is required:
39
- if (withItems) {
40
- // Add an itemization to the result.
41
- data.items = [];
42
- allCapElements.forEach(allCapElement => {
43
- data.items.push({
44
- tagName: allCapElement.tagName,
45
- id: allCapElement.id || '',
46
- text: compact(allCapElement.textContent)
47
- });
48
- });
49
- }
50
- return data;
51
- }, withItems);
52
- // Get the totals.
53
- const totals = [data.total, 0, 0, 0];
54
- // Get the required standard instances.
55
- const standardInstances = [];
56
- if (data.items) {
57
- data.items.forEach(item => {
58
- standardInstances.push({
59
- ruleID: 'allCaps',
60
- what: `${item.tagName} element has entirely upper-case text`,
61
- ordinalSeverity: 0,
62
- tagName: item.tagName,
63
- id: item.id,
64
- location: {
65
- doc: '',
66
- type: '',
67
- spec: ''
68
- },
69
- excerpt: item.text
70
- });
71
- });
72
- }
73
- else {
74
- standardInstances.push({
75
- ruleID: 'allCaps',
76
- what: 'Elements have entirely upper-case texts',
77
- ordinalSeverity: 0,
78
- count: data.total,
79
- tagName: '',
80
- id: '',
81
- location: {
82
- doc: '',
83
- type: '',
84
- spec: ''
85
- },
86
- excerpt: ''
87
- });
88
- }
89
- return {
90
- data,
91
- totals,
92
- standardInstances
93
- };
94
- };
@@ -1,86 +0,0 @@
1
- /*
2
- allSlanted
3
- Related to Tenon rule 154.
4
- This test reports leaf elements whose text contents are at least 40 characters long and are
5
- entirely italic or oblique. Blocks of italic or oblique text are difficult to read.
6
- */
7
- // Runs the test and returns the results.
8
- exports.reporter = async (page, withItems) => {
9
- // Identify the elements with text longer than 7 characters.
10
- const data = await page.$$eval('body *', (elements, withItems) => {
11
- // Returns a space-minimized copy of a string.
12
- const compact = string => string
13
- .replace(/[\t\n]/g, '')
14
- .replace(/\s{2,}/g, ' ')
15
- .trim()
16
- .slice(0, 100);
17
- // Get the leaf elements.
18
- const leafElements = elements.filter(element => ! element.children.length);
19
- // Get those with text contents longer than 39 characters.
20
- const textElements = leafElements.filter(element => compact(element.textContent).length > 39);
21
- // Get those with italic or oblique text.
22
- const allSlantedElements = textElements.filter(element => {
23
- const styleDec = window.getComputedStyle(element);
24
- return ['italic', 'oblique'].includes(styleDec['font-style']);
25
- });
26
- // Initialize the result.
27
- const data = {
28
- total: allSlantedElements.length
29
- };
30
- // If itemization is required:
31
- if (withItems) {
32
- // Add an itemization to the result.
33
- data.items = [];
34
- allSlantedElements.forEach(allSlantedElement => {
35
- data.items.push({
36
- tagName: allSlantedElement.tagName,
37
- id: allSlantedElement.id || '',
38
- text: compact(allSlantedElement.textContent)
39
- });
40
- });
41
- }
42
- return data;
43
- }, withItems);
44
- // Get the totals.
45
- const totals = [data.total, 0, 0, 0];
46
- // Get the required standard instances.
47
- const standardInstances = [];
48
- if (data.items) {
49
- data.items.forEach(item => {
50
- standardInstances.push({
51
- ruleID: 'allSlanted',
52
- what: `${item.tagName} element has entirely italic or oblique text`,
53
- ordinalSeverity: 0,
54
- tagName: item.tagName.toUpperCase(),
55
- id: item.id,
56
- location: {
57
- doc: '',
58
- type: '',
59
- spec: ''
60
- },
61
- excerpt: item.text
62
- });
63
- });
64
- }
65
- else {
66
- standardInstances.push({
67
- ruleID: 'allSlanted',
68
- what: 'Elements have entirely italic or oblique texts',
69
- ordinalSeverity: 0,
70
- count: data.total,
71
- tagName: '',
72
- id: '',
73
- location: {
74
- doc: '',
75
- type: '',
76
- spec: ''
77
- },
78
- excerpt: ''
79
- });
80
- }
81
- return {
82
- data,
83
- totals,
84
- standardInstances
85
- };
86
- };
@@ -1,35 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en-US">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Page with deviant hover indicators</title>
6
- <meta name="description" content="tester">
7
- <meta name="viewport" content="width=device-width, initial-scale=1">
8
- <style>
9
- a.qCursor {
10
- cursor: help;
11
- }
12
- li.cursorless {
13
- cursor: none;
14
- }
15
- li.hoverChanger:hover {
16
- color: blue;
17
- background-color: yellow;
18
- }
19
- </style>
20
- </head>
21
- <body>
22
- <main>
23
- <h1>Page with deviant hover indicators</h1>
24
- <p>This page contains a link named <a id="trigger1" class="qCursor" href="https://en.wikipedia.org">Trigger 1</a>. When hovered over, it changes the cursor to a question mark.</p>
25
- <p>This is a list.</p>
26
- <ul>
27
- <li>This Trigger 2 is a normal list item.</li>
28
- <li class="cursorless">This Trigger 3 is a list item that loses its cursor when hovered over.</li>
29
- <li id="li2" class="hoverChanger">This Trigger 4 is a list item that changes when hovered over, although it should not.</li>
30
- </ul>
31
- <p>Trigger 1 has a bad hover cursor. Trigger 3 has no hover cursor. Trigger 4 changes style when hovered over.</p>
32
- <p>Impacts severities: no cursor 3, bad cursor 2, bad indicator 2.
33
- </main>
34
- </body>
35
- </html>