Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Nested Catch-All Coverage #10659

Merged
merged 11 commits into from Feb 24, 2020
2 changes: 1 addition & 1 deletion test/integration/prerender/pages/catchall/[...slug].js
Expand Up @@ -29,5 +29,5 @@ export default ({ slug }) => {
if (isFallback) {
return <p id="catchall">fallback</p>
}
return <p id="catchall">Hi {slug.join('/')}</p>
return <p id="catchall">Hi {slug.join(' ')}</p>
}
34 changes: 33 additions & 1 deletion test/integration/prerender/test/index.test.js
Expand Up @@ -376,7 +376,7 @@ const runTests = (dev = false, looseMode = false) => {
.text()
).isFallback
).toBe(false)
expect($('#catchall').text()).toMatch(/Hi.*?another\/value/)
expect($('#catchall').text()).toMatch(/Hi.*?another value/)
})

it('should support lazy catchall route', async () => {
Expand Down Expand Up @@ -405,6 +405,38 @@ const runTests = (dev = false, looseMode = false) => {
}
})

it('should support nested lazy catchall route', async () => {
// Dev doesn't support fallback yet
if (dev) {
const html = await renderViaHTTP(
appPort,
'/catchall/notreturnedinpaths/nested'
)
const $ = cheerio.load(html)
expect($('#catchall').text()).toMatch(/Hi.*?notreturnedinpaths nested/)
}
// Production will render fallback for a "lazy" route
else {
const html = await renderViaHTTP(
appPort,
'/catchall/notreturnedinpaths/nested'
)
const $ = cheerio.load(html)
expect($('#catchall').text()).toBe('fallback')

// hydration
const browser = await webdriver(appPort, '/catchall/delayby3s/nested')

const text1 = await browser.elementByCss('#catchall').text()
expect(text1).toBe('fallback')

await new Promise(resolve => setTimeout(resolve, 4000))
Timer marked this conversation as resolved.
Show resolved Hide resolved

const text2 = await browser.elementByCss('#catchall').text()
expect(text2).toMatch(/Hi.*?delayby3s nested/)
}
})

if (dev) {
// TODO: re-enable when this is supported in dev
// it('should show error when rewriting to dynamic SSG page', async () => {
Expand Down