Skip to content

Commit c1ef20c

Browse files
committed
minor refactor
1 parent cbe0352 commit c1ef20c

File tree

2 files changed

+0
-9
lines changed

2 files changed

+0
-9
lines changed

src/lib/processSnapshot.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
669669
if (!Array.isArray(processedOptions[ignoreOrSelectBoxes][viewportString])) processedOptions[ignoreOrSelectBoxes][viewportString] = []
670670

671671
for (const selector of selectors) {
672-
// Handle coordinates validation
673672
if (selector.startsWith('coordinates=')) {
674673
const coordString = selector.replace('coordinates=', '');
675674
const viewportSize = await page.viewportSize();
@@ -687,7 +686,6 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
687686
continue;
688687
}
689688

690-
// Coordinates are valid - create a coordinate element
691689
const coordinateElement = {
692690
type: 'coordinates',
693691
...validation.coords
@@ -708,7 +706,6 @@ export default async function processSnapshot(snapshot: Snapshot, ctx: Context):
708706
if (locator && typeof locator === 'object' && locator.hasOwnProperty('type') && (locator as any).type === 'coordinates') {
709707
const coordLocator = locator as any;
710708
const { top, bottom, left, right } = coordLocator;
711-
// Coordinates already validated, push directly
712709
processedOptions[ignoreOrSelectBoxes][viewportString].push({
713710
left: left,
714711
top: top,

src/lib/utils.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,8 @@ export function validateCoordinates(
518518
viewportString: string
519519
): { valid: boolean, error?: string, coords?: { top: number, bottom: number, left: number, right: number } } {
520520

521-
// Parse coordinates
522521
const coords = coordString.split(',').map(Number);
523522

524-
// Check format
525523
if (coords.length !== 4) {
526524
return {
527525
valid: false,
@@ -531,15 +529,13 @@ export function validateCoordinates(
531529

532530
const [top, bottom, left, right] = coords;
533531

534-
// Check if all values are numbers
535532
if (coords.some(isNaN)) {
536533
return {
537534
valid: false,
538535
error: `for snapshot ${snapshotName} viewport ${viewportString}, invalid coordinate values: ${coordString}. All values must be numbers`
539536
};
540537
}
541538

542-
// Check coordinate bounds
543539
if (top < 0 || left < 0 || bottom < 0 || right < 0) {
544540
return {
545541
valid: false,
@@ -561,7 +557,6 @@ export function validateCoordinates(
561557
};
562558
}
563559

564-
// Check viewport bounds
565560
if (bottom > viewportSize.height) {
566561
return {
567562
valid: false,
@@ -576,7 +571,6 @@ export function validateCoordinates(
576571
};
577572
}
578573

579-
// All validations passed
580574
return {
581575
valid: true,
582576
coords: { top, bottom, left, right }

0 commit comments

Comments
 (0)