Skip to content

Commit

Permalink
add 404 by default for parallel routes
Browse files Browse the repository at this point in the history
  • Loading branch information
feedthejim committed Apr 3, 2023
1 parent 5e4abc0 commit 6ce7349
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
@@ -1,3 +1,5 @@
import { notFound } from './not-found'

export default function NoopParallelRouteDefault() {
return null
notFound()
}
@@ -0,0 +1,3 @@
export default function Page({ params }) {
return <div>default modal slot</div>
}
Expand Up @@ -183,6 +183,27 @@ createNextDescribe(
expect(html).toContain('parallel/(new)/layout')
expect(html).toContain('parallel/(new)/@baz/nested/page')
})

it('should throw a 404 when no matching parallel route is found', async () => {
const browser = await next.browser('/parallel-tab-bar')
// we make sure the page is available through navigating
await check(
() => browser.waitForElementByCss('#home').text(),
'Tab bar page (@children)'
)
await browser.elementByCss('#view-duration-link').click()
await check(
() => browser.waitForElementByCss('#view-duration').text(),
'View duration'
)

// fetch /parallel-tab-bar/view-duration
const res = await next.fetch(
`${next.url}/parallel-tab-bar/view-duration`
)
const html = await res.text()
expect(html).toContain('page could not be found')
})
})

describe('route intercepting', () => {
Expand Down

0 comments on commit 6ce7349

Please sign in to comment.