|
1 | 1 | import { expect, type Locator } 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' |
4 | 6 |
|
5 | 7 | const expectImageWasLoaded = async (locator: Locator) => {
|
6 | 8 | expect(await locator.evaluate((img: HTMLImageElement) => img.naturalHeight)).toBeGreaterThan(0)
|
@@ -282,3 +284,27 @@ test('can require CJS module that is not bundled', async ({ simple }) => {
|
282 | 284 | expect(parsedBody.notBundledCJSModule.isBundled).toEqual(false)
|
283 | 285 | expect(parsedBody.bundledCJSModule.isBundled).toEqual(true)
|
284 | 286 | })
|
| 287 | + |
| 288 | +test('serves a 200 for an existing static asset without invoking a function', async ({ |
| 289 | + page, |
| 290 | + simple, |
| 291 | +}) => { |
| 292 | + // Since assets are hashed, we can't hardcode anything here. Find something to fetch. |
| 293 | + const [staticAsset] = await readdir(join(simple.isolatedFixtureRoot, '.next', 'static', 'chunks')) |
| 294 | + expect(staticAsset).toBeDefined() |
| 295 | + |
| 296 | + const response = await page.goto(`${simple.url}/_next/static/chunks/${staticAsset}`) |
| 297 | + |
| 298 | + expect(response?.status()).toBe(200) |
| 299 | + expect(response?.headers()).not.toHaveProperty('x-nf-function-type') |
| 300 | +}) |
| 301 | + |
| 302 | +test('serves a 404 for a nonexistent static asset without invoking a function', async ({ |
| 303 | + page, |
| 304 | + simple, |
| 305 | +}) => { |
| 306 | + const response = await page.goto(`${simple.url}/_next/static/stale123abcdef.js`) |
| 307 | + |
| 308 | + expect(response?.status()).toBe(404) |
| 309 | + expect(response?.headers()).not.toHaveProperty('x-nf-function-type') |
| 310 | +}) |
0 commit comments