-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathcopy-paste.spec.ts
More file actions
158 lines (136 loc) · 5.94 KB
/
Copy pathcopy-paste.spec.ts
File metadata and controls
158 lines (136 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import { test, expect } from '@playwright/test';
import {
addComponentsToCanvas,
dragAndDrop,
getWithinCanvasItemList,
} from '../helpers';
import { E2E_CanvasItemKeyAttrs } from '../helpers/types/e2e-types';
import {
clickCopyUiButton,
clickPasteUiButton,
} from '../helpers/ui-buttons.helpers';
test.describe('Copy/Paste functionality tests', () => {
test.beforeEach(async ({ page }) => {
await page.goto('');
});
test('Should copy and paste a single shape using the ToolBar UI buttons', async ({
page,
}) => {
//Arrange one Input component
const addInputIntoCanvas = ['Input'];
await addComponentsToCanvas(page, addInputIntoCanvas);
//Copy and assert there are only one component within the canvas
await clickCopyUiButton(page);
const insideCanvasItemList = (await getWithinCanvasItemList(
page
)) as E2E_CanvasItemKeyAttrs[];
expect(insideCanvasItemList.length).toEqual(1);
//Paste and assert there are 2 Input Components and that they have different IDs
await clickPasteUiButton(page);
const updatedInsideCanvasItemList = (await getWithinCanvasItemList(
page
)) as E2E_CanvasItemKeyAttrs[];
const [originalComponent, copiedComponent] = updatedInsideCanvasItemList;
expect(updatedInsideCanvasItemList.length).toEqual(2);
expect(originalComponent.shapeType).toEqual(copiedComponent.shapeType);
expect(originalComponent['data-id']).not.toEqual(
copiedComponent['data-id']
);
});
test('Should copy and paste a single shape using keyboard commands', async ({
page,
}) => {
// NOTE: This test has the same steps as the previous one, except for the keyboard commands.
//Arrange one Input component
const addInputIntoCanvas = ['Input'];
await addComponentsToCanvas(page, addInputIntoCanvas);
//Copy and assert there are only one component within the canvas
await page.keyboard.press('ControlOrMeta+c');
const insideCanvasItemList = (await getWithinCanvasItemList(
page
)) as E2E_CanvasItemKeyAttrs[];
expect(insideCanvasItemList.length).toEqual(1);
//Paste and assert there are 2 Input Components and that they have different IDs
await page.keyboard.press('ControlOrMeta+v');
const updatedInsideCanvasItemList = (await getWithinCanvasItemList(
page
)) as E2E_CanvasItemKeyAttrs[];
const [originalComponent, copiedComponent] = updatedInsideCanvasItemList;
expect(updatedInsideCanvasItemList.length).toEqual(2);
expect(originalComponent.shapeType).toEqual(copiedComponent.shapeType);
expect(originalComponent['data-id']).not.toEqual(
copiedComponent['data-id']
);
});
/*
test('Should copy and paste a multiple shapes using the ToolBar UI buttons', async ({
page,
}) => {
//Add several components into the canvas
const addInputIntoCanvas = ['Input', 'Combobox', 'Icon'];
await addComponentsToCanvas(page, addInputIntoCanvas);
//Select items by drag and drop
await dragAndDrop(page, { x: 260, y: 130 }, { x: 1000, y: 550 });
//Copy and assert there are 3 components within the canvas
await clickCopyUiButton(page);
const insideCanvasItemList = (await getWithinCanvasItemList(
page
)) as E2E_CanvasItemKeyAttrs[];
const [originalComp_1, originalComp_2, originalComp_3] =
insideCanvasItemList;
expect(insideCanvasItemList.length).toEqual(3);
//Paste
await clickPasteUiButton(page);
const updatedInsideCanvasItemList = (await getWithinCanvasItemList(
page
)) as E2E_CanvasItemKeyAttrs[];
const [, , , copiedComp_1, copiedComp_2, copiedComp_3] =
updatedInsideCanvasItemList;
//Assert there are 6 Components,
expect(updatedInsideCanvasItemList.length).toEqual(6);
//Assert they match the same shapes respectively
expect(originalComp_1.shapeType).toEqual(copiedComp_1.shapeType);
expect(originalComp_2.shapeType).toEqual(copiedComp_2.shapeType);
expect(originalComp_3.shapeType).toEqual(copiedComp_3.shapeType);
//Assert they have different IDs
expect(originalComp_1['data-id']).not.toEqual(copiedComp_1['data-id']);
expect(originalComp_2['data-id']).not.toEqual(copiedComp_2['data-id']);
expect(originalComp_3['data-id']).not.toEqual(copiedComp_3['data-id']);
});
*/
test('Should copy and paste a multiple shapes using keyboard commands', async ({
page,
}) => {
// NOTE: This test has the same steps as the previous one, except for the keyboard commands.
//Add several components into the canvas
const addInputIntoCanvas = ['Input', 'Combobox', 'Icon'];
await addComponentsToCanvas(page, addInputIntoCanvas);
//Select items by drag and drop
await dragAndDrop(page, { x: 260, y: 130 }, { x: 1000, y: 650 });
//Copy and assert there are 3 components within the canvas
await page.keyboard.press('ControlOrMeta+c');
const insideCanvasItemList = (await getWithinCanvasItemList(
page
)) as E2E_CanvasItemKeyAttrs[];
const [originalComp_1, originalComp_2, originalComp_3] =
insideCanvasItemList;
expect(insideCanvasItemList.length).toEqual(3);
//Paste
await page.keyboard.press('ControlOrMeta+v');
const updatedInsideCanvasItemList = (await getWithinCanvasItemList(
page
)) as E2E_CanvasItemKeyAttrs[];
const [, , , copiedComp_1, copiedComp_2, copiedComp_3] =
updatedInsideCanvasItemList;
//Assert there are 6 Components,
expect(updatedInsideCanvasItemList.length).toEqual(6);
//Assert they match the same shapes respectively
expect(originalComp_1.shapeType).toEqual(copiedComp_1.shapeType);
expect(originalComp_2.shapeType).toEqual(copiedComp_2.shapeType);
expect(originalComp_3.shapeType).toEqual(copiedComp_3.shapeType);
//Assert they have different IDs
expect(originalComp_1['data-id']).not.toEqual(copiedComp_1['data-id']);
expect(originalComp_2['data-id']).not.toEqual(copiedComp_2['data-id']);
expect(originalComp_3['data-id']).not.toEqual(copiedComp_3['data-id']);
});
});