From a2632f64373f37c9f1310c5d1a3c288c08f3fde8 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 20 Dec 2023 17:39:36 -0600 Subject: [PATCH 1/3] Add unstable_cache validate test case --- .../app-invalid-revalidate.test.ts | 22 +++++++++++++++++++ .../app-invalid-revalidate/app/page.tsx | 3 +++ 2 files changed, 25 insertions(+) diff --git a/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts b/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts index 398eaa6261de8..394b9565449a9 100644 --- a/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts +++ b/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts @@ -74,5 +74,27 @@ createNextDescribe( await next.patchFile('app/page.tsx', origText) } }) + + it('should error properly for invalid revalidate on unstable_cache', async () => { + await next.stop().catch(() => {}) + const origText = await next.readFile('app/page.tsx') + + try { + await next.patchFile( + 'app/page.tsx', + origText.replace('// await unstable', 'await unstable') + ) + await next.start().catch(() => {}) + + await check(async () => { + if (isNextDev) { + await next.fetch('/') + } + return next.cliOutput + }, /Invalid revalidate value "1" on "unstable_cache async \(\)=>Date.now\(\)"/) + } finally { + await next.patchFile('app/page.tsx', origText) + } + }) } ) diff --git a/test/e2e/app-dir/app-invalid-revalidate/app/page.tsx b/test/e2e/app-dir/app-invalid-revalidate/app/page.tsx index 0a55367c3f55d..02b0c157e1112 100644 --- a/test/e2e/app-dir/app-invalid-revalidate/app/page.tsx +++ b/test/e2e/app-dir/app-invalid-revalidate/app/page.tsx @@ -1,6 +1,9 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { unstable_cache } from 'next/cache' // export const revalidate = '1' export default async function Page() { // await fetch('https://example.vercel.sh', { next: { revalidate: '1' } }) + // await unstable_cache(async () => Date.now(), [], { revalidate: '1' })() return

hello world

} From 4803149be1daa62efc9545f879f2ef498b761640 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 20 Dec 2023 17:47:14 -0600 Subject: [PATCH 2/3] update --- .../app-invalid-revalidate/app-invalid-revalidate.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts b/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts index 394b9565449a9..9a02f3949abcd 100644 --- a/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts +++ b/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts @@ -91,7 +91,7 @@ createNextDescribe( await next.fetch('/') } return next.cliOutput - }, /Invalid revalidate value "1" on "unstable_cache async \(\)=>Date.now\(\)"/) + }, /Invalid revalidate value "1" on "unstable_cache"/) } finally { await next.patchFile('app/page.tsx', origText) } From 2ee1084c26e8a70988d1d07a1c79e67b69fe6f49 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 20 Dec 2023 17:48:37 -0600 Subject: [PATCH 3/3] update --- .../app-invalid-revalidate/app-invalid-revalidate.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts b/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts index 394b9565449a9..1908b8ce41c59 100644 --- a/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts +++ b/test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts @@ -91,7 +91,7 @@ createNextDescribe( await next.fetch('/') } return next.cliOutput - }, /Invalid revalidate value "1" on "unstable_cache async \(\)=>Date.now\(\)"/) + }, /Invalid revalidate value "1" on "unstable_cache/) } finally { await next.patchFile('app/page.tsx', origText) }