editor.spec.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { expect } from '@playwright/test'
  2. import { test } from './fixtures'
  3. import { createRandomPage, IsMac } from './utils'
  4. import { press_with_events, macos_pinyin_left_full_bracket } from './util/keyboard-events'
  5. test('keyboard related issues', async ({ page }) => {
  6. await createRandomPage(page)
  7. await page.type(':nth-match(textarea, 1)', 'without events: ')
  8. await page.type(':nth-match(textarea, 1)', "【")
  9. await page.type(':nth-match(textarea, 1)', "【")
  10. await page.type(':nth-match(textarea, 1)', ' | with events: ')
  11. await page.type(':nth-match(textarea, 1)', "【")
  12. await press_with_events(page, ':nth-match(textarea, 1)', macos_pinyin_left_full_bracket)
  13. await page.type(':nth-match(textarea, 1)', "【")
  14. await press_with_events(page, ':nth-match(textarea, 1)', macos_pinyin_left_full_bracket)
  15. })
  16. test('hashtag and quare brackets in same line #4178', async ({ page }) => {
  17. await createRandomPage(page)
  18. await page.type(':nth-match(textarea, 1)', '#foo bar')
  19. await page.press(':nth-match(textarea, 1)', 'Enter')
  20. await page.type(':nth-match(textarea, 1)', 'bar [[blah]]')
  21. for (let i = 0; i < 12; i++) {
  22. await page.press(':nth-match(textarea, 1)', 'ArrowLeft')
  23. }
  24. await page.type(':nth-match(textarea, 1)', ' ')
  25. await page.press(':nth-match(textarea, 1)', 'ArrowLeft')
  26. await page.type(':nth-match(textarea, 1)', '#')
  27. await page.waitForSelector('text="Search for a page"', { state: 'visible' })
  28. await page.type(':nth-match(textarea, 1)', 'fo')
  29. await page.click('.absolute >> text=' + 'foo')
  30. expect(await page.inputValue(':nth-match(textarea, 1)')).toBe(
  31. '#foo bar [[blah]]'
  32. )
  33. })
  34. // FIXME: ClipboardItem is not defined when running with this test
  35. // test('copy & paste block ref and replace its content', async ({ page }) => {
  36. // await createRandomPage(page)
  37. // await page.type(':nth-match(textarea, 1)', 'Some random text')
  38. // if (IsMac) {
  39. // await page.keyboard.press('Meta+c')
  40. // } else {
  41. // await page.keyboard.press('Control+c')
  42. // }
  43. // await page.pause()
  44. // await page.press(':nth-match(textarea, 1)', 'Enter')
  45. // if (IsMac) {
  46. // await page.keyboard.press('Meta+v')
  47. // } else {
  48. // await page.keyboard.press('Control+v')
  49. // }
  50. // await page.keyboard.press('Escape')
  51. // const blockRef$ = page.locator('.block-ref >> text="Some random text"');
  52. // // Check if the newly created block-ref has the same referenced content
  53. // await expect(blockRef$).toHaveCount(1);
  54. // // Edit the last block
  55. // await blockRef$.press('Enter')
  56. // // Move cursor into the block ref
  57. // for (let i = 0; i < 4; i++) {
  58. // await page.press(':nth-match(textarea, 1)', 'ArrowLeft')
  59. // }
  60. // // Trigger replace-block-reference-with-content-at-point
  61. // if (IsMac) {
  62. // await page.keyboard.press('Meta+Shift+r')
  63. // } else {
  64. // await page.keyboard.press('Control+Shift+v')
  65. // }
  66. // })