markdown.spec.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import path from 'node:path'
  2. import { E2E_TIMEOUT, expectByPolling, setupPuppeteer } from './e2eUtils'
  3. describe('e2e: markdown', () => {
  4. const { page, isVisible, value, html } = setupPuppeteer()
  5. async function testMarkdown(apiType: 'classic' | 'composition') {
  6. const baseUrl = `file://${path.resolve(
  7. __dirname,
  8. `../../examples/${apiType}/markdown.html#test`,
  9. )}`
  10. await page().goto(baseUrl)
  11. expect(await isVisible('#editor')).toBe(true)
  12. expect(await value('textarea')).toBe('# hello')
  13. expect(await html('#editor div')).toBe('<h1>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>hello</h1>\n' +
  21. '<h2>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. })