vdomInterop.spec.ts 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import path from 'node:path'
  2. import {
  3. E2E_TIMEOUT,
  4. setupPuppeteer,
  5. } from '../../../packages/vue/__tests__/e2e/e2eUtils'
  6. import connect from 'connect'
  7. import sirv from 'sirv'
  8. describe('vdom / vapor interop', () => {
  9. const { page, click, text, enterValue } = setupPuppeteer()
  10. let server: any
  11. const port = '8193'
  12. beforeAll(() => {
  13. server = connect()
  14. .use(sirv(path.resolve(import.meta.dirname, '../dist')))
  15. .listen(port)
  16. process.on('SIGTERM', () => server && server.close())
  17. })
  18. afterAll(() => {
  19. server.close()
  20. })
  21. test(
  22. 'should work',
  23. async () => {
  24. const baseUrl = `http://localhost:${port}/interop/`
  25. await page().goto(baseUrl)
  26. expect(await text('.vapor > h2')).toContain('Vapor component in VDOM')
  27. expect(await text('.vapor-prop')).toContain('hello')
  28. const t = await text('.vdom-slot-in-vapor-default')
  29. expect(t).toContain('slot prop: slot prop')
  30. expect(t).toContain('component prop: hello')
  31. await click('.change-vdom-slot-in-vapor-prop')
  32. expect(await text('.vdom-slot-in-vapor-default')).toContain(
  33. 'slot prop: changed',
  34. )
  35. expect(await text('.vdom-slot-in-vapor-test')).toContain('A test slot')
  36. await click('.toggle-vdom-slot-in-vapor')
  37. expect(await text('.vdom-slot-in-vapor-test')).toContain(
  38. 'fallback content',
  39. )
  40. await click('.toggle-vdom-slot-in-vapor')
  41. expect(await text('.vdom-slot-in-vapor-test')).toContain('A test slot')
  42. expect(await text('.vdom > h2')).toContain('VDOM component in Vapor')
  43. expect(await text('.vdom-prop')).toContain('hello')
  44. const tt = await text('.vapor-slot-in-vdom-default')
  45. expect(tt).toContain('slot prop: slot prop')
  46. expect(tt).toContain('component prop: hello')
  47. await click('.change-vapor-slot-in-vdom-prop')
  48. expect(await text('.vapor-slot-in-vdom-default')).toContain(
  49. 'slot prop: changed',
  50. )
  51. expect(await text('.vapor-slot-in-vdom-test')).toContain('fallback')
  52. await click('.toggle-vapor-slot-in-vdom-default')
  53. expect(await text('.vapor-slot-in-vdom-default')).toContain(
  54. 'default slot fallback',
  55. )
  56. await click('.toggle-vapor-slot-in-vdom-default')
  57. await enterValue('input', 'bye')
  58. expect(await text('.vapor-prop')).toContain('bye')
  59. expect(await text('.vdom-slot-in-vapor-default')).toContain('bye')
  60. expect(await text('.vdom-prop')).toContain('bye')
  61. expect(await text('.vapor-slot-in-vdom-default')).toContain('bye')
  62. },
  63. E2E_TIMEOUT,
  64. )
  65. })