1- import path from 'path'
21import stripAnsi from 'strip-ansi'
32import { check } from 'next-test-utils'
4- import { createNextDescribe , FileRef } from 'e2e-utils'
3+ import { createNextDescribe } from 'e2e-utils'
54
65function parseLogsFromCli ( cliOutput : string ) {
76 const logs = stripAnsi ( cliOutput )
@@ -37,22 +36,14 @@ function parseLogsFromCli(cliOutput: string) {
3736}
3837
3938createNextDescribe (
40- 'app-dir - data fetching with cache logging' ,
39+ 'app-dir - logging' ,
4140 {
4241 skipDeployment : true ,
43- files : {
44- 'app/layout.js' : new FileRef ( path . join ( __dirname , 'app/layout.js' ) ) ,
45- 'app/default-cache/page.js' : new FileRef (
46- path . join ( __dirname , 'app/default-cache/page.js' )
47- ) ,
48- 'next.config.js' : `module.exports = {
49- logging: { fetches: { fullUrl: true } }
50- }` ,
51- } ,
42+ files : __dirname ,
5243 } ,
5344 ( { next, isNextDev } ) => {
54- function runTests ( { hasLogging } : { hasLogging : boolean } ) {
55- if ( hasLogging ) {
45+ function runTests ( { withFetchesLogging } : { withFetchesLogging : boolean } ) {
46+ if ( withFetchesLogging ) {
5647 it ( 'should only log requests in dev mode' , async ( ) => {
5748 const outputIndex = next . cliOutput . length
5849 await next . fetch ( '/default-cache' )
@@ -143,10 +134,40 @@ createNextDescribe(
143134 } , 'success' )
144135 } )
145136 }
137+
138+ if ( isNextDev ) {
139+ it ( 'should not contain trailing word page for app router routes' , async ( ) => {
140+ const logLength = next . cliOutput . length
141+ await next . fetch ( '/' )
142+
143+ await check ( ( ) => {
144+ const output = stripAnsi ( next . cliOutput . slice ( logLength ) )
145+ expect ( output ) . toContain ( '/' )
146+ expect ( output ) . not . toContain ( '/page' )
147+
148+ return 'success'
149+ } , / s u c c e s s / )
150+ } )
151+
152+ it ( 'should not contain metadata internal segments for dynamic metadata routes' , async ( ) => {
153+ const logLength = next . cliOutput . length
154+ await next . fetch ( '/dynamic/big/icon' )
155+
156+ await check ( ( ) => {
157+ const output = stripAnsi ( next . cliOutput . slice ( logLength ) )
158+ expect ( output ) . toContain ( '/dynamic/[slug]/icon' )
159+ expect ( output ) . not . toContain ( '/(group)' )
160+ expect ( output ) . not . toContain ( '[[...__metadata_id__]]' )
161+ expect ( output ) . not . toContain ( '/route' )
162+
163+ return 'success'
164+ } , / s u c c e s s / )
165+ } )
166+ }
146167 }
147168
148169 describe ( 'with verbose logging' , ( ) => {
149- runTests ( { hasLogging : true } )
170+ runTests ( { withFetchesLogging : true } )
150171 } )
151172
152173 describe ( 'with verbose logging for edge runtime' , ( ) => {
@@ -160,7 +181,7 @@ createNextDescribe(
160181 await next . start ( )
161182 } )
162183
163- runTests ( { hasLogging : false } )
184+ runTests ( { withFetchesLogging : false } )
164185 } )
165186
166187 describe ( 'with default logging' , ( ) => {
@@ -170,7 +191,7 @@ createNextDescribe(
170191 await next . start ( )
171192 } )
172193
173- runTests ( { hasLogging : false } )
194+ runTests ( { withFetchesLogging : false } )
174195 } )
175196 }
176197)
0 commit comments