2022-04-22 09:29:38 +00:00
|
|
|
import { expect } from '@playwright/test'
|
|
|
|
import { test } from './fixtures'
|
2022-04-26 05:29:02 +00:00
|
|
|
import { createRandomPage, lastBlock, IsMac, IsLinux } from './utils'
|
2022-04-22 09:29:38 +00:00
|
|
|
|
2022-08-18 02:39:08 +00:00
|
|
|
test("Logseq URLs (same graph)", async ({ page, block }) => {
|
2023-11-20 15:26:30 +00:00
|
|
|
try {
|
|
|
|
await page.waitForSelector('.notification-clear', { timeout: 10 })
|
|
|
|
page.click('.notification-clear')
|
|
|
|
} catch (error) {
|
|
|
|
}
|
|
|
|
|
2022-08-18 02:39:08 +00:00
|
|
|
let paste_key = IsMac ? 'Meta+v' : 'Control+v'
|
|
|
|
// create a page with identify block
|
|
|
|
let identify_text = "URL redirect target"
|
|
|
|
let page_title = await createRandomPage(page)
|
|
|
|
await block.mustFill(identify_text)
|
2022-04-22 09:29:38 +00:00
|
|
|
|
2023-02-20 11:44:01 +00:00
|
|
|
// paste current page's URL to another page, then redirect through the URL
|
2022-11-29 05:03:41 +00:00
|
|
|
await page.click('.ui__dropdown-trigger .toolbar-dots-btn')
|
2022-08-18 02:39:08 +00:00
|
|
|
await page.locator("text=Copy page URL").click()
|
|
|
|
await createRandomPage(page)
|
|
|
|
await block.mustFill("") // to enter editing mode
|
|
|
|
await page.keyboard.press(paste_key)
|
2023-03-28 20:03:19 +00:00
|
|
|
// paste returns a promise which is async, so we need give it a little bit
|
|
|
|
// more time
|
|
|
|
await page.waitForTimeout(100)
|
2022-08-18 02:39:08 +00:00
|
|
|
let cursor_locator = page.locator('textarea >> nth=0')
|
|
|
|
expect(await cursor_locator.inputValue()).toContain("page=" + page_title)
|
|
|
|
await cursor_locator.press("Enter")
|
|
|
|
if (IsMac) { // FIXME: support Logseq URL on Linux (XDG)
|
|
|
|
page.locator('a.external-link >> nth=0').click()
|
|
|
|
await page.waitForNavigation()
|
|
|
|
await page.waitForTimeout(500)
|
|
|
|
cursor_locator = await lastBlock(page)
|
|
|
|
expect(await cursor_locator.inputValue()).toBe(identify_text)
|
|
|
|
}
|
2022-04-22 09:29:38 +00:00
|
|
|
|
2023-02-20 11:44:01 +00:00
|
|
|
// paste the identify block's URL to another page, then redirect through the URL
|
2022-08-18 02:39:08 +00:00
|
|
|
await page.click('span.bullet >> nth=0', { button: "right" })
|
|
|
|
await page.locator("text=Copy block URL").click()
|
|
|
|
await createRandomPage(page)
|
|
|
|
await block.mustFill("") // to enter editing mode
|
|
|
|
await page.keyboard.press(paste_key)
|
2023-03-28 20:03:19 +00:00
|
|
|
await page.waitForTimeout(100)
|
2022-08-18 02:39:08 +00:00
|
|
|
cursor_locator = page.locator('textarea >> nth=0')
|
|
|
|
expect(await cursor_locator.inputValue()).toContain("block-id=")
|
|
|
|
await cursor_locator.press("Enter")
|
|
|
|
if (IsMac) { // FIXME: support Logseq URL on Linux (XDG)
|
|
|
|
page.locator('a.external-link >> nth=0').click()
|
|
|
|
await page.waitForNavigation()
|
|
|
|
await page.waitForTimeout(500)
|
|
|
|
cursor_locator = await lastBlock(page)
|
|
|
|
expect(await cursor_locator.inputValue()).toBe(identify_text)
|
|
|
|
}
|
|
|
|
})
|