Skip to content

Commit

Permalink
QA improve way to get transformer nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alber-Writer committed Oct 9, 2024
1 parent 1a8cf49 commit ecbc4e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions e2e/helpers/konva-testing.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ export const getByShapeType = async (
}
};

export const getCanvasSelectedComponentList = async (
page: Page
): Promise<Node[]> => {
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<Node[]> =>
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();
});
6 changes: 3 additions & 3 deletions e2e/multiple-selection.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
import {
dragAndDrop,
getCanvasSelectedComponentList,
getTransformerNodes,
addComponentsToCanvas,
} from './helpers';

Expand All @@ -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);
});

0 comments on commit ecbc4e7

Please sign in to comment.