Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit fce1c6d

Browse files
committedDec 18, 2024·
fix: update test with getServerSideProps
1 parent bab0894 commit fce1c6d

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed
 

‎test/production/deployment-id-handling/app/pages/pages-edge.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import testImage from '../public/test.jpg'
22
import Image from 'next/image'
33

4-
export default function Page() {
4+
export default function Page({ data }: { data: string }) {
55
return (
66
<>
7-
<p>hello pages edge</p>
7+
<h1>{data}</h1>
88
<Image src={testImage} alt="test image" />
99
<p id="deploymentId">{process.env.NEXT_DEPLOYMENT_ID}</p>
1010

@@ -25,3 +25,11 @@ export default function Page() {
2525
export const config = {
2626
runtime: 'experimental-edge',
2727
}
28+
29+
export function getServerSideProps() {
30+
return {
31+
props: {
32+
data: 'hello pages edge',
33+
},
34+
}
35+
}

‎test/production/deployment-id-handling/deployment-id-handling.test.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,20 @@ describe.each(['NEXT_DEPLOYMENT_ID', 'CUSTOM_DEPLOYMENT_ID'])(
9090
beforePageLoad(page) {
9191
page.on('request', async (req) => {
9292
const headers = await req.allHeaders()
93-
if (headers['x-next-data']) {
93+
if (headers['x-nextjs-data']) {
9494
dataHeaders.push(headers)
9595
}
9696
})
9797
},
9898
})
9999

100-
await browser.elementById('edge-link').click()
100+
await browser.elementByCss('#edge-link').click()
101101

102-
expect(dataHeaders.length).toBeGreaterThan(0)
102+
await retry(async () => {
103+
expect(await browser.elementByCss('h1').text()).toBe('hello pages edge')
104+
expect(await browser.url()).toContain('/pages-edge')
105+
expect(dataHeaders.length).toBeGreaterThan(0)
106+
})
103107

104108
expect(
105109
dataHeaders.every(

0 commit comments

Comments
 (0)
Please sign in to comment.