From 508cf2b7fc90b01ceee2fc53e3616bd37f39b838 Mon Sep 17 00:00:00 2001 From: AriFreyr Date: Mon, 11 Jan 2021 19:35:02 +0000 Subject: [PATCH] add integration test for maxage header --- test/integration/prerender/pages/index.js | 2 +- test/integration/prerender/test/index.test.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/integration/prerender/pages/index.js b/test/integration/prerender/pages/index.js index b63b9295f70ce..063d1a7941d87 100644 --- a/test/integration/prerender/pages/index.js +++ b/test/integration/prerender/pages/index.js @@ -5,7 +5,7 @@ export async function getStaticProps() { return { props: { world: 'world', time: new Date().getTime() }, // bad-prop - revalidate: 1, + revalidate: 2, } } diff --git a/test/integration/prerender/test/index.test.js b/test/integration/prerender/test/index.test.js index 4667674bd6d62..2618373a5a265 100644 --- a/test/integration/prerender/test/index.test.js +++ b/test/integration/prerender/test/index.test.js @@ -521,6 +521,13 @@ const runTests = (dev = false, isEmulatedServerless = false) => { expect(data.pageProps.post).toBe('post-3') }) + it('should use correct caching headers for a revalidate page', async () => { + const initialRes = await fetchViaHTTP(appPort, '/') + expect(initialRes.headers.get('cache-control')).toBe( + 's-maxage=2, stale-while-revalidate' + ) + }) + it('should navigate to a normal page and back', async () => { const browser = await webdriver(appPort, '/') let text = await browser.elementByCss('p').text()