Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7227722
commit e8817bc
Showing
5 changed files
with
71 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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.keyboard.press(modKey + '+z') | ||
await page.waitForTimeout(100) | ||
|
||
await expect(page.locator('text="text 1"')).toHaveCount(0) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Page } from '@playwright/test' | ||
|
||
export async function activateNewPage(page: Page) { | ||
await page.click('.ls-block >> nth=0') | ||
await page.waitForTimeout(500) | ||
} | ||
|
||
export async function renamePage(page: Page, new_name: string) { | ||
await page.click('.ls-page-title .page-title') | ||
await page.waitForSelector('input[type="text"]') | ||
await page.fill('input[type="text"]', '') | ||
await page.type('.title input', new_name) | ||
await page.keyboard.press('Enter') | ||
await page.click('.ui__confirm-modal button') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters