Skip to content

Commit

Permalink
test(e2e): alias test robustness
Browse files Browse the repository at this point in the history
  • Loading branch information
cnrpman committed Dec 1, 2022
1 parent 7944f2d commit 1702993
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
4 changes: 2 additions & 2 deletions e2e-tests/editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ test('should show text after soft return when node is collapsed #5074', async ({
await expect(page.locator('textarea >> nth=0')).toHaveText('Before soft return\nAfter soft return')

// zoom into the block
await page.click('a.block-control + a')
await page.waitForTimeout(delay)
page.click('a.block-control + a')
await page.waitForNavigation()

// select the block that has the soft return
await page.keyboard.press('ArrowDown')
Expand Down
50 changes: 27 additions & 23 deletions e2e-tests/page-search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,46 +103,52 @@ async function alias_test( block: Block, page: Page, page_name: string, search_k
// alias_test_content_1,
// alias_test_content_2, and
// alias_test_content_3 sequentialy, to validate the target page state
await page.type('textarea >> nth=0', 'alias:: [[' + alias_name)
await page.press('textarea >> nth=0', 'Enter') // Enter for finishing selection
await page.press('textarea >> nth=0', 'Enter') // double Enter for exit property editing
await page.press('textarea >> nth=0', 'Enter') // double Enter for exit property editing
await lastBlock(page)
await page.type('textarea >> nth=0', 'alias:: [[' + alias_name, {delay: 10})
await page.keyboard.press('Enter', {delay: 200}) // Enter for finishing selection
await page.keyboard.press('Enter', {delay: 200}) // double Enter for exit property editing
await page.keyboard.press('Enter', {delay: 200}) // double Enter for exit property editing
await page.waitForTimeout(200)
await block.activeEditing(1)
await page.type('textarea >> nth=0', alias_test_content_1)
await lastBlock(page)
await page.keyboard.press(hotkeyBack)
page.keyboard.press(hotkeyBack)

await page.waitForTimeout(100) // await navigation
await page.waitForNavigation()
// create alias ref in origin Page
await newBlock(page)
await page.type('textarea >> nth=0', '[[' + alias_name)
await page.press('textarea >> nth=0', 'Enter') // Enter for finishing selection
await block.activeEditing(0)
await block.enterNext()
await page.type('textarea >> nth=0', '[[' + alias_name, {delay: 20})
await page.keyboard.press('Enter') // Enter for finishing selection
await page.waitForTimeout(100)

await page.keyboard.press(hotkeyOpenLink)
await page.waitForTimeout(100) // await navigation
page.keyboard.press(hotkeyOpenLink)
await page.waitForNavigation()

// shortcut opening test
await lastBlock(page)
await block.activeEditing(1)
expect(await page.inputValue('textarea >> nth=0')).toBe(alias_test_content_1)

await enterNextBlock(page)
await page.type('textarea >> nth=0', alias_test_content_2)
await page.keyboard.press(hotkeyBack)
page.keyboard.press(hotkeyBack)

await page.waitForNavigation()
// pressing enter on alias opening test
await lastBlock(page)
await block.activeEditing(1)
await page.press('textarea >> nth=0', 'ArrowLeft')
await page.press('textarea >> nth=0', 'ArrowLeft')
await page.press('textarea >> nth=0', 'ArrowLeft')
await page.press('textarea >> nth=0', 'Enter')
await lastBlock(page)
page.press('textarea >> nth=0', 'Enter')
await page.waitForNavigation()
await block.activeEditing(2)
expect(await page.inputValue('textarea >> nth=0')).toBe(alias_test_content_2)
await newInnerBlock(page)
await page.type('textarea >> nth=0', alias_test_content_3)
await page.keyboard.press(hotkeyBack)

page.keyboard.press(hotkeyBack)

await page.waitForNavigation()
// clicking alias ref opening test
await block.activeEditing(1)
await block.enterNext()
await page.waitForSelector('.page-blocks-inner .ls-block .page-ref >> nth=-1')
await page.click('.page-blocks-inner .ls-block .page-ref >> nth=-1')
Expand Down Expand Up @@ -172,7 +178,6 @@ async function alias_test( block: Block, page: Page, page_name: string, search_k
// test search entering (page)
page.keyboard.press("Enter")
await page.waitForNavigation()
await page.waitForTimeout(100)
await lastBlock(page)
expect(await page.inputValue('textarea >> nth=0')).toBe(alias_test_content_3)

Expand All @@ -181,10 +186,9 @@ async function alias_test( block: Block, page: Page, page_name: string, search_k
await page.waitForSelector('[placeholder="Search or create page"]')
await page.fill('[placeholder="Search or create page"]', kw_name)
await page.waitForTimeout(500)
page.click(":nth-match(.menu-link, 2)")
page.click(":nth-match(.search-result, 3)")
await page.waitForNavigation()
await page.waitForTimeout(500)
await lastBlock(page)
await block.activeEditing(1)
expect(await page.inputValue('textarea >> nth=0')).toBe("[[" + alias_name + "]]")
await page.keyboard.press(hotkeyBack)
}
Expand Down

0 comments on commit 1702993

Please sign in to comment.