Skip to content

Commit b08baba

Browse files
refactor(test): use reusable helpers to add components and select all elements in canvas
1 parent a1239f3 commit b08baba

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

e2e/props/multi-select-bg-and-common-props.spec.ts

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
import { test, expect } from '@playwright/test';
2-
import { dragAndDrop, getLocatorPosition, getTransformer } from '../helpers';
3-
import { getShapeBackgroundColor } from '../helpers';
2+
import {
3+
getTransformer,
4+
ComponentWithCategory,
5+
getShapeBackgroundColor,
6+
addComponentsWithDifferentCategoriesToCanvas,
7+
selectAllComponentsInCanvas,
8+
} from '../helpers';
49

510
test('when selecting a button and a rectangle, select both, change background color to red, both should update their bg to red', async ({
611
page,
712
}) => {
813
await page.goto('');
914

10-
// Drag & drop button in canvas
11-
const button = page.getByAltText('Button', { exact: true });
15+
// Add components to canvas
16+
const components: ComponentWithCategory[] = [
17+
{ name: 'Button' }, // Button is in default 'Components' category
18+
{ name: 'Rectangle', category: 'Basic Shapes' },
19+
];
20+
await addComponentsWithDifferentCategoriesToCanvas(page, components);
1221

13-
const position = await getLocatorPosition(button);
14-
const targetPosition = { x: position.x + 500, y: position.y };
15-
await dragAndDrop(page, position, targetPosition);
16-
17-
// Drag & drop rectangle in canvas
18-
await page.getByText('Basic Shapes').click();
19-
const rectangle = page.getByText('Rectangle', { exact: true }).locator('..');
20-
21-
const position2 = await getLocatorPosition(rectangle);
22-
const targetPosition2 = { x: position2.x + 500, y: position2.y - 100 };
23-
await dragAndDrop(page, position2, targetPosition2);
24-
25-
await page.mouse.click(800, 130);
26-
27-
// Perform items selection
28-
await dragAndDrop(page, { x: 260, y: 130 }, { x: 1000, y: 550 });
22+
// Select all components in canvas
23+
await selectAllComponentsInCanvas(page);
2924

3025
// Confirm both items are selected
3126
const selectedItems = await getTransformer(page);

0 commit comments

Comments
 (0)