testaro 18.6.0 → 18.7.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 +1 -1
- package/testaro/autocomplete.js +22 -53
- package/testaro/buttonMenu.js +1 -0
package/package.json
CHANGED
package/testaro/autocomplete.js
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
// ########## IMPORTS
|
|
7
7
|
|
|
8
|
+
// Module to perform common operations.
|
|
9
|
+
const {init, report} = require('../procs/testaro');
|
|
8
10
|
// Module to get locator data.
|
|
9
11
|
const {getLocatorData} = require('../procs/getLocatorData');
|
|
10
12
|
|
|
11
13
|
// ########## FUNCTIONS
|
|
12
14
|
|
|
13
|
-
// Runs the test and returns the
|
|
15
|
+
// Runs the test and returns the result.
|
|
14
16
|
exports.reporter = async (
|
|
15
17
|
page,
|
|
16
18
|
withItems,
|
|
@@ -18,23 +20,18 @@ exports.reporter = async (
|
|
|
18
20
|
familyLabels = ['last name', 'surname', 'family name'],
|
|
19
21
|
emailLabels = ['email']
|
|
20
22
|
) => {
|
|
23
|
+
// Initialize the locators and result.
|
|
24
|
+
const all = await init(page, 'input[type=text], input[type=email], input:not([type])');
|
|
25
|
+
// For each locator:
|
|
21
26
|
const autoValues = {
|
|
22
27
|
'given-name': givenLabels,
|
|
23
28
|
'family-name': familyLabels,
|
|
24
29
|
'email': emailLabels
|
|
25
30
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const data = {};
|
|
31
|
-
const totals = [0, 0, 0, 0];
|
|
32
|
-
const standardInstances = [];
|
|
33
|
-
// For each of the inputs:
|
|
34
|
-
for (const loc of locsAll) {
|
|
35
|
-
// If it requires an autocomplete attribute but does not have it:
|
|
36
|
-
const data = await getLocatorData(loc);
|
|
37
|
-
const lcText = data.excerpt.toLowerCase();
|
|
31
|
+
for (const loc of all.allLocs) {
|
|
32
|
+
// Get which autocomplete value, if any, its element needs.
|
|
33
|
+
const elData = await getLocatorData(loc);
|
|
34
|
+
const lcText = elData.excerpt.toLowerCase();
|
|
38
35
|
const neededAutos = Object.keys(autoValues)
|
|
39
36
|
.filter(autoValue => autoValues[autoValue].some(typeLabel => lcText.includes(typeLabel)));
|
|
40
37
|
let neededAuto;
|
|
@@ -44,49 +41,21 @@ exports.reporter = async (
|
|
|
44
41
|
else if (! neededAutos.length && await loc.getAttribute('type') === 'email') {
|
|
45
42
|
neededAuto = 'email';
|
|
46
43
|
}
|
|
44
|
+
// If it needs one:
|
|
47
45
|
if (neededAuto) {
|
|
46
|
+
// If it does not have the one it needs:
|
|
48
47
|
const actualAuto = await loc.getAttribute('autocomplete');
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (withItems) {
|
|
54
|
-
// Add a standard instance.
|
|
55
|
-
standardInstances.push({
|
|
56
|
-
ruleID: 'autocomplete',
|
|
57
|
-
what: `Input is missing an autocomplete attribute with value ${neededAuto}`,
|
|
58
|
-
ordinalSeverity: 2,
|
|
59
|
-
tagName: 'INPUT',
|
|
60
|
-
id: data.id,
|
|
61
|
-
location: data.location,
|
|
62
|
-
excerpt: data.excerpt
|
|
63
|
-
});
|
|
64
|
-
}
|
|
48
|
+
const isBad = actualAuto !== neededAuto;
|
|
49
|
+
if (isBad) {
|
|
50
|
+
// Add the locator to the array of violators.
|
|
51
|
+
all.locs.push([loc, neededAuto]);
|
|
65
52
|
}
|
|
66
53
|
}
|
|
67
54
|
}
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
ordinalSeverity: 2,
|
|
75
|
-
count: totals[2],
|
|
76
|
-
tagName: 'INPUT',
|
|
77
|
-
id: '',
|
|
78
|
-
location: {
|
|
79
|
-
doc: '',
|
|
80
|
-
type: '',
|
|
81
|
-
spec: ''
|
|
82
|
-
},
|
|
83
|
-
excerpt: ''
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
// Return the data.
|
|
87
|
-
return {
|
|
88
|
-
data,
|
|
89
|
-
totals,
|
|
90
|
-
standardInstances
|
|
91
|
-
};
|
|
55
|
+
// Populate and return the result.
|
|
56
|
+
const whats = [
|
|
57
|
+
'Input is missing an autocomplete attribute with value __param__',
|
|
58
|
+
'Inputs are missing applicable autocomplete attributes'
|
|
59
|
+
];
|
|
60
|
+
return await report(withItems, all, 'autocomplete', whats, 2);
|
|
92
61
|
};
|
package/testaro/buttonMenu.js
CHANGED
|
@@ -104,6 +104,7 @@ exports.reporter = async (page, withItems, trialKeySpecs = []) => {
|
|
|
104
104
|
const mbLocAll = page.locator(
|
|
105
105
|
'button[aria-controls][aria-expanded][aria-haspopup=true], button[aria-controls][aria-expanded][aria-haspopup=menu]'
|
|
106
106
|
);
|
|
107
|
+
// For each menu button:
|
|
107
108
|
const mbLocsAll = await mbLocAll.all();
|
|
108
109
|
for (const mbLoc of mbLocsAll) {
|
|
109
110
|
// Get a locator for its menu.
|