Unverified Commit 4a926efb authored by JJ Kasper's avatar JJ Kasper Committed by GitHub
parent da043b55
......@@ -288,8 +288,11 @@ createNextDescribe(
origContent.replace('return value + 1', 'return value + 1000')
)
await browser.elementByCss('#inc').click()
await check(() => browser.elementByCss('h1').text(), '1001')
await check(async () => {
await browser.elementByCss('#inc').click()
const val = Number(await browser.elementByCss('h1').text())
return val > 1000 ? 'success' : val
}, 'success')
} finally {
await next.patchFile(filePath, origContent)
}
......
......@@ -41,30 +41,23 @@ describe('Prerender prefetch', () => {
reqs[path] = props
}
const browser = await webdriver(next.url, '/')
// wait for prefetch to occur
await check(async () => {
const cache = await browser.eval(
'JSON.stringify(window.next.router.sdc)'
)
return cache.includes('/blog/first') && cache.includes('/blog/second')
? 'success'
: cache
}, 'success')
// wait revalidate period
await waitFor(3000)
await browser.refresh()
// reload after revalidate period and wait for prefetch again
await check(async () => {
const cache = await browser.eval(
'JSON.stringify(window.next.router.sdc)'
// do prefetch requests
for (const path of ['/blog/first', '/blog/second']) {
const res = await fetchViaHTTP(
next.url,
`/_next/data/${next.buildId}${path}.json`,
undefined,
{
headers: {
purpose: 'prefetch',
},
}
)
return cache.includes('/blog/first') && cache.includes('/blog/second')
? 'success'
: cache
}, 'success')
expect(res.status).toBe(200)
}
// ensure revalidate did not occur from prefetch
for (const path of ['/blog/first', '/blog/second']) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment