Files
supabase/apps/docs/features/IaNav/navTree.test.ts
Danny White 30a1b38da0 feat(studio): rename temporary access to database token access (#54282)
## Problem

The database access preview still uses “Temporary access” across its
settings and member rules.

## Solution

Use “Database token access” for the feature and “Member access” for
member rules. Update the preview, settings, dialogs, feedback, member
status messages and docs together. Move the guide to
`/guides/platform/token-access`, permanently redirect the old URL, and
preserve existing section anchors.

## Review instructions

1. Open [the Studio
preview](https://studio-staging-git-dnywh-database-token-access-naming-supabase.vercel.app),
then Feature previews and find **Database token access**. Enable the
preview for a supported project, then open [Database
Settings](https://studio-staging-git-dnywh-database-token-access-naming-supabase.vercel.app/project/_/database/settings).
2. Check the **Database token access** heading, **Allow token access**
switch and **Member access** table. Open **Add rule** and an existing
rule to check the sheet titles. Open a rule’s delete confirmation and
cancel it.
3. With an assigned role, check the access status above the member
table. As a member without management permission, check the access
notice uses the same feature name.
4. Open the [database token access guide in the docs
preview](https://docs-git-dnywh-database-token-access-naming-supabase.vercel.app/docs/guides/platform/token-access).
Check the guide and navigation use the new name, the dashboard
instructions match Studio, and the existing section links from the
member guide still work. Open `/docs/guides/platform/temporary-access`
and its `.md` variant to check they permanently redirect to the new
URLs.

| Before | After |
| --- | --- |
| <img width="726" height="367" alt="CleanShot 2026-11-30 at 16 06 00"
src="https://github.com/user-attachments/assets/be351f0c-d578-4289-8785-5c4e69a254a7"
/> | <img width="729" height="374" alt="CleanShot 2026-11-30 at 16 05
38"
src="https://github.com/user-attachments/assets/f02b470d-ef1a-4b6c-bdbb-20fe10b847c6"
/> |
2026-12-02 00:03:43 +00:00

76 lines
2.6 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { buildNavTree, type NavTreeNode } from './navTree'
import * as option1NavItems from './option1.constants'
import * as currentNavItems from '@/components/Navigation/NavigationMenu/NavigationMenu.constants'
describe('buildNavTree', () => {
it('uses the top nav as the first level', () => {
const tree = buildNavTree('today', currentNavItems)
expect(tree.name).toBe('today')
expect(tree.root.label).toBe('Supabase Docs')
expect(tree.root.children.map((node) => node.label)).toEqual([
'Start',
'Products',
'Build',
'Manage',
'Reference',
'Resources',
])
expect(tree.root.children[0].route).toBe('/guides/getting-started')
})
it('places SSL enforcement under Manage today', () => {
const tree = buildNavTree('today', currentNavItems)
expect(pathsTo(tree.root, '/guides/platform/ssl-enforcement')).toEqual([
['Manage', 'Platform Management', 'Platform Configuration', 'SSL Enforcement'],
])
})
it('expands a top nav entry that names a sidebar group into that group only', () => {
const tree = buildNavTree('option-1', option1NavItems)
expect(pathsTo(tree.root, '/guides/platform/ssl-enforcement')).toEqual([
['Run and manage', 'Network, SSL and domains'],
['Run and manage', 'Network, SSL and domains', 'SSL enforcement'],
])
})
it.each([
['today', currentNavItems],
['option-1', option1NavItems],
])('is five levels deep in %s, counting the top nav as level one', (name, menus) => {
const tree = buildNavTree(name, menus)
expect(Math.max(...tree.root.children.map((node) => depth(node)))).toBe(5)
})
it('contains the source pages the evals start from today', () => {
const tree = buildNavTree('today', currentNavItems)
const routes = [
'/guides/getting-started/api-keys',
'/guides/deployment/going-into-prod',
'/guides/database/postgres/postgres-log-config',
'/guides/deployment/branching/integrations',
'/guides/platform/token-access',
'/guides/local-development/testing/overview',
]
expect(routes.filter((route) => pathsTo(tree.root, route).length === 0)).toEqual([])
})
})
function depth(node: NavTreeNode): number {
return 1 + Math.max(0, ...(node.children ?? []).map((child) => depth(child)))
}
function pathsTo(node: NavTreeNode, route: string, path: string[] = []): string[][] {
const here = node.route === route ? [path] : []
return [
...here,
...(node.children ?? []).flatMap((child) => pathsTo(child, route, [...path, child.label])),
]
}