From: daiwei Date: Wed, 21 Jan 2026 02:57:26 +0000 (+0800) Subject: test(runtime-vapor): add hydration tests for v-if/v-for with sibling components X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d508e644de60a507f85fb1e8e0b40be32e340f0f;p=thirdparty%2Fvuejs%2Fcore.git test(runtime-vapor): add hydration tests for v-if/v-for with sibling components --- diff --git a/packages/runtime-vapor/__tests__/hydration.spec.ts b/packages/runtime-vapor/__tests__/hydration.spec.ts index 9e67a4bc21..3f7ca5c542 100644 --- a/packages/runtime-vapor/__tests__/hydration.spec.ts +++ b/packages/runtime-vapor/__tests__/hydration.spec.ts @@ -1623,6 +1623,135 @@ describe('Vapor Mode hydration', () => { `"
foo
"`, ) }) + + test('v-if with insertion parent + sibling component', async () => { + const data = ref(true) + const { container } = await testHydration( + ``, + { + Child: ``, + }, + data, + ) + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
hello
child
+ " + `, + ) + + data.value = false + await nextTick() + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
child
+ " + `, + ) + + data.value = true + await nextTick() + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
hello
child
+ " + `, + ) + }) + + test('v-if with static sibling + root sibling component', async () => { + const data = ref(true) + const { container } = await testHydration( + ``, + { + Child: ``, + }, + data, + ) + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
hello
1
child
+ " + `, + ) + + data.value = false + await nextTick() + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
1
child
+ " + `, + ) + + data.value = true + await nextTick() + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
hello
1
child
+ " + `, + ) + }) + + test('v-if + static sibling + root sibling component (flat)', async () => { + const data = ref(true) + const { container } = await testHydration( + ``, + { + Child: ``, + }, + data, + ) + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " + hello
child
+ " + `, + ) + + data.value = false + await nextTick() + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
child
+ " + `, + ) + + data.value = true + await nextTick() + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " + hello
child
+ " + `, + ) + }) }) describe('for', () => { @@ -1716,6 +1845,43 @@ describe('Vapor Mode hydration', () => { ) }) + test('v-for with static sibling + root sibling component', async () => { + const { container, data } = await testHydration( + ``, + { + Child: ``, + }, + ref(['a', 'b', 'c']), + ) + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
+ abc +
1
3
+ " + `, + ) + + data.value.push('d') + await nextTick() + expect(formatHtml(container.innerHTML)).toMatchInlineSnapshot( + ` + " +
+ abcd +
1
4
+ " + `, + ) + }) + test('v-for with insertion anchor', async () => { const { container, data } = await testHydration( `