page-alias.spec.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { expect } from '@playwright/test'
  2. import { test } from './fixtures'
  3. import { IsMac, createRandomPage, newBlock, newInnerBlock, lastBlock, lastInnerBlock } from './utils'
  4. test('page alias', async ({ page }) => {
  5. let hotkeyOpenLink = 'Control+o'
  6. let hotkeyBack = 'Control+['
  7. if (IsMac) {
  8. hotkeyOpenLink = 'Meta+o'
  9. hotkeyBack = 'Meta+['
  10. }
  11. // shortcut opening test
  12. await createRandomPage(page)
  13. await page.fill(':nth-match(textarea, 1)', '[[page alias test target page]]')
  14. await page.keyboard.press(hotkeyOpenLink)
  15. // build target Page with alias
  16. await page.type(':nth-match(textarea, 1)', 'alias:: [[page alias test alias page]]')
  17. await page.press(':nth-match(textarea, 1)', 'Enter') // double Enter for exit property editing
  18. await page.press(':nth-match(textarea, 1)', 'Enter')
  19. await page.type(':nth-match(textarea, 1)', 'page alias test content')
  20. await page.keyboard.press(hotkeyBack)
  21. // create alias ref in origin Page
  22. await newBlock(page)
  23. await page.type(':nth-match(textarea, 1)', '[[page alias test alias page]]')
  24. await page.keyboard.press(hotkeyOpenLink)
  25. // shortcut opening test
  26. await lastInnerBlock(page)
  27. expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('page alias test content')
  28. await newInnerBlock(page)
  29. await page.type(':nth-match(textarea, 1)', 'yet another page alias test content')
  30. await page.keyboard.press(hotkeyBack)
  31. // pressing enter opening test
  32. await lastInnerBlock(page)
  33. await page.press(':nth-match(textarea, 1)', 'ArrowLeft')
  34. await page.press(':nth-match(textarea, 1)', 'ArrowLeft')
  35. await page.press(':nth-match(textarea, 1)', 'ArrowLeft')
  36. await page.press(':nth-match(textarea, 1)', 'Enter')
  37. await lastInnerBlock(page)
  38. expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('yet another page alias test content')
  39. await newInnerBlock(page)
  40. await page.type(':nth-match(textarea, 1)', 'still another page alias test content')
  41. await page.keyboard.press(hotkeyBack)
  42. // clicking opening test
  43. await page.click('.page-blocks-inner .ls-block .page-ref >> nth=-1')
  44. await lastInnerBlock(page)
  45. expect(await page.inputValue(':nth-match(textarea, 1)')).toBe('still another page alias test content')
  46. // TODO: test alias from graph clicking
  47. // TODO: test alias from search clicking
  48. })