-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathmove-shape-using-keyboard.spec.ts
More file actions
111 lines (78 loc) · 3.39 KB
/
Copy pathmove-shape-using-keyboard.spec.ts
File metadata and controls
111 lines (78 loc) · 3.39 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
import { test, expect } from '@playwright/test';
import {
dragAndDrop,
getLocatorPosition,
getByShapeType,
getShapePosition,
moveSelected,
} from '../helpers';
import { Group } from 'konva/lib/Group';
const numShifts: number = 10;
test('move shape with the keyboard - left', async ({ page }) => {
await page.goto('');
const component = page.getByAltText('Input', { exact: true });
const position = await getLocatorPosition(component);
await dragAndDrop(page, position, {
x: position.x + 500,
y: position.y - 240,
});
const inputShape = (await getByShapeType(page, 'input')) as Group;
expect(inputShape).toBeDefined();
const draggedPosition = await getShapePosition(inputShape);
moveSelected(page, 'ArrowLeft', numShifts);
const inputShapeMoved = (await getByShapeType(page, 'input')) as Group;
const movedPosition = await getShapePosition(inputShapeMoved);
expect(movedPosition.x === draggedPosition.x - numShifts * 2).toBeTruthy();
expect(movedPosition.y === draggedPosition.y).toBeTruthy();
});
test('move shape with the keyboard - up', async ({ page }) => {
await page.goto('');
const component = page.getByAltText('Input', { exact: true });
const position = await getLocatorPosition(component);
await dragAndDrop(page, position, {
x: position.x + 500,
y: position.y - 240,
});
const inputShape = (await getByShapeType(page, 'input')) as Group;
expect(inputShape).toBeDefined();
const draggedPosition = await getShapePosition(inputShape);
moveSelected(page, 'ArrowUp', numShifts);
const inputShapeMoved = (await getByShapeType(page, 'input')) as Group;
const movedPosition = await getShapePosition(inputShapeMoved);
expect(movedPosition.x === draggedPosition.x).toBeTruthy();
expect(movedPosition.y === draggedPosition.y - numShifts * 2).toBeTruthy();
});
test('move shape with the keyboard - down', async ({ page }) => {
await page.goto('');
const component = page.getByAltText('Input', { exact: true });
const position = await getLocatorPosition(component);
await dragAndDrop(page, position, {
x: position.x + 500,
y: position.y - 240,
});
const inputShape = (await getByShapeType(page, 'input')) as Group;
expect(inputShape).toBeDefined();
const draggedPosition = await getShapePosition(inputShape);
moveSelected(page, 'ArrowDown', numShifts);
const inputShapeMoved = (await getByShapeType(page, 'input')) as Group;
const movedPosition = await getShapePosition(inputShapeMoved);
expect(movedPosition.x === draggedPosition.x).toBeTruthy();
expect(movedPosition.y === draggedPosition.y + numShifts * 2).toBeTruthy();
});
test('move shape with the keyboard - right', async ({ page }) => {
await page.goto('');
const component = page.getByAltText('Input', { exact: true });
const position = await getLocatorPosition(component);
await dragAndDrop(page, position, {
x: position.x + 500,
y: position.y - 240,
});
const inputShape = (await getByShapeType(page, 'input')) as Group;
expect(inputShape).toBeDefined();
const draggedPosition = await getShapePosition(inputShape);
moveSelected(page, 'ArrowRight', numShifts);
const inputShapeMoved = (await getByShapeType(page, 'input')) as Group;
const movedPosition = await getShapePosition(inputShapeMoved);
expect(movedPosition.x === draggedPosition.x + numShifts * 2).toBeTruthy();
expect(movedPosition.y === draggedPosition.y).toBeTruthy();
});