From 96d6370572cb3e9182c427f2d61e0d74a2e1c72e Mon Sep 17 00:00:00 2001 From: Zack Tanner <1939140+ztanner@users.noreply.github.com> Date: Thu, 13 Jun 2024 08:54:59 -0700 Subject: [PATCH] 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. --- test/deploy-tests-manifest.json | 1 - test/e2e/revalidate-reason/pages/index.tsx | 6 +++--- test/e2e/revalidate-reason/pages/stale.tsx | 6 +++--- test/e2e/revalidate-reason/revalidate-reason.test.ts | 12 ++++-------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/test/deploy-tests-manifest.json b/test/deploy-tests-manifest.json index 886fcdda1a..612d73460d 100644 --- a/test/deploy-tests-manifest.json +++ b/test/deploy-tests-manifest.json @@ -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", diff --git a/test/e2e/revalidate-reason/pages/index.tsx b/test/e2e/revalidate-reason/pages/index.tsx index 0e42d22ada..cc644a7123 100644 --- a/test/e2e/revalidate-reason/pages/index.tsx +++ b/test/e2e/revalidate-reason/pages/index.tsx @@ -7,11 +7,11 @@ export async function getStaticProps({ params, revalidateReason }) { ) return { props: { - hello: 'world', + reason: revalidateReason, }, } } -export default ({ hello }) => { - return

hello: {hello}

+export default ({ reason }) => { + return

revalidate reason: {reason}

} diff --git a/test/e2e/revalidate-reason/pages/stale.tsx b/test/e2e/revalidate-reason/pages/stale.tsx index 62b9848b20..a898161096 100644 --- a/test/e2e/revalidate-reason/pages/stale.tsx +++ b/test/e2e/revalidate-reason/pages/stale.tsx @@ -7,12 +7,12 @@ export async function getStaticProps({ params, revalidateReason }) { ) return { props: { - hello: 'world', + reason: revalidateReason, }, revalidate: 5, } } -export default ({ hello }) => { - return

hello: {hello}

+export default ({ reason }) => { + return

revalidate reason: {reason}

} diff --git a/test/e2e/revalidate-reason/revalidate-reason.test.ts b/test/e2e/revalidate-reason/revalidate-reason.test.ts index 6de92cf44d..cc4485ba90 100644 --- a/test/e2e/revalidate-reason/revalidate-reason.test.ts +++ b/test/e2e/revalidate-reason/revalidate-reason.test.ts @@ -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') }) }) })