Skip to content
Merged
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
101 changes: 101 additions & 0 deletions e2e/react-router/basic-file-based/src/routeTree.gen.ts

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions e2e/react-router/basic-file-based/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ function RootComponent() {
}}
>
Masks
</Link>{' '}
<Link
to="/pathless-layout"
data-testid="link-to-pathless-layout"
activeProps={{
className: 'font-bold',
}}
>
Pathless Layout
</Link>
</div>
<hr />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/pathless-layout/_layout/child')({
component: () => (
<div data-testid="pathless-layout-child">Pathless Layout Child Route</div>
),
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/pathless-layout/_layout/')({
component: () => (
<div data-testid="pathless-layout-index">Pathless Layout Index</div>
),
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Link, Outlet, createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/pathless-layout/_layout')({
component: () => (
<div>
<div data-testid="pathless-layout-wrapper">Pathless Layout Wrapper</div>
<nav>
<Link to="/pathless-layout/child" data-testid="link-to-child">
Go to Child
</Link>
</nav>
<Outlet />
</div>
),
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Outlet, createFileRoute } from '@tanstack/react-router'

export const Route = createFileRoute('/pathless-layout')({
component: () => (
<div>
<h2 data-testid="pathless-layout-header">Pathless Layout Section</h2>
<Outlet />
</div>
),
notFoundComponent: () => (
<div data-testid="pathless-layout-not-found">
Not Found in Pathless Layout
</div>
),
})
67 changes: 67 additions & 0 deletions e2e/react-router/basic-file-based/tests/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,70 @@ test.describe('Unicode route rendering', () => {
expect(page.url()).toBe(`${baseURL}/%EB%8C%80%ED%95%9C%EB%AF%BC%EA%B5%AD`)
})
})

test.describe('Pathless layout routes', () => {
test('direct navigation to pathless layout route renders correctly', async ({
page,
}) => {
await page.goto('/pathless-layout')
await expect(page.getByTestId('pathless-layout-header')).toContainText(
'Pathless Layout Section',
)
await expect(page.getByTestId('pathless-layout-wrapper')).toContainText(
'Pathless Layout Wrapper',
)
await expect(page.getByTestId('pathless-layout-index')).toContainText(
'Pathless Layout Index',
)
})

test('client-side navigation to pathless layout route', async ({ page }) => {
await page.goto('/')
await page.getByTestId('link-to-pathless-layout').click()
await expect(page.getByTestId('pathless-layout-header')).toContainText(
'Pathless Layout Section',
)
await expect(page.getByTestId('pathless-layout-wrapper')).toContainText(
'Pathless Layout Wrapper',
)
})

test('navigation within pathless layout preserves layout', async ({
page,
}) => {
await page.goto('/pathless-layout')
await page.getByTestId('link-to-child').click()
await expect(page.getByTestId('pathless-layout-header')).toContainText(
'Pathless Layout Section',
)
await expect(page.getByTestId('pathless-layout-wrapper')).toContainText(
'Pathless Layout Wrapper',
)
await expect(page.getByTestId('pathless-layout-child')).toContainText(
'Pathless Layout Child Route',
)
})

test('direct navigation to child of pathless layout', async ({ page }) => {
await page.goto('/pathless-layout/child')
await expect(page.getByTestId('pathless-layout-header')).toContainText(
'Pathless Layout Section',
)
await expect(page.getByTestId('pathless-layout-wrapper')).toContainText(
'Pathless Layout Wrapper',
)
await expect(page.getByTestId('pathless-layout-child')).toContainText(
'Pathless Layout Child Route',
)
})

test('navigating to non-existent route under pathless layout shows not found', async ({
page,
}) => {
await page.goto('/pathless-layout/does-not-exist')
await expect(page.getByTestId('pathless-layout-not-found')).toContainText(
'Not Found in Pathless Layout',
)
await expect(page.locator('body')).toContainText('Not Found')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Route as IndexRouteImport } from './routes/index'
import { Route as PostsIndexRouteImport } from './routes/posts.index'
import { Route as PostsPostIdRouteImport } from './routes/posts.$postId'
import { Route as LayoutLayout2RouteImport } from './routes/_layout/_layout-2'
import { Route as TransitionCountQueryRouteImport } from './routes/transition/count/query'
import { Route as LayoutLayout2LayoutBRouteImport } from './routes/_layout/_layout-2/layout-b'
import { Route as LayoutLayout2LayoutARouteImport } from './routes/_layout/_layout-2/layout-a'

Expand Down Expand Up @@ -47,11 +46,6 @@ const LayoutLayout2Route = LayoutLayout2RouteImport.update({
id: '/_layout-2',
getParentRoute: () => LayoutRoute,
} as any)
const TransitionCountQueryRoute = TransitionCountQueryRouteImport.update({
id: '/transition/count/query',
path: '/transition/count/query',
getParentRoute: () => rootRouteImport,
} as any)
const LayoutLayout2LayoutBRoute = LayoutLayout2LayoutBRouteImport.update({
id: '/layout-b',
path: '/layout-b',
Expand All @@ -70,15 +64,13 @@ export interface FileRoutesByFullPath {
'/posts/': typeof PostsIndexRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
'/layout-b': typeof LayoutLayout2LayoutBRoute
'/transition/count/query': typeof TransitionCountQueryRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/posts/$postId': typeof PostsPostIdRoute
'/posts': typeof PostsIndexRoute
'/layout-a': typeof LayoutLayout2LayoutARoute
'/layout-b': typeof LayoutLayout2LayoutBRoute
'/transition/count/query': typeof TransitionCountQueryRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
Expand All @@ -90,7 +82,6 @@ export interface FileRoutesById {
'/posts/': typeof PostsIndexRoute
'/_layout/_layout-2/layout-a': typeof LayoutLayout2LayoutARoute
'/_layout/_layout-2/layout-b': typeof LayoutLayout2LayoutBRoute
'/transition/count/query': typeof TransitionCountQueryRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
Expand All @@ -101,15 +92,8 @@ export interface FileRouteTypes {
| '/posts/'
| '/layout-a'
| '/layout-b'
| '/transition/count/query'
fileRoutesByTo: FileRoutesByTo
to:
| '/'
| '/posts/$postId'
| '/posts'
| '/layout-a'
| '/layout-b'
| '/transition/count/query'
to: '/' | '/posts/$postId' | '/posts' | '/layout-a' | '/layout-b'
id:
| '__root__'
| '/'
Expand All @@ -120,14 +104,12 @@ export interface FileRouteTypes {
| '/posts/'
| '/_layout/_layout-2/layout-a'
| '/_layout/_layout-2/layout-b'
| '/transition/count/query'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
LayoutRoute: typeof LayoutRouteWithChildren
PostsRoute: typeof PostsRouteWithChildren
TransitionCountQueryRoute: typeof TransitionCountQueryRoute
}

declare module '@tanstack/react-router' {
Expand Down Expand Up @@ -174,13 +156,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutLayout2RouteImport
parentRoute: typeof LayoutRoute
}
'/transition/count/query': {
id: '/transition/count/query'
path: '/transition/count/query'
fullPath: '/transition/count/query'
preLoaderRoute: typeof TransitionCountQueryRouteImport
parentRoute: typeof rootRouteImport
}
'/_layout/_layout-2/layout-b': {
id: '/_layout/_layout-2/layout-b'
path: '/layout-b'
Expand Down Expand Up @@ -239,7 +214,6 @@ const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
LayoutRoute: LayoutRouteWithChildren,
PostsRoute: PostsRouteWithChildren,
TransitionCountQueryRoute: TransitionCountQueryRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
Expand Down
45 changes: 8 additions & 37 deletions e2e/react-start/basic/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// You should NOT make any changes in this file as it will be overwritten.
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.

import { createFileRoute } from '@tanstack/react-router'

import { Route as rootRouteImport } from './routes/__root'
import { Route as Char45824Char54620Char48124Char44397RouteImport } from './routes/대한민국'
import { Route as UsersRouteImport } from './routes/users'
Expand Down Expand Up @@ -54,8 +52,6 @@ import { Route as RedirectTargetServerFnViaBeforeLoadRouteImport } from './route
import { Route as FooBarQuxHereRouteImport } from './routes/foo/$bar/$qux/_here'
import { Route as FooBarQuxHereIndexRouteImport } from './routes/foo/$bar/$qux/_here/index'

const FooBarQuxRouteImport = createFileRoute('/foo/$bar/$qux')()

const Char45824Char54620Char48124Char44397Route =
Char45824Char54620Char48124Char44397RouteImport.update({
id: '/대한민국',
Expand Down Expand Up @@ -203,11 +199,6 @@ const LayoutLayout2Route = LayoutLayout2RouteImport.update({
id: '/_layout-2',
getParentRoute: () => LayoutRoute,
} as any)
const FooBarQuxRoute = FooBarQuxRouteImport.update({
id: '/foo/$bar/$qux',
path: '/foo/$bar/$qux',
getParentRoute: () => rootRouteImport,
} as any)
const RedirectTargetIndexRoute = RedirectTargetIndexRouteImport.update({
id: '/',
path: '/',
Expand Down Expand Up @@ -269,8 +260,9 @@ const RedirectTargetServerFnViaBeforeLoadRoute =
getParentRoute: () => RedirectTargetRoute,
} as any)
const FooBarQuxHereRoute = FooBarQuxHereRouteImport.update({
id: '/_here',
getParentRoute: () => FooBarQuxRoute,
id: '/foo/$bar/$qux/_here',
path: '/foo/$bar/$qux',
getParentRoute: () => rootRouteImport,
} as any)
const FooBarQuxHereIndexRoute = FooBarQuxHereIndexRouteImport.update({
id: '/',
Expand Down Expand Up @@ -350,11 +342,11 @@ export interface FileRoutesByTo {
'/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute
'/redirect/$target/via-loader': typeof RedirectTargetViaLoaderRoute
'/redirect/$target': typeof RedirectTargetIndexRoute
'/foo/$bar/$qux': typeof FooBarQuxHereIndexRoute
'/redirect/$target/serverFn/via-beforeLoad': typeof RedirectTargetServerFnViaBeforeLoadRoute
'/redirect/$target/serverFn/via-loader': typeof RedirectTargetServerFnViaLoaderRoute
'/redirect/$target/serverFn/via-useServerFn': typeof RedirectTargetServerFnViaUseServerFnRoute
'/redirect/$target/serverFn': typeof RedirectTargetServerFnIndexRoute
'/foo/$bar/$qux': typeof FooBarQuxHereIndexRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
Expand Down Expand Up @@ -394,7 +386,6 @@ export interface FileRoutesById {
'/redirect/$target/via-beforeLoad': typeof RedirectTargetViaBeforeLoadRoute
'/redirect/$target/via-loader': typeof RedirectTargetViaLoaderRoute
'/redirect/$target/': typeof RedirectTargetIndexRoute
'/foo/$bar/$qux': typeof FooBarQuxRouteWithChildren
'/foo/$bar/$qux/_here': typeof FooBarQuxHereRouteWithChildren
'/redirect/$target/serverFn/via-beforeLoad': typeof RedirectTargetServerFnViaBeforeLoadRoute
'/redirect/$target/serverFn/via-loader': typeof RedirectTargetServerFnViaLoaderRoute
Expand Down Expand Up @@ -476,11 +467,11 @@ export interface FileRouteTypes {
| '/redirect/$target/via-beforeLoad'
| '/redirect/$target/via-loader'
| '/redirect/$target'
| '/foo/$bar/$qux'
| '/redirect/$target/serverFn/via-beforeLoad'
| '/redirect/$target/serverFn/via-loader'
| '/redirect/$target/serverFn/via-useServerFn'
| '/redirect/$target/serverFn'
| '/foo/$bar/$qux'
id:
| '__root__'
| '/'
Expand Down Expand Up @@ -519,7 +510,6 @@ export interface FileRouteTypes {
| '/redirect/$target/via-beforeLoad'
| '/redirect/$target/via-loader'
| '/redirect/$target/'
| '/foo/$bar/$qux'
| '/foo/$bar/$qux/_here'
| '/redirect/$target/serverFn/via-beforeLoad'
| '/redirect/$target/serverFn/via-loader'
Expand Down Expand Up @@ -547,7 +537,7 @@ export interface RootRouteChildren {
MultiCookieRedirectIndexRoute: typeof MultiCookieRedirectIndexRoute
RedirectIndexRoute: typeof RedirectIndexRoute
PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute
FooBarQuxRoute: typeof FooBarQuxRouteWithChildren
FooBarQuxHereRoute: typeof FooBarQuxHereRouteWithChildren
}

declare module '@tanstack/react-router' {
Expand Down Expand Up @@ -755,13 +745,6 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof LayoutLayout2RouteImport
parentRoute: typeof LayoutRoute
}
'/foo/$bar/$qux': {
id: '/foo/$bar/$qux'
path: '/foo/$bar/$qux'
fullPath: '/foo/$bar/$qux'
preLoaderRoute: typeof FooBarQuxRouteImport
parentRoute: typeof rootRouteImport
}
'/redirect/$target/': {
id: '/redirect/$target/'
path: '/'
Expand Down Expand Up @@ -844,7 +827,7 @@ declare module '@tanstack/react-router' {
path: '/foo/$bar/$qux'
fullPath: '/foo/$bar/$qux'
preLoaderRoute: typeof FooBarQuxHereRouteImport
parentRoute: typeof FooBarQuxRoute
parentRoute: typeof rootRouteImport
}
'/foo/$bar/$qux/_here/': {
id: '/foo/$bar/$qux/_here/'
Expand Down Expand Up @@ -988,18 +971,6 @@ const FooBarQuxHereRouteWithChildren = FooBarQuxHereRoute._addFileChildren(
FooBarQuxHereRouteChildren,
)

interface FooBarQuxRouteChildren {
FooBarQuxHereRoute: typeof FooBarQuxHereRouteWithChildren
}

const FooBarQuxRouteChildren: FooBarQuxRouteChildren = {
FooBarQuxHereRoute: FooBarQuxHereRouteWithChildren,
}

const FooBarQuxRouteWithChildren = FooBarQuxRoute._addFileChildren(
FooBarQuxRouteChildren,
)

const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
NotFoundRouteRoute: NotFoundRouteRouteWithChildren,
Expand All @@ -1020,7 +991,7 @@ const rootRouteChildren: RootRouteChildren = {
MultiCookieRedirectIndexRoute: MultiCookieRedirectIndexRoute,
RedirectIndexRoute: RedirectIndexRoute,
PostsPostIdDeepRoute: PostsPostIdDeepRoute,
FooBarQuxRoute: FooBarQuxRouteWithChildren,
FooBarQuxHereRoute: FooBarQuxHereRouteWithChildren,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
Expand Down
Loading
Loading