-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathcli-before-frameworks-api-support.test.ts
28 lines (23 loc) · 1.2 KB
/
cli-before-frameworks-api-support.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { expect } from '@playwright/test'
import { test } from '../utils/playwright-helpers.js'
test('should serve 404 page when requesting non existing page (no matching route) if site is deployed with CLI not supporting frameworks API', async ({
page,
cliBeforeFrameworksAPISupport,
}) => {
// 404 page is built and uploaded to blobs at build time
// when Next.js serves 404 it will try to fetch it from the blob store
// if request handler function is unable to get from blob store it will
// fail request handling and serve 500 error.
// This implicitly tests that request handler function is able to read blobs
// that are uploaded as part of site deploy.
// This also tests if edge middleware is working.
const response = await page.goto(new URL('non-existing', cliBeforeFrameworksAPISupport.url).href)
const headers = response?.headers() || {}
expect(response?.status()).toBe(404)
expect(await page.textContent('h1')).toBe('404')
expect(headers['netlify-cdn-cache-control']).toBe(
'no-cache, no-store, max-age=0, must-revalidate',
)
expect(headers['cache-control']).toBe('no-cache,no-store,max-age=0,must-revalidate')
expect(headers['x-hello-from-middleware']).toBe('hello')
})