1
1
import { expect } from '@playwright/test'
2
2
import { nextVersionSatisfies } from '../utils/next-version-helpers.mjs'
3
3
import { test } from '../utils/playwright-helpers.js'
4
- import { join } from 'node:path'
5
- import { readdir } from 'node:fs/promises'
6
4
7
5
export function waitFor ( millis : number ) {
8
6
return new Promise ( ( resolve ) => setTimeout ( resolve , millis ) )
@@ -616,34 +614,6 @@ test.describe('Simple Page Router (no basePath, no i18n)', () => {
616
614
/ ( s - m a x a g e | m a x - a g e ) / ,
617
615
)
618
616
} )
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
- } )
647
617
} )
648
618
649
619
test . describe ( 'Page Router with basePath and i18n' , ( ) => {
@@ -1382,15 +1352,13 @@ test.describe('Page Router with basePath and i18n', () => {
1382
1352
1383
1353
test ( 'requesting a non existing page route that needs to be fetched from the blob store like 404.html' , async ( {
1384
1354
page,
1385
- pageRouterBasePathI18n ,
1355
+ pageRouter ,
1386
1356
} ) => {
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 )
1390
1358
const headers = response ?. headers ( ) || { }
1391
1359
expect ( response ?. status ( ) ) . toBe ( 404 )
1392
1360
1393
- expect ( await page . textContent ( 'p' ) ) . toBe ( 'Custom 404 page for locale: en ' )
1361
+ expect ( await page . textContent ( 'p' ) ) . toBe ( 'Custom 404 page' )
1394
1362
1395
1363
expect ( headers [ 'debug-netlify-cdn-cache-control' ] ) . toMatch (
1396
1364
/ 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', () => {
1400
1368
1401
1369
test ( 'requesting a non existing page route that needs to be fetched from the blob store like 404.html (notFound: true)' , async ( {
1402
1370
page,
1403
- pageRouterBasePathI18n ,
1371
+ pageRouter ,
1404
1372
} ) => {
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 )
1408
1374
const headers = response ?. headers ( ) || { }
1409
1375
expect ( response ?. status ( ) ) . toBe ( 404 )
1410
1376
1411
- expect ( await page . textContent ( 'p' ) ) . toBe ( 'Custom 404 page for locale: en ' )
1377
+ expect ( await page . textContent ( 'p' ) ) . toBe ( 'Custom 404 page' )
1412
1378
1413
1379
// Prior to v14.2.4 notFound pages are not cacheable
1414
1380
// https://github.com/vercel/next.js/pull/66674
@@ -1421,36 +1387,4 @@ test.describe('Page Router with basePath and i18n', () => {
1421
1387
expect ( headers [ 'cache-control' ] ) . toBe ( 'public,max-age=0,must-revalidate' )
1422
1388
}
1423
1389
} )
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
- } )
1456
1390
} )
0 commit comments