|
1 | 1 | 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'; |
4 | 9 |
|
5 | 10 | test('when selecting a button and a rectangle, select both, change background color to red, both should update their bg to red', async ({ |
6 | 11 | page, |
7 | 12 | }) => { |
8 | 13 | await page.goto(''); |
9 | 14 |
|
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); |
12 | 21 |
|
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); |
29 | 24 |
|
30 | 25 | // Confirm both items are selected |
31 | 26 | const selectedItems = await getTransformer(page); |
|
0 commit comments