Skip to content

Commit 85addf7

Browse files
authored
Merge pull request #773 from Lemoncode/feature/#547-duplicate-page-right-click-button
feature/#547 duplicate page right click button
2 parents 6c0ccc5 + d3aba75 commit 85addf7

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { test, expect } from '@playwright/test';
2+
import {
3+
addComponentsToCanvas,
4+
getByShapeType,
5+
getByShapeTypeInThumb,
6+
} from '../helpers';
7+
import { Group } from 'konva/lib/Group';
8+
9+
test('should duplicate thumbpage when trigerred via right click', async ({
10+
page,
11+
}) => {
12+
await page.goto('');
13+
14+
// Add components to canvas
15+
await addComponentsToCanvas(page, ['Button', 'Input']);
16+
17+
await page.getByText('Pages').click();
18+
19+
// Find thumb page and right click
20+
const siblingElement = page.getByText('Page 1', { exact: true });
21+
const thumb = siblingElement.locator('..');
22+
await thumb.click({ button: 'right' });
23+
24+
const duplicateButton = page
25+
.locator('div')
26+
.filter({ hasText: /^Duplicate$/ });
27+
28+
await expect(duplicateButton).toBeVisible();
29+
30+
// Duplicate thumbpage
31+
await duplicateButton.click();
32+
33+
// Verify Page 1 - copy exists and its selected
34+
const pageTwo = page
35+
.getByText('Page 1 - copy', { exact: true })
36+
.locator('..');
37+
await expect(pageTwo).toBeVisible();
38+
39+
// Additional click to force the duplicate thumbnail to finish rendering.
40+
await pageTwo.click();
41+
// Without this click, the React/Konva pipeline does not always update on time and the
42+
// assertions fail intermittently.
43+
44+
// Verify components exist in copy thumb
45+
const buttonInCopyThumb = await getByShapeTypeInThumb(page, 1, 'button');
46+
const inputInCopyThumb = await getByShapeTypeInThumb(page, 1, 'input');
47+
expect(buttonInCopyThumb).toBeDefined();
48+
expect(inputInCopyThumb).toBeDefined();
49+
50+
// Verify components exist in copy canvas
51+
const buttonShape = (await getByShapeType(page, 'button')) as Group;
52+
const inputShape = (await getByShapeType(page, 'input')) as Group;
53+
expect(buttonShape).toBeDefined();
54+
expect(inputShape).toBeDefined();
55+
});

0 commit comments

Comments
 (0)