diff --git a/e2e/helpers/konva-testing.helpers.ts b/e2e/helpers/konva-testing.helpers.ts index 6b02fe24..51f30b2f 100644 --- a/e2e/helpers/konva-testing.helpers.ts +++ b/e2e/helpers/konva-testing.helpers.ts @@ -50,12 +50,10 @@ export const getByShapeType = async ( } }; -export const getCanvasSelectedComponentList = async ( - page: Page -): Promise => { - const layer = await getLayer(page); - //TODO: find a better way to access Transformer>Nodes. - const transformer = layer?.children?.at(-2) as Transformer; - if (!transformer?._nodes) throw new Error('No transformer selection found'); - return transformer._nodes; -}; +export const getTransformerNodes = async (page: Page): Promise => + await page.evaluate(() => { + const layer = window.__TESTING_KONVA_LAYER__.getLayer(); + const transformer: Transformer | undefined = layer?.findOne('Transformer'); + if (!transformer) throw new Error('Konva transformer not found'); + return transformer?.getNodes(); + }); diff --git a/e2e/multiple-selection.spec.ts b/e2e/multiple-selection.spec.ts index 9bf67267..f8510f1a 100644 --- a/e2e/multiple-selection.spec.ts +++ b/e2e/multiple-selection.spec.ts @@ -1,7 +1,7 @@ import { test, expect } from '@playwright/test'; import { dragAndDrop, - getCanvasSelectedComponentList, + getTransformerNodes, addComponentsToCanvas, } from './helpers'; @@ -22,6 +22,6 @@ test('Should perform multiple selection when dragging and dropping over multiple await dragAndDrop(page, { x: 260, y: 130 }, { x: 1000, y: 550 }); //Assert - const selectedItems = await getCanvasSelectedComponentList(page); - expect(selectedItems.length).toBeGreaterThan(componentsAtCanvas.length - 2); + const selectedItems = await getTransformerNodes(page); + expect(selectedItems.length).toEqual(3); });