@@ -25,6 +25,7 @@ import {
25
25
NavigationResult ,
26
26
DataLoaderPluginOptions ,
27
27
useIsDataLoading ,
28
+ LOADER_SET_PROMISES_KEY ,
28
29
} from 'unplugin-vue-router/data-loaders'
29
30
import { mockPromise } from '../../tests/utils'
30
31
import {
@@ -178,6 +179,30 @@ describe('navigation-guard', () => {
178
179
expect ( [ ...set ! ] ) . toEqual ( [ useDataOne , useDataTwo ] )
179
180
} )
180
181
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
+
181
206
it ( 'awaits for all loaders to be resolved' , async ( ) => {
182
207
setupApp ( { isSSR : false } )
183
208
const router = getRouter ( )
0 commit comments