fix revalidate-reason deploy test (#66830)

Since `next.cliOutput` won't have access to runtime logs we can refactor
this test to render text on the page instead.
This commit is contained in:
Zack Tanner 2024-06-13 08:54:59 -07:00 committed by GitHub
parent 258726e42b
commit 96d6370572
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 15 deletions

View file

@ -50,7 +50,6 @@
"test/e2e/new-link-behavior/stitches.test.ts",
"test/e2e/next-image-forward-ref/index.test.ts",
"test/e2e/react-compiler/react-compiler.test.ts",
"test/e2e/revalidate-reason/revalidate-reason.test.ts",
"test/e2e/app-dir/actions/app-action.test.ts",
"test/e2e/app-dir/i18n-hybrid/i18n-hybrid.test.js",
"test/e2e/app-dir/metadata/metadata.test.ts",

View file

@ -7,11 +7,11 @@ export async function getStaticProps({ params, revalidateReason }) {
)
return {
props: {
hello: 'world',
reason: revalidateReason,
},
}
}
export default ({ hello }) => {
return <p>hello: {hello}</p>
export default ({ reason }) => {
return <p id="reason">revalidate reason: {reason}</p>
}

View file

@ -7,12 +7,12 @@ export async function getStaticProps({ params, revalidateReason }) {
)
return {
props: {
hello: 'world',
reason: revalidateReason,
},
revalidate: 5,
}
}
export default ({ hello }) => {
return <p>hello: {hello}</p>
export default ({ reason }) => {
return <p id="reason">revalidate reason: {reason}</p>
}

View file

@ -38,9 +38,8 @@ describe('revalidate-reason', () => {
expect(res.status).toBe(200)
expect(next.cliOutput).toContain(
'revalidate-reason/pages/index.tsx revalidateReason: on-demand'
)
const $ = await next.render$('/')
expect($('#reason').text()).toBe('revalidate reason: on-demand')
})
it('should support revalidateReason: "stale"', async () => {
@ -51,11 +50,8 @@ describe('revalidate-reason', () => {
await waitFor(5000)
await retry(async () => {
await next.fetch('/stale')
expect(next.cliOutput).toContain(
'revalidate-reason/pages/stale.tsx revalidateReason: stale'
)
const $ = await next.render$('/stale')
expect($('#reason').text()).toBe('revalidate reason: stale')
})
})
})