testaro 64.9.0 → 64.9.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": "testaro",
3
- "version": "64.9.0",
3
+ "version": "64.9.1",
4
4
  "description": "Run 1000 web accessibility tests from 11 tools and get a standardized report",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -101,3 +101,47 @@ exports.getLocatorData = async loc => {
101
101
  return null;
102
102
  }
103
103
  };
104
+ // Returns location data from the extract of a standard instance.
105
+ exports.getLocationData = async (page, excerpt) => {
106
+ const testaroIDArray = excerpt.match(/data-testaro-id="(\d+)#"/);
107
+ // If the excerpt contains a Testaro identifier:
108
+ if (testaroIDArray) {
109
+ const testaroID = testaroIDArray[1];
110
+ // Return location data for the element.
111
+ return await page.evaluate(testaroID => {
112
+ const element = document.querySelector(`[data-testaro-id="${testaroID}#"]`);
113
+ // If any element has that identifier:
114
+ if (element) {
115
+ // Get box and path IDs for the element.
116
+ const box = {};
117
+ let boxID = '';
118
+ const boundingBox = element.getBoundingClientRect() || {};
119
+ if (boundingBox.x) {
120
+ ['x', 'y', 'width', 'height'].forEach(coordinate => {
121
+ box[coordinate] = Math.round(boundingBox[coordinate]);
122
+ });
123
+ }
124
+ if (typeof box.x === 'number') {
125
+ boxID = Object.values(box).join(':');
126
+ }
127
+ const pathID = window.getXPath(element) || '';
128
+ // Return them.
129
+ return {
130
+ boxID,
131
+ pathID
132
+ };
133
+ }
134
+ // Otherwise, i.e. if no element has it, return empty location data.
135
+ return {};
136
+ }, testaroID);
137
+ }
138
+ // Otherwise, i.e. if the extract contains no Testaro identifier:
139
+ else {
140
+ // Return a non-DOM location.
141
+ return {
142
+ notInDOM: true,
143
+ boxID: '',
144
+ pathID: ''
145
+ };
146
+ }
147
+ };
package/procs/nu.js CHANGED
@@ -15,7 +15,9 @@
15
15
  // ########## IMPORTS
16
16
 
17
17
  // Module to add Testaro IDs to elements.
18
- const {addTestaroIDs, getLocationData} = require('./testaro');
18
+ const {addTestaroIDs} = require('./testaro');
19
+ // Module to get location data from an element.
20
+ const {getLocationData} = require('./getLocatorData');
19
21
  // Module to get the document source.
20
22
  const {getSource} = require('./getSource');
21
23
 
package/procs/testaro.js CHANGED
@@ -234,47 +234,3 @@ exports.addTestaroIDs = async page => {
234
234
  }
235
235
  });
236
236
  };
237
- // Returns location data from the extract of a standard instance.
238
- exports.getLocationData = async (page, excerpt) => {
239
- const testaroIDArray = excerpt.match(/data-testaro-id="(\d+)#"/);
240
- // If the excerpt contains a Testaro identifier:
241
- if (testaroIDArray) {
242
- const testaroID = testaroIDArray[1];
243
- // Return location data for the element.
244
- return await page.evaluate(testaroID => {
245
- const element = document.querySelector(`[data-testaro-id="${testaroID}#"]`);
246
- // If any element has that identifier:
247
- if (element) {
248
- // Get box and path IDs for the element.
249
- const box = {};
250
- let boxID = '';
251
- const boundingBox = element.getBoundingClientRect() || {};
252
- if (boundingBox.x) {
253
- ['x', 'y', 'width', 'height'].forEach(coordinate => {
254
- box[coordinate] = Math.round(boundingBox[coordinate]);
255
- });
256
- }
257
- if (typeof box.x === 'number') {
258
- boxID = Object.values(box).join(':');
259
- }
260
- const pathID = window.getXPath(element) || '';
261
- // Return them.
262
- return {
263
- boxID,
264
- pathID
265
- };
266
- }
267
- // Otherwise, i.e. if no element has it, return empty location data.
268
- return {};
269
- }, testaroID);
270
- }
271
- // Otherwise, i.e. if the extract contains no Testaro identifier:
272
- else {
273
- // Return a non-DOM location.
274
- return {
275
- notInDOM: true,
276
- boxID: '',
277
- pathID: ''
278
- };
279
- }
280
- };
package/tests/htmlcs.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /*
2
2
  © 2022–2024 CVS Health and/or one of its affiliates. All rights reserved.
3
+ © 2025 Jonathan Robert Pool.
3
4
 
4
5
  Licensed under the MIT License. See LICENSE file at the project root or
5
6
  https://opensource.org/license/mit/ for details.
@@ -15,7 +16,9 @@
15
16
  // IMPORTS
16
17
 
17
18
  // Module to add and use unique element IDs.
18
- const {addTestaroIDs, getLocationData} = require('../procs/testaro');
19
+ const {addTestaroIDs} = require('../procs/testaro');
20
+ // Module to get location data from an element.
21
+ const {getLocationData} = require('../procs/getLocatorData');
19
22
  // Module to handle files.
20
23
  const fs = require('fs/promises');
21
24
 
package/tests/wax.js CHANGED
@@ -16,7 +16,9 @@
16
16
  // IMPORTS
17
17
 
18
18
  // Module to add and use unique element IDs.
19
- const {addTestaroIDs, getLocationData} = require('../procs/testaro');
19
+ const {addTestaroIDs} = require('../procs/testaro');
20
+ // Module to get location data from an element.
21
+ const {getLocationData} = require('../procs/getLocatorData');
20
22
  // Modules to run WAX.
21
23
  const runWax = require('@wally-ax/wax-dev');
22
24
  const waxDev = {runWax};