markdown.spec.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import path from 'path'
  2. import {
  3. setupPuppeteer,
  4. expectByPolling,
  5. E2E_TIMEOUT
  6. } from '../../__tests__/e2eUtils'
  7. describe('e2e: markdown', () => {
  8. const { page, isVisible, value, html } = setupPuppeteer()
  9. async function testMarkdown(apiType: 'classic' | 'composition') {
  10. const baseUrl = `file://${path.resolve(
  11. __dirname,
  12. `../${apiType}/markdown.html#test`
  13. )}`
  14. await page().goto(baseUrl)
  15. expect(await isVisible('#editor')).toBe(true)
  16. expect(await value('textarea')).toBe('# hello')
  17. expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
  18. await page().type('textarea', '\n## foo\n\n- bar\n- baz')
  19. // assert the output is not updated yet because of debounce
  20. // debounce has become unstable on CI so this assertion is disabled
  21. // expect(await html('#editor div')).toBe('<h1 id="hello">hello</h1>\n')
  22. await expectByPolling(
  23. () => html('#editor div'),
  24. '<h1 id="hello">hello</h1>\n' +
  25. '<h2 id="foo">foo</h2>\n' +
  26. '<ul>\n<li>bar</li>\n<li>baz</li>\n</ul>\n'
  27. )
  28. }
  29. test(
  30. 'classic',
  31. async () => {
  32. await testMarkdown('classic')
  33. },
  34. E2E_TIMEOUT
  35. )
  36. test(
  37. 'composition',
  38. async () => {
  39. await testMarkdown('composition')
  40. },
  41. E2E_TIMEOUT
  42. )
  43. })