Skip to content

Commit b40b0fd

Browse files
feat: add test for thumbpage duplication via arrow icon
1 parent f4bd853 commit b40b0fd

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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 triggered via the arrow icon', async ({
10+
page,
11+
}) => {
12+
await page.goto('');
13+
14+
// Add components to canvas
15+
await addComponentsToCanvas(page, ['Button', 'Combobox']);
16+
17+
await page.getByText('Pages').click();
18+
19+
// Find thumb page
20+
const siblingElement = page.getByText('Page 1', { exact: true });
21+
const thumb = siblingElement.locator('..');
22+
23+
// Select arrow svg inside the thumb container
24+
const svgElement = thumb.locator('span > svg');
25+
await svgElement.click();
26+
27+
// Verify duplicate button exists in the context menu
28+
const duplicateButton = page
29+
.locator('div')
30+
.filter({ hasText: /^Duplicate$/ });
31+
32+
await expect(duplicateButton).toBeVisible();
33+
34+
// Duplicate thumbpage
35+
await duplicateButton.click();
36+
37+
// Verify Page 1 - copy exists and its selected
38+
const pageTwo = page
39+
.getByText('Page 1 - copy', { exact: true })
40+
.locator('..');
41+
await expect(pageTwo).toBeVisible();
42+
43+
// Verify components exist in copy thumb
44+
const buttonInCopyThumb = await getByShapeTypeInThumb(page, 1, 'button');
45+
const comboboxInCopyThumb = await getByShapeTypeInThumb(page, 1, 'combobox');
46+
expect(buttonInCopyThumb).toBeDefined();
47+
expect(comboboxInCopyThumb).toBeDefined();
48+
49+
// Verify components exist in copy canvas
50+
const buttonShape = (await getByShapeType(page, 'button')) as Group;
51+
const comboboxShape = (await getByShapeType(page, 'combobox')) as Group;
52+
expect(buttonShape).toBeDefined();
53+
expect(comboboxShape).toBeDefined();
54+
});

0 commit comments

Comments
 (0)