Skip to content

Commit 99480f0

Browse files
remove old logic
1 parent a1c96aa commit 99480f0

File tree

1 file changed

+3
-28
lines changed

1 file changed

+3
-28
lines changed

src/lib/processSnapshot.ts

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,7 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
648648
}
649649

650650
// snapshot options
651-
if (processedOptions.element) {
652-
let l = await page.locator(processedOptions.element).all()
653-
if (l.length === 0) {
654-
throw new Error(`for snapshot ${snapshot.name} viewport ${viewportString}, no element found for selector ${processedOptions.element}`);
655-
} else if (l.length > 1) {
656-
throw new Error(`for snapshot ${snapshot.name} viewport ${viewportString}, multiple elements found for selector ${processedOptions.element}`);
657-
}
658-
} else if (selectors.length) {
651+
if (selectors.length) {
659652
let height = 0;
660653
height = await page.evaluate(() => {
661654
const DEFAULT_HEIGHT = 16384;
@@ -786,32 +779,14 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
786779
elements = Array.from(document.querySelectorAll(selectorValue));
787780
}
788781

789-
let boxes = [];
790-
791-
elements.forEach((element) => {
792-
const boundingBox = element.getBoundingClientRect();
793-
if (boundingBox && boundingBox.width > 0 && boundingBox.height > 0) {
794-
const box = {
795-
top: boundingBox.top + window.scrollY,
796-
left: boundingBox.left + window.scrollX,
797-
right: boundingBox.left + window.scrollX + boundingBox.width,
798-
bottom: boundingBox.top + window.scrollY + boundingBox.height
799-
};
800-
801-
if (box.bottom <= pageHeight && box.top >= 0) {
802-
boxes.push(box);
803-
}
804-
}
805-
});
806-
807-
return boxes;
782+
return elements;
808783

809784
} catch (error) {
810785
}
811786

812787
}, { selectorValue, isXPath });
813788

814-
if (boxes && boxes.length > 1) {
789+
if (boxes && boxes.length >= 1) {
815790
processedOptions[ignoreOrSelectBoxes][viewportString].push(...boxes);
816791
} else {
817792
optionWarnings.add(`for snapshot ${snapshot.name} viewport ${viewportString}, no element found for selector ${selector}`);

0 commit comments

Comments
 (0)