@@ -25,6 +25,7 @@ import {
2525 NavigationResult ,
2626 DataLoaderPluginOptions ,
2727 useIsDataLoading ,
28+ LOADER_SET_PROMISES_KEY ,
2829} from 'unplugin-vue-router/data-loaders'
2930import { mockPromise } from '../../tests/utils'
3031import {
@@ -178,6 +179,30 @@ describe('navigation-guard', () => {
178179 expect ( [ ...set ! ] ) . toEqual ( [ useDataOne , useDataTwo ] )
179180 } )
180181
182+ it ( 'collects all loaders from lazy loaded pages with repeated navigation' , async ( ) => {
183+ setupApp ( { isSSR : false } )
184+ const router = getRouter ( )
185+ router . addRoute ( {
186+ name : '_test' ,
187+ path : '/fetch' ,
188+ component : ( ) =>
189+ import ( '../../tests/data-loaders/ComponentWithLoader.vue' ) ,
190+ } )
191+
192+ void router . push ( '/fetch' )
193+
194+ // simulate repeated navigation while the async component is loading
195+ await Promise . resolve ( )
196+ await router . push ( '/fetch' )
197+
198+ const set = router . currentRoute . value . meta [ LOADER_SET_KEY ]
199+ expect ( [ ...set ! ] ) . toEqual ( [ useDataOne , useDataTwo ] )
200+
201+ for ( const record of router . currentRoute . value . matched ) {
202+ expect ( record . meta [ LOADER_SET_PROMISES_KEY ] ) . toBeUndefined ( )
203+ }
204+ } )
205+
181206 it ( 'awaits for all loaders to be resolved' , async ( ) => {
182207 setupApp ( { isSSR : false } )
183208 const router = getRouter ( )
0 commit comments