Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Suspense): fallback should work with transition #3968

Merged
merged 4 commits into from
Jun 21, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions packages/vue/__tests__/Transition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,69 @@ describe('e2e: Transition', () => {
},
E2E_TIMEOUT
)

test(
'Suspense fallback should work with transition',
async () => {
const onLeaveSpy = jest.fn()
const onEnterSpy = jest.fn()

await page().exposeFunction('onLeaveSpy', onLeaveSpy)
await page().exposeFunction('onEnterSpy', onEnterSpy)

await page().evaluate(() => {
const { createApp, shallowRef, h } = (window as any).Vue
const One = {
template: `<div>{{ msg }}</div>`,
setup() {
return new Promise((resolve, reject) => {
setTimeout(
() =>
resolve({
msg: 'success'
}),
1000
)
})
}
}
createApp({
template: `
<div id="container">
<transition mode="out-in">
<Suspense :timeout="0">
<template #default>
<component :is="view" />
</template>
<template #fallback>
<div>Loading...</div>
</template>
</Suspense>
</transition>
</div>
<button id="toggleBtn" @click="click">button</button>
`,
setup: () => {
const view = shallowRef(null)
const click = () => {
view.value = view.value ? null : h(One)
}
return { view, click }
}
}).mount('#app')
})

await nextTick()
expect(await html('#container')).toBe('<!---->')

await click('#toggleBtn')
await timeout(500)
expect(await html('#container')).toBe('<div class="">Loading...</div>')
await transitionFinish(1500)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using hard coded test durations like this.

See 740bcd1

expect(await html('#container')).toBe('<div class="">success</div>')
},
E2E_TIMEOUT
)
})

describe('transition with v-show', () => {
Expand Down