Commit e0e23b69 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

header test

parent b38c7f3b
......@@ -2,12 +2,12 @@ import type * as Playwright from 'playwright'
import webdriver from 'next-webdriver'
import { createRouterAct } from 'router-act'
import { findPort } from 'next-test-utils'
import { isNextDeploy, isNextDev } from 'e2e-utils'
import { isNextDeploy, isNextDev, isNextStart, nextTestSetup } from 'e2e-utils'
import { build, start } from './servers.mjs'
describe('segment cache (deployment skew)', () => {
if (isNextDev || isNextDeploy) {
test('should not run during dev or deploy test runs', () => {})
if (isNextDev) {
test('should not run during dev', () => {})
return
}
......@@ -21,39 +21,65 @@ describe('segment cache (deployment skew)', () => {
// start a proxy server that rewrites incoming requests to one or the other
// based on the request information.
let cleanup: () => Promise<void>
let port: number
if (isNextStart) {
let cleanup: () => Promise<void>
let port: number
describe('with BUILD_ID', () => {
beforeAll(async () => {
build('BUILD_ID')
const proxyPort = (port = await findPort())
const nextPort1 = await findPort()
const nextPort2 = await findPort()
cleanup = await start(proxyPort, nextPort1, nextPort2, 'BUILD_ID')
})
describe('with BUILD_ID', () => {
beforeAll(async () => {
build('BUILD_ID')
const proxyPort = (port = await findPort())
const nextPort1 = await findPort()
const nextPort2 = await findPort()
cleanup = await start(proxyPort, nextPort1, nextPort2, 'BUILD_ID')
})
afterAll(async () => {
await cleanup()
})
afterAll(async () => {
await cleanup()
runTests(() => port)
})
runTests(() => port)
})
describe('with NEXT_DEPLOYMENT_ID', () => {
beforeAll(async () => {
build('DEPLOYMENT_ID')
const proxyPort = (port = await findPort())
const nextPort1 = await findPort()
const nextPort2 = await findPort()
cleanup = await start(proxyPort, nextPort1, nextPort2, 'DEPLOYMENT_ID')
})
describe('with NEXT_DEPLOYMENT_ID', () => {
beforeAll(async () => {
build('DEPLOYMENT_ID')
const proxyPort = (port = await findPort())
const nextPort1 = await findPort()
const nextPort2 = await findPort()
cleanup = await start(proxyPort, nextPort1, nextPort2, 'DEPLOYMENT_ID')
afterAll(async () => {
await cleanup()
})
runTests(() => port)
})
}
afterAll(async () => {
await cleanup()
describe('header with deployment id', () => {
const { next } = nextTestSetup({
files: __dirname,
env: {
// rely on skew protection when deployed
NEXT_DEPLOYMENT_ID: isNextDeploy ? undefined : 'test-deployment-id',
},
})
runTests(() => port)
// Deployment skew is hard to properly e2e deploy test, so this just checks for the header
it('header is set on RSC responses', async () => {
for (const route of ['/dynamic-page', '/static-page']) {
await next.fetch(route)
let res = await next.fetch(`${route}?_rsc=`, {
headers: { rsc: '1' },
})
expect(res.status).toBe(200)
expect(res.headers.get('content-type')).toBe('text/x-component')
expect(res.headers.get('x-nextjs-deployment-id')).toBeTruthy()
}
})
})
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment