|
| 1 | +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. |
| 2 | +// |
| 3 | +// Tombstone for four dead `apps.setup.navigation` translation keys (#6660). |
| 4 | +// |
| 5 | +// --------------------------------------------------------------------------- |
| 6 | +// Why a hard-coded id list instead of the general reverse direction |
| 7 | +// --------------------------------------------------------------------------- |
| 8 | +// `app-nav-translation-parity.test.ts` asserts the reverse direction for Studio |
| 9 | +// ("a translation for an id the app no longer declares is dead weight that |
| 10 | +// reads as coverage") by walking `STUDIO_APP.navigation`. Setup cannot be |
| 11 | +// walked that way: it is a shell of empty group anchors (ADR-0029 D7) and every |
| 12 | +// entry arrives at RUNTIME, so this file has nothing to diff against — which is |
| 13 | +// exactly why that file's header says a Setup case there "has to boot |
| 14 | +// something", and why `pnpm check:app-nav-i18n` (which does boot) still refuses |
| 15 | +// the reverse direction: from one composition a dead key and a |
| 16 | +// conditionally-contributed key are indistinguishable (`nav_sso_providers` is |
| 17 | +// contributed only when an external IdP is wired). Making that gate |
| 18 | +// union-aware is tracked as #6659. |
| 19 | +// |
| 20 | +// This file makes no general claim. It pins exactly four ids that were checked |
| 21 | +// ONE BY ONE against a repo-wide grep — `id: '<key>'` returned zero hits for |
| 22 | +// each of them on `61282f906`, against a control probe (`nav_webhooks`) that |
| 23 | +// returned five — and each of which has a recorded reason to be gone: |
| 24 | +// |
| 25 | +// nav_approval_processes the process engine was retired in favour of the |
| 26 | +// approval flow node (#1408, ADR-0019 P4/P5) |
| 27 | +// nav_verifications `sys_verification` omits `list` from `apiMethods` |
| 28 | +// nav_device_codes `sys_device_code` likewise — both are sensitive, |
| 29 | +// ephemeral secrets, so a browse entry could only |
| 30 | +// ever render "failed to load" (#2266, and the |
| 31 | +// comment that records it in |
| 32 | +// `setup-nav.contributions.ts`) |
| 33 | +// nav_metadata moved to Studio as `nav_metadata_directory` when |
| 34 | +// the Studio app was split out (482eb67cc) |
| 35 | +// |
| 36 | +// --------------------------------------------------------------------------- |
| 37 | +// What to do when this test goes red |
| 38 | +// --------------------------------------------------------------------------- |
| 39 | +// It goes red on exactly one event: one of the four ids comes back. That is not |
| 40 | +// automatically wrong — re-adding `nav_verifications` or `nav_device_codes` is a |
| 41 | +// deliberate security decision (it requires enabling `list` on the object |
| 42 | +// first), and `nav_approval_processes` could return with a new owner. The rule |
| 43 | +// is the ORDER: the declaring nav item comes back first, the label second, and |
| 44 | +// the id's line is deleted from `DEAD_SETUP_NAV_IDS` in that same commit. A |
| 45 | +// label with no declaring nav item is what this tombstone exists to refuse. |
| 46 | + |
| 47 | +import { describe, it, expect } from 'vitest'; |
| 48 | +import { SETUP_NAV_CONTRIBUTIONS } from '../setup-nav.contributions.js'; |
| 49 | +import { en } from './en.js'; |
| 50 | +import { zhCN } from './zh-CN.js'; |
| 51 | +import { jaJP } from './ja-JP.js'; |
| 52 | +import { esES } from './es-ES.js'; |
| 53 | + |
| 54 | +const LOCALES = { en, 'zh-CN': zhCN, 'ja-JP': jaJP, 'es-ES': esES } as const; |
| 55 | + |
| 56 | +/** Removed Setup nav ids. Delete a line here only together with its nav item. */ |
| 57 | +const DEAD_SETUP_NAV_IDS = [ |
| 58 | + 'nav_approval_processes', |
| 59 | + 'nav_device_codes', |
| 60 | + 'nav_metadata', |
| 61 | + 'nav_verifications', |
| 62 | +] as const; |
| 63 | + |
| 64 | +describe('removed Setup nav ids stay removed (#6660)', () => { |
| 65 | + for (const [locale, data] of Object.entries(LOCALES)) { |
| 66 | + it(`${locale} carries no label for a removed Setup nav id`, () => { |
| 67 | + const nav = (data.apps?.setup?.navigation ?? {}) as Record<string, { label?: string }>; |
| 68 | + expect( |
| 69 | + DEAD_SETUP_NAV_IDS.filter((id) => id in nav), |
| 70 | + 'apps.setup.navigation keys with no declaring nav item — see this file header', |
| 71 | + ).toEqual([]); |
| 72 | + }); |
| 73 | + } |
| 74 | + |
| 75 | + // The other half of the same fact, on the one Setup contributor this package |
| 76 | + // owns. Keeping it here means a re-added nav item cannot quietly restore a |
| 77 | + // label without this ledger being read: both assertions go red together. |
| 78 | + it('SETUP_NAV_CONTRIBUTIONS declares none of them', () => { |
| 79 | + const declared = new Set<string>(); |
| 80 | + const walk = (items: unknown[]): void => { |
| 81 | + for (const raw of items) { |
| 82 | + const item = raw as { id?: string; children?: unknown[] }; |
| 83 | + if (item?.id) declared.add(item.id); |
| 84 | + if (Array.isArray(item?.children)) walk(item.children); |
| 85 | + } |
| 86 | + }; |
| 87 | + for (const contribution of SETUP_NAV_CONTRIBUTIONS) walk(contribution.items); |
| 88 | + |
| 89 | + // Control: the walk really reads this array, so an empty `declared` cannot |
| 90 | + // pass the assertion below by vacuity. |
| 91 | + expect(declared.has('nav_users'), 'nav_users is contributed here').toBe(true); |
| 92 | + expect(DEAD_SETUP_NAV_IDS.filter((id) => declared.has(id))).toEqual([]); |
| 93 | + }); |
| 94 | +}); |
0 commit comments