-
Notifications
You must be signed in to change notification settings - Fork 51
/
basic.test.ts
74 lines (69 loc) · 1.68 KB
/
basic.test.ts
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
import { test, expect } from "@playwright/test";
import {
Examples,
getTestUrl,
trackMouse,
untrackMouse,
addFontStyles,
getListItems,
makeDnd,
waitForList,
} from "./utils";
const POSITIONS = [
[190, 111],
[190, 190],
[190, 263],
[190, 346],
[190, 418],
[190, 501],
];
test.beforeEach(async ({ page }) => {
await page.goto(getTestUrl(Examples.BASIC));
await page.waitForSelector("[data-storyloaded]");
await addFontStyles(page as any);
await waitForList(page);
});
test("dnd the first item to second position", async ({ page }) => {
await trackMouse(page as any);
await makeDnd(page, page.mouse, 1, 2, POSITIONS);
expect(await getListItems(page as any)).toEqual([
"Item 2",
"Item 1",
"Item 3",
"Item 4",
"Item 5",
"Item 6",
]);
await untrackMouse(page as any);
await expect(page).toHaveScreenshot();
});
test("dnd the sixth item to fifth position", async ({ page }) => {
await trackMouse(page as any);
await makeDnd(page, page.mouse, 6, 5, POSITIONS);
expect(await getListItems(page as any)).toEqual([
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 6",
"Item 5",
]);
await untrackMouse(page as any);
await expect(page).toHaveScreenshot();
});
test("dnd 1->5, 6->2 and 3->5", async ({ page }) => {
await trackMouse(page as any);
await makeDnd(page, page.mouse, 1, 5, POSITIONS);
await makeDnd(page, page.mouse, 6, 2, POSITIONS);
await makeDnd(page, page.mouse, 3, 5, POSITIONS);
expect(await getListItems(page as any)).toEqual([
"Item 2",
"Item 6",
"Item 4",
"Item 5",
"Item 3",
"Item 1",
]);
await untrackMouse(page as any);
await expect(page).toHaveScreenshot();
});