flexysnap 0.2.6 → 0.2.7
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/src/testUtils.js +5 -0
- package/src/wireframeUtils.js +7 -7
package/package.json
CHANGED
package/src/testUtils.js
CHANGED
|
@@ -2,6 +2,10 @@ import { test } from '@playwright/test';
|
|
|
2
2
|
|
|
3
3
|
let closePopups = async function(page) {}
|
|
4
4
|
|
|
5
|
+
async function callClosePopups(page) {
|
|
6
|
+
await closePopups(page);
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
async function gotoWithRetry(page, url) {
|
|
6
10
|
try {
|
|
7
11
|
logTimestamp('Loading ' + url);
|
|
@@ -209,6 +213,7 @@ export {
|
|
|
209
213
|
rehover,
|
|
210
214
|
scrollToTopOfElement,
|
|
211
215
|
setClosePopups,
|
|
216
|
+
callClosePopups,
|
|
212
217
|
logTimestamp,
|
|
213
218
|
setBaseUrl
|
|
214
219
|
};
|
package/src/wireframeUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { logTimestamp } from './testUtils.js';
|
|
3
|
+
import { logTimestamp, callClosePopups } from './testUtils.js';
|
|
4
4
|
import { loadImage, createCanvas } from 'canvas';
|
|
5
5
|
import { areWireframesStable } from './wireframeStability.js';
|
|
6
6
|
import { resolveWireframeOutputDir } from './wireframeOutput.js';
|
|
@@ -271,11 +271,11 @@ async function extractElementGroupData(page, elementGroup, groupIndex, elementId
|
|
|
271
271
|
}
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
async function extractWireframe(page, elementGroups
|
|
274
|
+
async function extractWireframe(page, elementGroups) {
|
|
275
275
|
const wireframeData = [];
|
|
276
276
|
|
|
277
277
|
for (let groupIndex = 0; groupIndex < elementGroups.length; groupIndex++) {
|
|
278
|
-
|
|
278
|
+
await callClosePopups(page);
|
|
279
279
|
const elementGroupData = await extractElementGroupData(page, elementGroups[groupIndex], groupIndex, FLEXYSNAP_ELEMENT_ID_ATTRIBUTE);
|
|
280
280
|
wireframeData.push(elementGroupData);
|
|
281
281
|
}
|
|
@@ -335,14 +335,14 @@ function cloneElementGroups(elementGroups) {
|
|
|
335
335
|
return elementGroups.map(elementGroup => ({...elementGroup, elements: undefined}));
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
async function extractStableWireframe(page, elementGroups, retryDelay, maxRetryCount
|
|
338
|
+
async function extractStableWireframe(page, elementGroups, retryDelay, maxRetryCount) {
|
|
339
339
|
let previousWireframeData = null;
|
|
340
340
|
let currentWireframeData = null;
|
|
341
341
|
let currentScrollPosition = null;
|
|
342
342
|
|
|
343
343
|
for (let attempt = 0; attempt < maxRetryCount; attempt++) {
|
|
344
344
|
const extractionStartTime = Date.now();
|
|
345
|
-
const extractionResult = await extractWireframe(page, cloneElementGroups(elementGroups)
|
|
345
|
+
const extractionResult = await extractWireframe(page, cloneElementGroups(elementGroups));
|
|
346
346
|
currentWireframeData = extractionResult.wireframeData;
|
|
347
347
|
currentScrollPosition = extractionResult.scrollPosition;
|
|
348
348
|
const extractionDuration = Date.now() - extractionStartTime;
|
|
@@ -368,10 +368,10 @@ async function extractStableWireframe(page, elementGroups, retryDelay, maxRetryC
|
|
|
368
368
|
}
|
|
369
369
|
|
|
370
370
|
async function expectWireframe(page, elementGroups, outputDir, outputFile, outputName, options = {}) {
|
|
371
|
-
const { retryDelay = 1000, maxRetryCount = 10, metadata = {}
|
|
371
|
+
const { retryDelay = 1000, maxRetryCount = 10, metadata = {} } = options;
|
|
372
372
|
|
|
373
373
|
logTimestamp(`Starting wireframe capture for: ${outputFile}`);
|
|
374
|
-
const { wireframeData, scrollPosition } = await extractStableWireframe(page, elementGroups, retryDelay, maxRetryCount
|
|
374
|
+
const { wireframeData, scrollPosition } = await extractStableWireframe(page, elementGroups, retryDelay, maxRetryCount);
|
|
375
375
|
|
|
376
376
|
const screenshotScrollPosition = await page.evaluate(() => ({
|
|
377
377
|
x: window.scrollX,
|