@@ -1214,6 +1214,63 @@ describe('e2e: Transition', () => {
12141214 } ,
12151215 E2E_TIMEOUT ,
12161216 )
1217+
1218+ test (
1219+ 'w/ KeepAlive + unmount innerChild' ,
1220+ async ( ) => {
1221+ const unmountSpy = vi . fn ( )
1222+ await page ( ) . exposeFunction ( 'unmountSpy' , unmountSpy )
1223+ await page ( ) . evaluate ( ( ) => {
1224+ const { unmountSpy } = window as any
1225+ const { createApp, ref, h, onUnmounted } = ( window as any ) . Vue
1226+ createApp ( {
1227+ template : `
1228+ <div id="container">
1229+ <transition mode="out-in">
1230+ <KeepAlive :include="includeRef">
1231+ <TrueBranch v-if="toggle"></TrueBranch>
1232+ </KeepAlive>
1233+ </transition>
1234+ </div>
1235+ <button id="toggleBtn" @click="click">button</button>
1236+ ` ,
1237+ components : {
1238+ TrueBranch : {
1239+ name : 'TrueBranch' ,
1240+ setup ( ) {
1241+ onUnmounted ( unmountSpy )
1242+ const count = ref ( 0 )
1243+ return ( ) => h ( 'div' , count . value )
1244+ } ,
1245+ } ,
1246+ } ,
1247+ setup : ( ) => {
1248+ const includeRef = ref ( [ 'TrueBranch' ] )
1249+ const toggle = ref ( true )
1250+ const click = ( ) => {
1251+ toggle . value = ! toggle . value
1252+ if ( toggle . value ) {
1253+ includeRef . value = [ 'TrueBranch' ]
1254+ } else {
1255+ includeRef . value = [ ]
1256+ }
1257+ }
1258+ return { toggle, click, unmountSpy, includeRef }
1259+ } ,
1260+ } ) . mount ( '#app' )
1261+ } )
1262+
1263+ await transitionFinish ( )
1264+ expect ( await html ( '#container' ) ) . toBe ( '<div>0</div>' )
1265+
1266+ await click ( '#toggleBtn' )
1267+
1268+ await transitionFinish ( )
1269+ expect ( await html ( '#container' ) ) . toBe ( '<!--v-if-->' )
1270+ expect ( unmountSpy ) . toBeCalledTimes ( 1 )
1271+ } ,
1272+ E2E_TIMEOUT ,
1273+ )
12171274 } )
12181275
12191276 describe ( 'transition with Suspense' , ( ) => {
0 commit comments