Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
yangchangtao committed Sep 18, 2024
1 parent 000c04f commit cf65113
Showing 1 changed file with 70 additions and 71 deletions.
141 changes: 70 additions & 71 deletions packages/vue/__tests__/e2e/Transition.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2311,89 +2311,88 @@ describe('e2e: Transition', () => {
},
E2E_TIMEOUT,
),
test(
'apply transition to teleport component child',
async () => {
await page().evaluate(() => {
const { createApp, ref, h } = (window as any).Vue
createApp({
template: `
test(
'apply transition to teleport component child',
async () => {
await page().evaluate(() => {
const { createApp, ref, h } = (window as any).Vue
createApp({
template: `
<div id="target"></div>
<div id="container">
<transition>
<Comp v-if="toggle" >content</Comp>
<Comp v-if="toggle"></Comp>
</transition>
</div>
<button id="toggleBtn" @click="click">button</button>
`,
components: {
Comp: {
setup() {
return () => h(Teleport, { to: '#target' }, [h('div', { class: 'test' }, 'content')])
components: {
Comp: {
setup() {
return () =>
h(
Teleport,
{ to: '#target' },
h('div', { class: 'test' }, 'content'),
)
},
},
},
},
setup: () => {
const toggle = ref(false)
const click = () => (toggle.value = !toggle.value)
return { toggle, click }
},
}).mount('#app')
})

expect(await html('#target')).toBe('')
expect(await html('#container')).toBe(
'<!--v-if-->',
)

const classWhenTransitionStart = () =>
page().evaluate(() => {
;(document.querySelector('#toggleBtn') as any)!.click()
return Promise.resolve().then(() => {
// find the class of teleported node
return document
.querySelector('#target div')!
.className.split(/\s+/g)
})
setup: () => {
const toggle = ref(false)
const click = () => (toggle.value = !toggle.value)
return { toggle, click }
},
}).mount('#app')
})

// enter
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
'v-enter-from',
'v-enter-active',
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
'test',
'v-enter-active',
'v-enter-to',
])
await transitionFinish()
expect(await html('#target')).toBe(
'<div class="test">content</div>',
)
expect(await html('#target')).toBe('')
expect(await html('#container')).toBe('<!--v-if-->')

const classWhenTransitionStart = () =>
page().evaluate(() => {
;(document.querySelector('#toggleBtn') as any)!.click()
return Promise.resolve().then(() => {
// find the class of teleported node
return document
.querySelector('#target div')!
.className.split(/\s+/g)
})
})

// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
'v-leave-from',
'v-leave-active',
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
'test',
'v-leave-active',
'v-leave-to',
])
await transitionFinish()
expect(await html('#target')).toBe('')
expect(await html('#container')).toBe(
'<!--v-if-->',
)
},
E2E_TIMEOUT,
)
// enter
expect(await classWhenTransitionStart()).toStrictEqual([

Check failure on line 2364 in packages/vue/__tests__/e2e/Transition.spec.ts

View workflow job for this annotation

GitHub Actions / test / e2e-test

packages/vue/__tests__/e2e/Transition.spec.ts > e2e: Transition > transition with Teleport > apply transition to teleport component child

TypeError: Cannot read properties of null (reading 'className') ❯ evaluate evaluate at classWhenTransitionStart2 (/home/runner/work/core/core/packages/vue/__tests__/e2e/Transition.spec.ts:2113:56), <anonymous>:4:56 ❯ ExecutionContext.#evaluate node_modules/.pnpm/puppeteer-core@23.3.0/node_modules/puppeteer-core/src/cdp/ExecutionContext.ts:449:13 ❯ ExecutionContext.evaluate node_modules/.pnpm/puppeteer-core@23.3.0/node_modules/puppeteer-core/src/cdp/ExecutionContext.ts:292:12 ❯ IsolatedWorld.evaluate node_modules/.pnpm/puppeteer-core@23.3.0/node_modules/puppeteer-core/src/cdp/IsolatedWorld.ts:194:12 ❯ CdpFrame.evaluate node_modules/.pnpm/puppeteer-core@23.3.0/node_modules/puppeteer-core/src/api/Frame.ts:472:12 ❯ CdpPage.evaluate node_modules/.pnpm/puppeteer-core@23.3.0/node_modules/puppeteer-core/src/api/Page.ts:2219:12 ❯ packages/vue/__tests__/e2e/Transition.spec.ts:2364:18
'test',
'v-enter-from',
'v-enter-active',
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
'test',
'v-enter-active',
'v-enter-to',
])
await transitionFinish()
expect(await html('#target')).toBe('<div class="test">content</div>')

// leave
expect(await classWhenTransitionStart()).toStrictEqual([
'test',
'v-leave-from',
'v-leave-active',
])
await nextFrame()
expect(await classList('.test')).toStrictEqual([
'test',
'v-leave-active',
'v-leave-to',
])
await transitionFinish()
expect(await html('#target')).toBe('')
expect(await html('#container')).toBe('<!--v-if-->')
},
E2E_TIMEOUT,
)
})

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

0 comments on commit cf65113

Please sign in to comment.