@@ -20,7 +20,7 @@ describe('pages:generateRoutesFromFiles', () => {
2020
2121 const tests : Array < {
2222 description : string
23- files ?: Array < { path : string , template ?: string } >
23+ files ?: Array < { path : string , template ?: string , meta ?: Record < string , any > } >
2424 output ?: NuxtPage [ ]
2525 normalized ?: Record < string , any > [ ]
2626 error ?: string
@@ -554,6 +554,53 @@ describe('pages:generateRoutesFromFiles', () => {
554554 } ,
555555 ] ,
556556 } ,
557+ {
558+ description : 'route.meta generated from file' ,
559+ files : [
560+ {
561+ path : `${ pagesDir } /page-with-meta.vue` ,
562+ meta : {
563+ test : 1 ,
564+ } ,
565+ } ,
566+ ] ,
567+ output : [
568+ {
569+ name : 'page-with-meta' ,
570+ path : '/page-with-meta' ,
571+ file : `${ pagesDir } /page-with-meta.vue` ,
572+ children : [ ] ,
573+ meta : { test : 1 } ,
574+ } ,
575+ ] ,
576+ } ,
577+ {
578+ description : 'should merge route.meta with meta from file' ,
579+ files : [
580+ {
581+ path : `${ pagesDir } /page-with-meta.vue` ,
582+ meta : {
583+ test : 1 ,
584+ } ,
585+ template : `
586+ <script setup lang="ts">
587+ definePageMeta({
588+ hello: 'world'
589+ })
590+ </script>
591+ ` ,
592+ } ,
593+ ] ,
594+ output : [
595+ {
596+ name : 'page-with-meta' ,
597+ path : '/page-with-meta' ,
598+ file : `${ pagesDir } /page-with-meta.vue` ,
599+ children : [ ] ,
600+ meta : { [ DYNAMIC_META_KEY ] : new Set ( [ 'meta' ] ) , test : 1 } ,
601+ } ,
602+ ] ,
603+ } ,
557604 ]
558605
559606 const normalizedResults : Record < string , any > = { }
@@ -572,7 +619,13 @@ describe('pages:generateRoutesFromFiles', () => {
572619 shouldUseServerComponents : true ,
573620 absolutePath : file . path ,
574621 relativePath : file . path . replace ( / ^ ( p a g e s | l a y e r \/ p a g e s ) \/ / , '' ) ,
575- } ) ) )
622+ } ) ) ) . map ( ( route , index ) => {
623+ return {
624+ ...route ,
625+ meta : test . files ! [ index ] . meta ,
626+ }
627+ } )
628+
576629 await augmentPages ( result , vfs )
577630 } catch ( error : any ) {
578631 expect ( error . message ) . toEqual ( test . error )
0 commit comments