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,6 +21,7 @@ describe('segment cache (deployment skew)', () => { ...@@ -21,6 +21,7 @@ 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.
if (isNextStart) {
let cleanup: () => Promise<void> let cleanup: () => Promise<void>
let port: number let port: number
...@@ -55,6 +56,31 @@ describe('segment cache (deployment skew)', () => { ...@@ -55,6 +56,31 @@ describe('segment cache (deployment skew)', () => {
runTests(() => port) runTests(() => port)
}) })
}
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',
},
})
// 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()
}
})
})
}) })
function runTests(getPort: () => number) { function runTests(getPort: () => number) {
......
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