Skip to content

Commit b777a93

Browse files
test: verify that background color changes apply to all selected shapes
1 parent 408d72c commit b777a93

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { test, expect } from '@playwright/test';
2+
import { dragAndDrop, getLocatorPosition, getTransformer } from '../helpers';
3+
import { getShapeBackgroundColor } from '../helpers';
4+
5+
test('when selecting a button and a rectangle, select both, change background color to red, both should update their bg to red', async ({
6+
page,
7+
}) => {
8+
await page.goto('');
9+
10+
// Drag & drop button in canvas
11+
const button = page.getByAltText('Button', { exact: true });
12+
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 });
29+
30+
// Confirm both items are selected
31+
const selectedItems = await getTransformer(page);
32+
expect(selectedItems._nodes.length).toEqual(2);
33+
34+
// Change background color to red
35+
const bgSelector = page
36+
.getByText('Background')
37+
.locator('..')
38+
.locator('button');
39+
await bgSelector.click();
40+
41+
const redColorBox = page.locator(
42+
'div[style*="background-color: rgb(221, 0, 0)"]'
43+
);
44+
await redColorBox.click();
45+
46+
// Verify that both items have red background
47+
const buttonBgColor = await getShapeBackgroundColor(page, 'button');
48+
const rectangleBgColor = await getShapeBackgroundColor(page, 'rectangle');
49+
50+
expect(buttonBgColor).toBe('#DD0000');
51+
expect(rectangleBgColor).toBe('#DD0000');
52+
});

0 commit comments

Comments
 (0)