mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Gives the `/org/_/…` and `/project/_/…` catch-alls proper TanStack routes and deletes `pages/org/_/[[...routeSlug]].tsx` and `pages/project/_/[[...routeSlug]].tsx` (FE-3106). They show an org or project picker whose links forward the trailing path and the query string (and, for projects, the hash) to the real org or project. Part 12 of the stack. **Depends on:** #53220 **Changed:** - `components/interfaces/Organization/SelectOrganizationPage.tsx`, `components/interfaces/Home/ProjectList/SelectProjectPage.tsx` – the picker bodies. The trailing path and query string come from `useLocation()` (repeated query keys survive): the splat routes nest under the `/org/_` and `/project/_` routes, which render the picker with no `<Outlet>`, so the picker can't rely on its own route's `_splat` - `routes/{org,project}.[_].tsx`, `routes/{org,project}.[_].$.tsx` – render the pickers - `tests/routes/org.[_].$.test.tsx` – covers path and query forwarding **Removed:** - both catch-all pages, and `parseCatchAllRoute` from `compat/next/router.ts` Addresses [FE-3106](https://linear.app/supabase/issue/FE-3106/move-page-bodies-into-route-files-and-delete-pages). ## To test - `/project/_/database/tables?schema=auth#x` – pick a project, lands on `/project/<ref>/database/tables?schema=auth#x` - `/org/_/billing?panel=x` – pick an org, lands on `/org/<slug>/billing?panel=x` - `/org/_` and `/project/_` – pickers link to the org or project home --------- Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
47 lines
1.6 KiB
TypeScript
47 lines
1.6 KiB
TypeScript
import { screen } from '@testing-library/react'
|
|
import type { components } from 'api-types'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { Route as OrgWildcardRoute } from '@/routes/org.[_]'
|
|
import { Route as OrgWildcardSplatRoute } from '@/routes/org.[_].$'
|
|
import { addAPIMock } from '@/tests/lib/msw'
|
|
import { createMockProfileContext } from '@/tests/lib/profile-helpers'
|
|
import { renderRoute } from '@/tests/lib/route-render'
|
|
|
|
type OrganizationResponse = components['schemas']['OrganizationResponse_Output']
|
|
|
|
const organization = {
|
|
id: 1,
|
|
slug: 'acme',
|
|
name: 'Acme',
|
|
plan: { id: 'free', name: 'Free' },
|
|
} as OrganizationResponse
|
|
|
|
describe('/org/_', () => {
|
|
it('links each organization to the requested sub-page, keeping the query string', async () => {
|
|
addAPIMock({ method: 'get', path: '/platform/organizations', response: [organization] })
|
|
|
|
await renderRoute(OrgWildcardSplatRoute, {
|
|
routeId: '/org/_/$',
|
|
url: '/org/_/billing/invoices?panel=open&tab=a&tab=b',
|
|
profileContext: createMockProfileContext(),
|
|
})
|
|
|
|
const link = await screen.findByRole('link', { name: /Acme/ })
|
|
expect(link).toHaveAttribute('href', '/org/acme/billing/invoices?panel=open&tab=a&tab=b')
|
|
})
|
|
|
|
it('links to the organization home without a trailing path', async () => {
|
|
addAPIMock({ method: 'get', path: '/platform/organizations', response: [organization] })
|
|
|
|
await renderRoute(OrgWildcardRoute, {
|
|
routeId: '/org/_',
|
|
url: '/org/_',
|
|
profileContext: createMockProfileContext(),
|
|
})
|
|
|
|
const link = await screen.findByRole('link', { name: /Acme/ })
|
|
expect(link).toHaveAttribute('href', '/org/acme')
|
|
})
|
|
})
|