From 0c96c94abd55b6bf2a5a84339291914cf646ce1c Mon Sep 17 00:00:00 2001 From: Braulio Date: Thu, 12 Dec 2024 20:01:14 +0100 Subject: [PATCH] fix test --- e2e/helpers/position.helpers.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/e2e/helpers/position.helpers.ts b/e2e/helpers/position.helpers.ts index 6bcf7461..d453c111 100644 --- a/e2e/helpers/position.helpers.ts +++ b/e2e/helpers/position.helpers.ts @@ -1,6 +1,5 @@ import { Locator, Page } from '@playwright/test'; import { Group } from 'konva/lib/Group'; - export interface Position { x: number; y: number; @@ -20,13 +19,17 @@ export const getLocatorPosition = async ( }; export const getCanvasBoundingBox = async (page: Page) => { - const canvasWindowPos = await page - .locator('#konva-stage canvas') - .boundingBox(); + const locator = page.locator('#konva-stage canvas').nth(1); + + // Ensure that the canvas is visible before continuie + await locator.waitFor({ state: 'visible' }); + + const canvasWindowPos = await locator.boundingBox(); + if (canvasWindowPos) { return canvasWindowPos; } else { - throw new Error('Canvas is not loaded on ui'); + throw new Error('Canvas is not loaded on UI'); } };