hotkey.spec.ts 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { expect } from '@playwright/test'
  2. import { test } from './fixtures'
  3. import { createRandomPage, enterNextBlock, lastBlock, modKey, IsLinux, closeSearchBox } from './utils'
  4. test('open search dialog', async ({ page }) => {
  5. await page.waitForTimeout(200)
  6. await closeSearchBox(page)
  7. await page.keyboard.press(modKey + '+k')
  8. await page.waitForSelector('[placeholder="What are you looking for?"]', { state: 'visible' })
  9. await page.keyboard.press('Escape')
  10. await page.waitForSelector('[placeholder="What are you looking for?"]', { state: 'hidden' })
  11. })
  12. test('insert link #3278', async ({ page }) => {
  13. await createRandomPage(page)
  14. let hotKey = modKey + '+l'
  15. let selectAll = modKey + '+a'
  16. // Case 1: empty link
  17. await lastBlock(page)
  18. await page.press('textarea >> nth=0', hotKey)
  19. expect(await page.inputValue('textarea >> nth=0')).toBe('[]()')
  20. await page.type('textarea >> nth=0', 'Logseq Website')
  21. expect(await page.inputValue('textarea >> nth=0')).toBe('[Logseq Website]()')
  22. await page.fill('textarea >> nth=0', '[Logseq Website](https://logseq.com)')
  23. // Case 2: link with label
  24. await enterNextBlock(page)
  25. await page.type('textarea >> nth=0', 'Logseq')
  26. await page.press('textarea >> nth=0', selectAll)
  27. await page.press('textarea >> nth=0', hotKey)
  28. expect(await page.inputValue('textarea >> nth=0')).toBe('[Logseq]()')
  29. await page.type('textarea >> nth=0', 'https://logseq.com/')
  30. expect(await page.inputValue('textarea >> nth=0')).toBe('[Logseq](https://logseq.com/)')
  31. // Case 3: link with URL
  32. await enterNextBlock(page)
  33. await page.type('textarea >> nth=0', 'https://logseq.com/')
  34. await page.press('textarea >> nth=0', selectAll)
  35. await page.press('textarea >> nth=0', hotKey)
  36. expect(await page.inputValue('textarea >> nth=0')).toBe('[](https://logseq.com/)')
  37. await page.type('textarea >> nth=0', 'Logseq')
  38. expect(await page.inputValue('textarea >> nth=0')).toBe('[Logseq](https://logseq.com/)')
  39. })