11import { expect } from '@playwright/test'
22import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
33import { test } from '../utils/playwright-helpers.js'
4- import { join } from 'node:path'
5- import { readdir } from 'node:fs/promises'
64
75export function waitFor ( millis : number ) {
86 return new Promise ( ( resolve ) => setTimeout ( resolve , millis ) )
@@ -616,34 +614,6 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
616614 / ( s - m a x a g e | m a x - a g e ) / ,
617615 )
618616 } )
619-
620- test . describe ( 'static assets and function invocations' , ( ) => {
621- test ( 'should return 200 for an existing static asset without invoking a function' , async ( {
622- page,
623- pageRouter,
624- } ) => {
625- // Since assets are hashed, we can't hardcode anything here. Find something to fetch.
626- const [ staticAsset ] = await readdir (
627- join ( pageRouter . isolatedFixtureRoot , '.next' , 'static' , 'chunks' ) ,
628- )
629- expect ( staticAsset ) . toBeDefined ( )
630-
631- const response = await page . goto ( `${ pageRouter . url } /_next/static/chunks/${ staticAsset } ` )
632-
633- expect ( response ?. status ( ) ) . toBe ( 200 )
634- expect ( response ?. headers ( ) ) . not . toHaveProperty ( 'x-nf-function-type' )
635- } )
636-
637- test ( 'should return 404 for a nonexistent static asset without invoking a function' , async ( {
638- page,
639- pageRouter,
640- } ) => {
641- const response = await page . goto ( `${ pageRouter . url } /_next/static/stale123abcdef.js` )
642-
643- expect ( response ?. status ( ) ) . toBe ( 404 )
644- expect ( response ?. headers ( ) ) . not . toHaveProperty ( 'x-nf-function-type' )
645- } )
646- } )
647617} )
648618
649619test . describe ( 'Page Router with basePath and i18n' , ( ) => {
@@ -1382,15 +1352,13 @@ test.describe('Page Router with basePath and i18n', () => {
13821352
13831353 test ( 'requesting a non existing page route that needs to be fetched from the blob store like 404.html' , async ( {
13841354 page,
1385- pageRouterBasePathI18n ,
1355+ pageRouter ,
13861356 } ) => {
1387- const response = await page . goto (
1388- new URL ( 'base/path/non-existing' , pageRouterBasePathI18n . url ) . href ,
1389- )
1357+ const response = await page . goto ( new URL ( 'non-existing' , pageRouter . url ) . href )
13901358 const headers = response ?. headers ( ) || { }
13911359 expect ( response ?. status ( ) ) . toBe ( 404 )
13921360
1393- expect ( await page . textContent ( 'p' ) ) . toBe ( 'Custom 404 page for locale: en ' )
1361+ expect ( await page . textContent ( 'p' ) ) . toBe ( 'Custom 404 page' )
13941362
13951363 expect ( headers [ 'debug-netlify-cdn-cache-control' ] ) . toMatch (
13961364 / n o - c a c h e , n o - s t o r e , m a x - a g e = 0 , m u s t - r e v a l i d a t e , d u r a b l e / m,
@@ -1400,15 +1368,13 @@ test.describe('Page Router with basePath and i18n', () => {
14001368
14011369 test ( 'requesting a non existing page route that needs to be fetched from the blob store like 404.html (notFound: true)' , async ( {
14021370 page,
1403- pageRouterBasePathI18n ,
1371+ pageRouter ,
14041372 } ) => {
1405- const response = await page . goto (
1406- new URL ( 'base/path/static/not-found' , pageRouterBasePathI18n . url ) . href ,
1407- )
1373+ const response = await page . goto ( new URL ( 'static/not-found' , pageRouter . url ) . href )
14081374 const headers = response ?. headers ( ) || { }
14091375 expect ( response ?. status ( ) ) . toBe ( 404 )
14101376
1411- expect ( await page . textContent ( 'p' ) ) . toBe ( 'Custom 404 page for locale: en ' )
1377+ expect ( await page . textContent ( 'p' ) ) . toBe ( 'Custom 404 page' )
14121378
14131379 // Prior to v14.2.4 notFound pages are not cacheable
14141380 // https://github.com/vercel/next.js/pull/66674
@@ -1421,36 +1387,4 @@ test.describe('Page Router with basePath and i18n', () => {
14211387 expect ( headers [ 'cache-control' ] ) . toBe ( 'public,max-age=0,must-revalidate' )
14221388 }
14231389 } )
1424-
1425- test . describe ( 'static assets and function invocations' , ( ) => {
1426- test ( 'should return 200 for an existing static asset without invoking a function' , async ( {
1427- page,
1428- pageRouterBasePathI18n,
1429- } ) => {
1430- // Since assets are hashed, we can't hardcode anything here. Find something to fetch.
1431- const [ staticAsset ] = await readdir (
1432- join ( pageRouterBasePathI18n . isolatedFixtureRoot , '.next' , 'static' , 'chunks' ) ,
1433- )
1434- expect ( staticAsset ) . toBeDefined ( )
1435-
1436- const response = await page . goto (
1437- `${ pageRouterBasePathI18n . url } /base/path/_next/static/chunks/${ staticAsset } ` ,
1438- )
1439-
1440- expect ( response ?. status ( ) ) . toBe ( 200 )
1441- expect ( response ?. headers ( ) ) . not . toHaveProperty ( 'x-nf-function-type' )
1442- } )
1443-
1444- test ( 'should return 404 for a nonexistent static asset without invoking a function' , async ( {
1445- page,
1446- pageRouterBasePathI18n,
1447- } ) => {
1448- const response = await page . goto (
1449- `${ pageRouterBasePathI18n . url } /base/path/_next/static/stale123abcdef.js` ,
1450- )
1451-
1452- expect ( response ?. status ( ) ) . toBe ( 404 )
1453- expect ( response ?. headers ( ) ) . not . toHaveProperty ( 'x-nf-function-type' )
1454- } )
1455- } )
14561390} )
0 commit comments