/
whiteboards.spec.ts
171 lines (140 loc) · 5.15 KB
/
whiteboards.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
import { expect } from '@playwright/test'
import { test } from './fixtures'
import { IsMac } from './utils'
test('enable whiteboards', async ({ page }) => {
await page.evaluate(() => {
window.localStorage.removeItem('ls-onboarding-whiteboard?')
})
await expect(page.locator('.nav-header .whiteboard')).toBeHidden()
await page.click('#head .toolbar-dots-btn')
await page.click('#head .dropdown-wrapper >> text=Settings')
await page.click('.settings-modal a[data-id=features]')
await page.click('text=Whiteboards >> .. >> .ui__toggle')
await page.keyboard.press('Escape')
await expect(page.locator('.nav-header .whiteboard')).toBeVisible()
})
test('create new whiteboard', async ({ page }) => {
await page.click('.nav-header .whiteboard')
await page.click('#tl-create-whiteboard')
await expect(page.locator('.logseq-tldraw')).toBeVisible()
})
test('check if the page contains the onboarding whiteboard', async ({
page,
}) => {
await expect(
page.locator('.tl-text-shape-wrapper >> text=Welcome to')
).toHaveCount(1)
})
test('cleanup the shapes', async ({ page }) => {
if (IsMac) {
await page.keyboard.press('Meta+a')
} else {
await page.keyboard.press('Control+a')
}
await page.keyboard.press('Delete')
await expect(page.locator('[data-type=Shape]')).toHaveCount(0)
})
test('can right click title to show context menu', async ({ page }) => {
await page.click('.whiteboard-page-title', {
button: 'right',
})
await expect(page.locator('#custom-context-menu')).toBeVisible()
await page.keyboard.press('Escape')
await expect(page.locator('#custom-context-menu')).toHaveCount(0)
})
test('set whiteboard title', async ({ page }) => {
const title = 'my-whiteboard'
// Newly created whiteboard should have a default title
await expect(page.locator('.whiteboard-page-title .title')).toContainText(
'Untitled'
)
await page.click('.whiteboard-page-title')
await page.fill('.whiteboard-page-title input', title)
await page.keyboard.press('Enter')
await expect(page.locator('.whiteboard-page-title .title')).toContainText(
title
)
await page.click('.whiteboard-page-title')
await page.fill('.whiteboard-page-title input', title + '-2')
await page.keyboard.press('Enter')
// Updating non-default title should pop up a confirmation dialog
await expect(page.locator('.ui__confirm-modal >> .headline')).toContainText(
`Do you really want to change the page name to “${title}-2”?`
)
await page.click('.ui__confirm-modal button')
await expect(page.locator('.whiteboard-page-title .title')).toContainText(
title + '-2'
)
})
test('draw a rectangle', async ({ page }) => {
const canvas = await page.waitForSelector('.logseq-tldraw')
const bounds = (await canvas.boundingBox())!
await page.keyboard.press('r')
await page.mouse.move(bounds.x + 5, bounds.y + 5)
await page.mouse.down()
await page.mouse.move(
bounds.x + bounds.width / 2,
bounds.y + bounds.height / 2
)
await page.mouse.up()
await expect(
page.locator('.logseq-tldraw .tl-positioned-svg rect')
).not.toHaveCount(0)
})
test('zoom in', async ({ page }) => {
await page.click('#tl-zoom-in')
await expect(page.locator('#tl-zoom')).toContainText('125%')
})
test('zoom out', async ({ page }) => {
await page.click('#tl-zoom-out')
await expect(page.locator('#tl-zoom')).toContainText('100%')
})
test('open context menu', async ({ page }) => {
await page.locator('.logseq-tldraw').click({ button: 'right' })
await expect(page.locator('.tl-context-menu')).toBeVisible()
})
test('close context menu on esc', async ({ page }) => {
await page.keyboard.press('Escape')
await expect(page.locator('.tl-context-menu')).toBeHidden()
})
test('quick add another whiteboard', async ({ page }) => {
// create a new board first
await page.click('.nav-header .whiteboard')
await page.click('#tl-create-whiteboard')
await page.click('.whiteboard-page-title')
await page.fill('.whiteboard-page-title input', 'my-whiteboard-3')
await page.keyboard.press('Enter')
const canvas = await page.waitForSelector('.logseq-tldraw')
await canvas.dblclick({
position: {
x: 100,
y: 100,
},
})
const quickAdd$ = page.locator('.tl-quick-search')
await expect(quickAdd$).toBeVisible()
await page.fill('.tl-quick-search input', 'my-whiteboard')
await quickAdd$
.locator('.tl-quick-search-option >> text=my-whiteboard-2')
.first()
.click()
await expect(quickAdd$).toBeHidden()
await expect(
page.locator('.tl-logseq-portal-container >> text=my-whiteboard-2')
).toBeVisible()
})
test('go to another board and check reference', async ({ page }) => {
await page
.locator('.tl-logseq-portal-container >> text=my-whiteboard-2')
.click()
await expect(page.locator('.whiteboard-page-title .title')).toContainText(
'my-whiteboard-2'
)
const pageRefCount$ = page.locator('.whiteboard-page-refs-count')
await expect(pageRefCount$.locator('.open-page-ref-link')).toContainText('1')
await pageRefCount$.click()
await expect(page.locator('.references-blocks')).toBeVisible()
await expect(
page.locator('.references-blocks >> .page-ref >> text=my-whiteboard-3')
).toBeVisible()
})