forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dnd.spec.ts
82 lines (62 loc) · 2.2 KB
/
dnd.spec.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
75
76
77
78
79
80
81
82
import { expect } from '@playwright/test'
import { test } from './fixtures'
import { createRandomPage, enterNextBlock } from './utils'
/**
* Drag and Drop tests.
*
* NOTE: x = 30 is an estimation of left position of the drop target.
*/
test('drop to left center', async ({ page }) => {
await createRandomPage(page)
await page.fill('textarea >> nth=0', 'block a')
await enterNextBlock(page)
await page.fill('textarea >> nth=0', 'block b')
await page.press('textarea >> nth=0', 'Escape')
const bullet = page.locator('span.bullet-container >> nth=-1')
const where = page.locator('.ls-block >> nth=0')
await bullet.dragTo(where, {
targetPosition: {
x: 30,
y: (await where.boundingBox()).height * 0.5
}
})
await page.keyboard.press('Escape')
const pageElem = page.locator('.page-blocks-inner')
await expect(pageElem).toHaveText('block b\nblock a', {useInnerText: true})
})
test('drop to upper left', async ({ page }) => {
await createRandomPage(page)
await page.fill('textarea >> nth=0', 'block a')
await enterNextBlock(page)
await page.fill('textarea >> nth=0', 'block b')
await page.press('textarea >> nth=0', 'Escape')
const bullet = page.locator('span.bullet-container >> nth=-1')
const where = page.locator('.ls-block >> nth=0')
await bullet.dragTo(where, {
targetPosition: {
x: 30,
y: 5
}
})
await page.keyboard.press('Escape')
const pageElem = page.locator('.page-blocks-inner')
await expect(pageElem).toHaveText('block b\nblock a', {useInnerText: true})
})
test('drop to bottom left', async ({ page }) => {
await createRandomPage(page)
await page.fill('textarea >> nth=0', 'block a')
await enterNextBlock(page)
await page.fill('textarea >> nth=0', 'block b')
await page.press('textarea >> nth=0', 'Escape')
const bullet = page.locator('span.bullet-container >> nth=-1')
const where = page.locator('.ls-block >> nth=0')
await bullet.dragTo(where, {
targetPosition: {
x: 30,
y: (await where.boundingBox()).height * 0.75
}
})
await page.keyboard.press('Escape')
const pageElem = page.locator('.page-blocks-inner')
await expect(pageElem).toHaveText('block a\nblock b', {useInnerText: true})
})