Skip to content

test: add e2e test for error in head #4862

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions e2e/react-start/basic/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { Route as SearchParamsDefaultRouteImport } from './routes/search-params/
import { Route as RedirectTargetRouteImport } from './routes/redirect/$target'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
import { Route as NotFoundViaLoaderRouteImport } from './routes/not-found/via-loader'
import { Route as NotFoundViaHeadRouteImport } from './routes/not-found/via-head'
import { Route as NotFoundViaBeforeLoadRouteImport } from './routes/not-found/via-beforeLoad'
import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2'
import { Route as RedirectTargetIndexRouteImport } from './routes/redirect/$target/index'
Expand Down Expand Up @@ -170,6 +171,11 @@ const NotFoundViaLoaderRoute = NotFoundViaLoaderRouteImport.update({
path: '/via-loader',
getParentRoute: () => NotFoundRouteRoute,
} as any)
const NotFoundViaHeadRoute = NotFoundViaHeadRouteImport.update({
id: '/via-head',
path: '/via-head',
getParentRoute: () => NotFoundRouteRoute,
} as any)
const NotFoundViaBeforeLoadRoute = NotFoundViaBeforeLoadRouteImport.update({
id: '/via-beforeLoad',
path: '/via-beforeLoad',
Expand Down Expand Up @@ -271,6 +277,7 @@ export interface FileRoutesByFullPath {
'/users': typeof UsersRouteWithChildren
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-head': typeof NotFoundViaHeadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
'/redirect/$target': typeof RedirectTargetRouteWithChildren
Expand Down Expand Up @@ -303,6 +310,7 @@ export interface FileRoutesByTo {
'/stream': typeof StreamRoute
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-head': typeof NotFoundViaHeadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
'/search-params/default': typeof SearchParamsDefaultRoute
Expand Down Expand Up @@ -340,6 +348,7 @@ export interface FileRoutesById {
'/대한민국': typeof Char45824Char54620Char48124Char44397Route
'/_layout/_layout-2': typeof LayoutLayout2RouteWithChildren
'/not-found/via-beforeLoad': typeof NotFoundViaBeforeLoadRoute
'/not-found/via-head': typeof NotFoundViaHeadRoute
'/not-found/via-loader': typeof NotFoundViaLoaderRoute
'/posts/$postId': typeof PostsPostIdRoute
'/redirect/$target': typeof RedirectTargetRouteWithChildren
Expand Down Expand Up @@ -379,6 +388,7 @@ export interface FileRouteTypes {
| '/users'
| '/대한민국'
| '/not-found/via-beforeLoad'
| '/not-found/via-head'
| '/not-found/via-loader'
| '/posts/$postId'
| '/redirect/$target'
Expand Down Expand Up @@ -411,6 +421,7 @@ export interface FileRouteTypes {
| '/stream'
| '/대한민국'
| '/not-found/via-beforeLoad'
| '/not-found/via-head'
| '/not-found/via-loader'
| '/posts/$postId'
| '/search-params/default'
Expand Down Expand Up @@ -447,6 +458,7 @@ export interface FileRouteTypes {
| '/대한민국'
| '/_layout/_layout-2'
| '/not-found/via-beforeLoad'
| '/not-found/via-head'
| '/not-found/via-loader'
| '/posts/$postId'
| '/redirect/$target'
Expand Down Expand Up @@ -615,6 +627,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof NotFoundViaBeforeLoadRouteImport
parentRoute: typeof NotFoundRouteRoute
}
'/not-found/via-head': {
id: '/not-found/via-head'
path: '/via-head'
fullPath: '/not-found/via-head'
preLoaderRoute: typeof NotFoundViaHeadRouteImport
parentRoute: typeof NotFoundRouteRoute
}
'/not-found/via-loader': {
id: '/not-found/via-loader'
path: '/via-loader'
Expand Down Expand Up @@ -892,6 +911,13 @@ declare module '@tanstack/react-start/server' {
preLoaderRoute: unknown
parentRoute: typeof rootServerRouteImport
}
'/not-found/via-head': {
id: '/not-found/via-head'
path: '/via-head'
fullPath: '/not-found/via-head'
preLoaderRoute: unknown
parentRoute: typeof rootServerRouteImport
}
'/not-found/via-loader': {
id: '/not-found/via-loader'
path: '/via-loader'
Expand Down Expand Up @@ -1301,6 +1327,23 @@ declare module './routes/not-found/via-beforeLoad' {
unknown
>
}
declare module './routes/not-found/via-head' {
const createFileRoute: CreateFileRoute<
'/not-found/via-head',
FileRoutesByPath['/not-found/via-head']['parentRoute'],
FileRoutesByPath['/not-found/via-head']['id'],
FileRoutesByPath['/not-found/via-head']['path'],
FileRoutesByPath['/not-found/via-head']['fullPath']
>

const createServerFileRoute: CreateServerFileRoute<
ServerFileRoutesByPath['/not-found/via-head']['parentRoute'],
ServerFileRoutesByPath['/not-found/via-head']['id'],
ServerFileRoutesByPath['/not-found/via-head']['path'],
ServerFileRoutesByPath['/not-found/via-head']['fullPath'],
unknown
>
}
declare module './routes/not-found/via-loader' {
const createFileRoute: CreateFileRoute<
'/not-found/via-loader',
Expand Down Expand Up @@ -1712,12 +1755,14 @@ declare module './routes/foo/$bar/$qux/_here/index' {

interface NotFoundRouteRouteChildren {
NotFoundViaBeforeLoadRoute: typeof NotFoundViaBeforeLoadRoute
NotFoundViaHeadRoute: typeof NotFoundViaHeadRoute
NotFoundViaLoaderRoute: typeof NotFoundViaLoaderRoute
NotFoundIndexRoute: typeof NotFoundIndexRoute
}

const NotFoundRouteRouteChildren: NotFoundRouteRouteChildren = {
NotFoundViaBeforeLoadRoute: NotFoundViaBeforeLoadRoute,
NotFoundViaHeadRoute: NotFoundViaHeadRoute,
NotFoundViaLoaderRoute: NotFoundViaLoaderRoute,
NotFoundIndexRoute: NotFoundIndexRoute,
}
Expand Down
10 changes: 10 additions & 0 deletions e2e/react-start/basic/src/routes/not-found/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ export const Route = createFileRoute({
via-loader
</Link>
</div>
<div className="mb-2">
<Link
from={Route.fullPath}
to="./via-head"
preload={preload}
data-testid="via-head"
>
via-head
</Link>
</div>
</div>
)
},
Expand Down
23 changes: 23 additions & 0 deletions e2e/react-start/basic/src/routes/not-found/via-head.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { notFound } from '@tanstack/react-router'

export const Route = createFileRoute({
head: () => {
throw notFound()
},
component: RouteComponent,
notFoundComponent: () => {
return (
<div data-testid="via-head-notFound-component">
Not Found "/not-found/via-head"!
</div>
)
},
})

function RouteComponent() {
return (
<div data-testid="via-head-route-component">
Hello "/not-found/via-head"!
</div>
)
}
16 changes: 12 additions & 4 deletions e2e/react-start/basic/tests/not-found.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ test.describe('not-found', () => {

test.describe('throw notFound()', () => {
const navigationTestMatrix = combinate({
// TODO beforeLoad!
thrower: [/* 'beforeLoad',*/ 'loader'] as const,
// TODO beforeLoad and head!
thrower: [
// 'beforeLoad',
'loader',
'head',
] as const,
preload: [false, true] as const,
})

Expand Down Expand Up @@ -53,9 +57,13 @@ test.describe('not-found', () => {
})
})
const directVisitTestMatrix = combinate({
// TODO beforeLoad!
// TODO beforeLoad and head!

thrower: [/* 'beforeLoad',*/ 'loader'] as const,
thrower: [
// 'beforeLoad',
'loader',
'head',
] as const,
})

directVisitTestMatrix.forEach(({ thrower }) => {
Expand Down
Loading