logseq-url.spec.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { expect } from '@playwright/test'
  2. import { test } from './fixtures'
  3. import { createRandomPage, lastBlock, IsMac, IsLinux } from './utils'
  4. test(
  5. "Logseq URLs (same graph)",
  6. async ({ page, block }) => {
  7. let paste_key = IsMac ? 'Meta+v' : 'Control+v'
  8. // create a page with identify block
  9. let identify_text = "URL redirect target"
  10. let page_title = await createRandomPage(page)
  11. await block.mustFill(identify_text)
  12. // paste current page's URL to another page, then redirect throught the URL
  13. await page.click('.ui__dropdown-trigger')
  14. await page.locator("text=Copy page URL").click()
  15. await createRandomPage(page)
  16. await block.mustFill("") // to enter editing mode
  17. await page.keyboard.press(paste_key)
  18. let cursor_locator = page.locator('textarea >> nth=0')
  19. expect(await cursor_locator.inputValue()).toContain("page=" + page_title)
  20. await cursor_locator.press("Enter")
  21. if (!IsLinux) { // FIXME: support Logseq URL on Linux (XDG)
  22. page.locator('a.external-link >> nth=0').click()
  23. await page.waitForNavigation()
  24. await page.waitForTimeout(500)
  25. cursor_locator = await lastBlock(page)
  26. expect(await cursor_locator.inputValue()).toBe(identify_text)
  27. }
  28. // paste the identify block's URL to another page, then redirect throught the URL
  29. await page.click('span.bullet >> nth=0', { button: "right" })
  30. await page.locator("text=Copy block URL").click()
  31. await createRandomPage(page)
  32. await block.mustFill("") // to enter editing mode
  33. await page.keyboard.press(paste_key)
  34. cursor_locator = page.locator('textarea >> nth=0')
  35. expect(await cursor_locator.inputValue()).toContain("block-id=")
  36. await cursor_locator.press("Enter")
  37. if (!IsLinux) { // FIXME: support Logseq URL on Linux (XDG)
  38. page.locator('a.external-link >> nth=0').click()
  39. await page.waitForNavigation()
  40. await page.waitForTimeout(500)
  41. cursor_locator = await lastBlock(page)
  42. expect(await cursor_locator.inputValue()).toBe(identify_text)
  43. }
  44. })