|
1 | 1 | import { nextTestSetup } from 'e2e-utils'
|
2 |
| -import { check } from 'next-test-utils' |
| 2 | +import { check, retry } from 'next-test-utils' |
3 | 3 | import { join } from 'node:path'
|
4 | 4 |
|
5 | 5 | describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])(
|
@@ -51,7 +51,9 @@ describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])(
|
51 | 51 | const requests = []
|
52 | 52 |
|
53 | 53 | browser.on('request', (req) => {
|
54 |
| - requests.push(req.url()) |
| 54 | + if (req.url().includes('/_next/static')) { |
| 55 | + requests.push(req.url()) |
| 56 | + } |
55 | 57 | })
|
56 | 58 |
|
57 | 59 | await browser.elementByCss('#dynamic-import').click()
|
@@ -81,8 +83,37 @@ describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])(
|
81 | 83 | })
|
82 | 84 | }
|
83 | 85 | )
|
| 86 | + |
| 87 | + it('should contain deployment id in RSC payload request headers', async () => { |
| 88 | + const rscHeaders = [] |
| 89 | + const browser = await next.browser('/from-app', { |
| 90 | + beforePageLoad(page) { |
| 91 | + page.on('request', async (req) => { |
| 92 | + const headers = await req.allHeaders() |
| 93 | + if (headers['rsc']) { |
| 94 | + rscHeaders.push(headers) |
| 95 | + } |
| 96 | + }) |
| 97 | + }, |
| 98 | + }) |
| 99 | + |
| 100 | + await browser.elementByCss('#other-app').click() |
| 101 | + |
| 102 | + await retry(async () => { |
| 103 | + expect(await browser.elementByCss('h1').text()).toBe('other app') |
| 104 | + expect(await browser.url()).toContain('/other-app') |
| 105 | + expect(rscHeaders.length).toBeGreaterThan(0) |
| 106 | + }) |
| 107 | + |
| 108 | + expect( |
| 109 | + rscHeaders.every( |
| 110 | + (headers) => headers['x-deployment-id'] === deploymentId |
| 111 | + ) |
| 112 | + ).toBe(true) |
| 113 | + }) |
84 | 114 | }
|
85 | 115 | )
|
| 116 | + |
86 | 117 | describe('deployment-id-handling disabled', () => {
|
87 | 118 | const deploymentId = Date.now() + ''
|
88 | 119 | const { next } = nextTestSetup({
|
|
0 commit comments