Skip to content

Commit 9805a64

Browse files
committed
test: add e2e test case
1 parent bb364ef commit 9805a64

File tree

1 file changed

+75
-4
lines changed

1 file changed

+75
-4
lines changed

packages/vue/__tests__/Transition.spec.ts

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,17 +2123,17 @@ describe('e2e: Transition', () => {
21232123
})
21242124

21252125
test(
2126-
'should work with dev root fragment',
2126+
'toggle single component with comments before the single root element',
21272127
async () => {
21282128
await page().evaluate(() => {
21292129
const { createApp, ref } = (window as any).Vue
21302130
createApp({
21312131
components: {
21322132
Comp: {
21332133
template: `
2134-
<!-- Broken! -->
2135-
<div><slot /></div>
2136-
`
2134+
<!-- Broken! -->
2135+
<div><slot /></div>
2136+
`
21372137
}
21382138
},
21392139
template: `
@@ -2191,4 +2191,75 @@ describe('e2e: Transition', () => {
21912191
},
21922192
E2E_TIMEOUT
21932193
)
2194+
2195+
test(
2196+
'toggle multiple components with comments before the single root element',
2197+
async () => {
2198+
await page().evaluate(() => {
2199+
const { createApp, ref } = (window as any).Vue
2200+
createApp({
2201+
components: {
2202+
One: {
2203+
template: `
2204+
<!-- Breaking Comment -->
2205+
<div class="one">One</div>
2206+
`
2207+
},
2208+
Two: {
2209+
template: `<div class="two">Two</div>`
2210+
}
2211+
},
2212+
template: `
2213+
<button id="toggleBtn" @click="click">button</button>
2214+
<div id="container">
2215+
<transition mode="out-in">
2216+
<One v-if="toggle"></One>
2217+
<Two v-else></Two>
2218+
</transition>
2219+
</div>
2220+
`,
2221+
setup: () => {
2222+
const toggle = ref(true)
2223+
const click = () => (toggle.value = !toggle.value)
2224+
return { toggle, click }
2225+
}
2226+
}).mount('#app')
2227+
})
2228+
2229+
expect(await html('#container')).toBe(
2230+
'<!-- Breaking Comment --><div class="one">One</div>'
2231+
)
2232+
2233+
// one -> two
2234+
expect(await classWhenTransitionStart()).toStrictEqual([
2235+
'one',
2236+
'v-leave-from',
2237+
'v-leave-active'
2238+
])
2239+
await nextFrame()
2240+
expect(await classList('.two')).toStrictEqual([
2241+
'two',
2242+
'v-enter-from',
2243+
'v-enter-active'
2244+
])
2245+
await transitionFinish(duration * 2)
2246+
expect(await html('#container')).toBe('<div class="two">Two</div>')
2247+
2248+
// two -> one
2249+
expect(await classWhenTransitionStart()).toStrictEqual([
2250+
'two',
2251+
'v-leave-from',
2252+
'v-leave-active'
2253+
])
2254+
await nextFrame()
2255+
expect(await classList('.one')).toStrictEqual([
2256+
'one',
2257+
'v-enter-from',
2258+
'v-enter-active'
2259+
])
2260+
await transitionFinish(duration * 2)
2261+
expect(await html('#container')).toBe(
2262+
'<!-- Breaking Comment --><div class="one">One</div>'
2263+
)
2264+
}, E2E_TIMEOUT)
21942265
})

0 commit comments

Comments
 (0)