2
0

markdown.spec.ts 1.2 KB

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