Commit e0e23b69 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig

header test

parent b38c7f3b
...@@ -2,12 +2,12 @@ import type * as Playwright from 'playwright' ...@@ -2,12 +2,12 @@ import type * as Playwright from 'playwright'
import webdriver from 'next-webdriver' import webdriver from 'next-webdriver'
import { createRouterAct } from 'router-act' import { createRouterAct } from 'router-act'
import { findPort } from 'next-test-utils' 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' import { build, start } from './servers.mjs'
describe('segment cache (deployment skew)', () => { describe('segment cache (deployment skew)', () => {
if (isNextDev || isNextDeploy) { if (isNextDev) {
test('should not run during dev or deploy test runs', () => {}) test('should not run during dev', () => {})
return return
} }
...@@ -21,39 +21,65 @@ describe('segment cache (deployment skew)', () => { ...@@ -21,39 +21,65 @@ describe('segment cache (deployment skew)', () => {
// start a proxy server that rewrites incoming requests to one or the other // start a proxy server that rewrites incoming requests to one or the other
// based on the request information. // based on the request information.
let cleanup: () => Promise<void> if (isNextStart) {
let port: number 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', () => { afterAll(async () => {
beforeAll(async () => { await cleanup()
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 () => { runTests(() => port)
await cleanup()
}) })
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', () => { afterAll(async () => {
beforeAll(async () => { await cleanup()
build('DEPLOYMENT_ID') })
const proxyPort = (port = await findPort())
const nextPort1 = await findPort() runTests(() => port)
const nextPort2 = await findPort()
cleanup = await start(proxyPort, nextPort1, nextPort2, 'DEPLOYMENT_ID')
}) })
}
afterAll(async () => { describe('header with deployment id', () => {
await cleanup() 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