import {
E2E_TIMEOUT,
setupPuppeteer,
+ timeout,
} from '../../../packages/vue/__tests__/e2e/e2eUtils'
import connect from 'connect'
import sirv from 'sirv'
+const { page, click, text, enterValue, html } = setupPuppeteer()
-describe('vdom / vapor interop', () => {
- const { page, click, text, enterValue } = setupPuppeteer()
+const duration = process.env.CI ? 200 : 50
+describe('vdom / vapor interop', () => {
let server: any
const port = '8193'
beforeAll(() => {
server.close()
})
+ beforeEach(async () => {
+ const baseUrl = `http://localhost:${port}/interop/`
+ await page().goto(baseUrl)
+ await page().waitForSelector('#app')
+ })
+
test(
'should work',
async () => {
- const baseUrl = `http://localhost:${port}/interop/`
- await page().goto(baseUrl)
-
expect(await text('.vapor > h2')).toContain('Vapor component in VDOM')
expect(await text('.vapor-prop')).toContain('hello')
},
E2E_TIMEOUT,
)
+
+ describe('async component', () => {
+ const container = '.async-component-interop'
+ test(
+ 'with-vdom-inner-component',
+ async () => {
+ const testContainer = `${container} .with-vdom-component`
+ expect(await html(testContainer)).toBe('<span>loading...</span>')
+
+ await timeout(duration)
+ expect(await html(testContainer)).toBe('<div> foo </div>')
+ },
+ E2E_TIMEOUT,
+ )
+ })
})
<script setup lang="ts">
-import { ref } from 'vue'
-import VaporComp from './VaporComp.vue'
+import { ref, defineVaporAsyncComponent, h } from 'vue'
+import VaporComp from './components/VaporComp.vue'
+import VdomFoo from './components/VdomFoo.vue'
const msg = ref('hello')
const passSlot = ref(true)
+
+const duration = typeof process !== undefined && process.env.CI ? 200 : 50
+
+const AsyncVDomFoo = defineVaporAsyncComponent({
+ loader: () => {
+ return new Promise(r => {
+ setTimeout(() => {
+ r(VdomFoo as any)
+ }, duration)
+ })
+ },
+ loadingComponent: () => h('span', 'loading...'),
+})
</script>
<template>
<template #test v-if="passSlot">A test slot</template>
</VaporComp>
+
+ <!-- async component -->
+ <div class="async-component-interop">
+ <div class="with-vdom-component">
+ <AsyncVDomFoo />
+ </div>
+ </div>
+ <!-- async component end -->
</template>
<div v-if="ok" style="border: 2px solid orange; padding: 10px">
<h3>vdom slots in vapor component</h3>
- <button
- class="change-vdom-slot-in-vapor-prop"
- @click="slotProp = 'changed'"
- >
+ <button class="change-vdom-slot-in-vapor-prop" @click="slotProp = 'changed'">
change slot prop
</button>
<div class="vdom-slot-in-vapor-default">
- #default: <slot :foo="slotProp" />
+ #default:
+ <slot :foo="slotProp" />
</div>
<div class="vdom-slot-in-vapor-test">
#test: <slot name="test">fallback content</slot>
</div>
</div>
- <button
- class="toggle-vapor-slot-in-vdom-default"
- @click="passSlot = !passSlot"
- >
+ <button class="toggle-vapor-slot-in-vdom-default" @click="passSlot = !passSlot">
Toggle default slot to vdom
</button>
<VdomComp :msg="msg">
--- /dev/null
+<script setup lang="ts">
+
+</script>
+
+<template>
+ <div>
+ foo
+ </div>
+</template>
source = dynamicSources[i]
isDynamic = isFunction(source)
source = isDynamic ? (source as Function)() : source
- if (hasOwn(source, key)) {
+ if (source && hasOwn(source, key)) {
const value = isDynamic ? source[key] : source[key]()
if (merged) {
merged.push(value)