Files
supabase/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.levels.nav-check.test.ts
T
anthony lio 02e61b9cda fix(docs): layout v2 reference fixtures (#54233)
## Problem

- after #53761 the option-1 sidebar reference list has no row for
server, middleware and tanstack db
- list marks no row as current on a library page, for example on
`/reference/javascript/select`
- management api intro shows its endpoint list in the right rail and its
toc in an extra column inside the content

## Solution

- adds the server, middleware and tanstack db rows with the new and
experimental badges of the current nav
- fixes the reference list so it marks the library of the current page
- changes the management api to open as its own sidebar level with the
endpoint list on the left
- moves the toc, the links and the feedback of the management api intro
into the right rail + removes the rail on endpoint pages
- adds the "on this page" menu to the management api intro below `lg`
- adds the reference library column to the option-1 nav size allowlist
because it is a list of peer libraries

| before | after |
| -------|------|
| <img width="2880" height="1800" alt="image"
src="https://github.com/user-attachments/assets/3a216c0b-31c1-4629-82a1-0590c7e639ae"
/> | <img width="2880" height="1800" alt="image"
src="https://github.com/user-attachments/assets/c53afc0e-8d15-45d7-9dc8-320443761ed2"
/> |

| before | after |
| -------|------|
| <img width="2880" height="1800" alt="image"
src="https://github.com/user-attachments/assets/5dc79bb9-b160-44e6-a3c5-39182fb71d4f"
/> | <img width="2880" height="1800" alt="image"
src="https://github.com/user-attachments/assets/9e0dff3c-5261-4c70-b1f1-f74314231a08"
/> |

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions

1. open
[/docs/reference?docs-ia-mvp-v1=option-1](https://docs-ivb0vb1qq-supabase.vercel.app/docs/reference?docs-ia-mvp-v1=option-1)
and do all steps in the same tab because the flag override lasts only
for the tab
2. make sure that the reference list shows server and middleware
3. open
[/docs/reference/javascript/select](https://docs-ivb0vb1qq-supabase.vercel.app/docs/reference/javascript/select)
and make sure that the sidebar marks only the javascript row
4. click `Management API` in the sidebar and make sure that the sidebar
shows `< Management API` with the endpoint list
5. make sure that the right rail shows the toc, the additional links and
the feedback buttons
6. open
[/docs/guides/database/overview](https://docs-ivb0vb1qq-supabase.vercel.app/docs/guides/database/overview)
and make sure that the sidebar and the right rail did not change

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-30 20:19:04 +00:00

99 lines
3.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import type { GlobalMenuItems } from '../Navigation.types'
import * as currentNavItems from './NavigationMenu.constants'
import * as option1NavItems from '@/features/IaNav/option1.constants'
const MAX_ITEMS = 9
// key is the group's id when it has one, so copy edits don't break allowlist entries
type Level = { key: string; size: number }
type NavNode = { id?: string; name?: string; enabled?: boolean; items?: NavNode[] }
// count only what renders: disabled items and their subtrees are hidden
const isRendered = (item: { enabled?: boolean }) => item.enabled !== false
function sidebarLevels(path: string, allItems: NavNode[], id?: string): Level[] {
const items = allItems.filter((item) => isRendered(item))
return [
{ key: id ?? path, size: items.length },
...items.flatMap((item) =>
item.items?.length ? sidebarLevels(`${path} > ${item.name}`, item.items, item.id) : []
),
]
}
function topNavLevels(allSections: GlobalMenuItems): Level[] {
const menu = allSections.filter(([item]) => isRendered(item))
return [
{ key: 'Top nav', size: menu.length },
...menu.flatMap(([item]) =>
(item.menuItems ?? []).map((column, index) => ({
key: `Top nav > ${item.label} > column ${index + 1}`,
size: column.filter((columnItem) => isRendered(columnItem)).length,
}))
),
]
}
function oversizedLevels(navItems: Record<string, unknown>): string[] {
// A sidebar shared by several URL prefixes is exported under each name.
const sidebars = new Set(
Object.values(navItems).filter(
(value): value is { title: string; items: NavNode[] } =>
typeof value === 'object' &&
value !== null &&
'title' in value &&
Array.isArray((value as { items?: unknown }).items)
)
)
return [
...topNavLevels(navItems.GLOBAL_MENU_ITEMS as GlobalMenuItems),
...[...sidebars].flatMap((sidebar) => sidebarLevels(sidebar.title, sidebar.items)),
]
.filter((level) => level.size > MAX_ITEMS)
.map((level) => level.key)
}
// Levels allowed 10 or more items, such as a list of peers like quickstarts or providers.
const ALLOWLIST = [
'Auth',
'Auth > Flows (How-tos)',
'Auth > Flows (How-tos) > Social Sign-in (OAuth)',
'Database',
'Database > Extensions',
'Database > Foreign Data Wrappers > Sources',
'Database > Working with your database (intermediate)',
'Edge Functions',
'Edge Functions > Examples',
'Edge Functions > Third-Party Tools',
'Local Dev / CLI > Guides',
'Platform > Billing > Manage your usage',
'Platform > Platform Configuration',
'Self-Hosting',
'Self-Hosting > How-to Guides',
'Start with Supabase > Framework Quickstarts',
'Start with Supabase > Web app demos',
'Storage > File Buckets',
]
const OPTION_1_ALLOWLIST = [
'auth-social-sign-in',
'fdw-apps-and-apis',
'fdw-databases-and-warehouses',
'start-javascript-and-typescript',
'start-web-app-tutorials',
'Top nav > Reference > column 1',
]
describe('navigation level size', () => {
it.each([
["today's navigation", currentNavItems, ALLOWLIST],
['Option 1', option1NavItems, OPTION_1_ALLOWLIST],
])('%s has no level with 10 or more items outside the allowlist', (_, navItems, allowlist) => {
expect(oversizedLevels(navItems).sort()).toEqual([...allowlist].sort())
})
})