forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhistory.spec.ts
52 lines (37 loc) · 1.76 KB
/
history.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
import { expect } from '@playwright/test'
import { test } from './fixtures'
import { createRandomPage, modKey, searchAndJumpToPage, renamePage, randomString } from './utils'
test('undo/redo on a page should work as expected', async ({ page, block }) => {
const page1 = await createRandomPage(page)
await block.mustType('text 1')
await page.waitForTimeout(500) // Wait for 500ms autosave period to expire
await expect(page.locator('text="text 1"')).toHaveCount(1)
await page.keyboard.press(modKey + '+z')
await page.waitForTimeout(100)
await expect(page.locator('text="text 1"')).toHaveCount(0)
await page.keyboard.press(modKey + '+Shift+z')
await page.waitForTimeout(100)
await expect(page.locator('text="text 1"')).toHaveCount(1)
})
test('should navigate to corresponding page on undo', async ({ page, block }) => {
const page1 = await createRandomPage(page)
await block.mustType('text 1')
await page.waitForTimeout(500) // Wait for 500ms autosave period to expire
const page2 = await createRandomPage(page)
await page.keyboard.press(modKey + '+z')
await page.waitForTimeout(100)
expect(await page.innerText('.page-title .title')).toBe(page1)
await page.keyboard.press(modKey + '+z')
await page.waitForTimeout(100)
await expect(page.locator('text="text 1"')).toHaveCount(0)
})
test('undo/redo of a renamed page should be preserved', async ({ page, block }) => {
const page1 = await createRandomPage(page)
await block.mustType('text 1')
await page.waitForTimeout(500) // Wait for 500ms autosave period to expire
await renamePage(page, randomString(10))
await page.click('.ui__confirm-modal button')
await page.keyboard.press(modKey + '+z')
await page.waitForTimeout(100)
await expect(page.locator('text="text 1"')).toHaveCount(0)
})