|
| 1 | +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. |
| 2 | +// |
| 3 | +// No two Setup nav entries in one group read the same in any locale. |
| 4 | +// |
| 5 | +// The defect: People & Organization carries `nav_organization` (the active |
| 6 | +// organization's record page) and `nav_organizations` (the organization list, |
| 7 | +// shown where `org-scoping` is mounted). English tells them apart by the |
| 8 | +// plural; zh-CN and ja-JP have no plural, so both read "组织" / "組織" and a |
| 9 | +// multi-organization deployment showed two identical menu entries that open |
| 10 | +// different pages. |
| 11 | +import { describe, it, expect } from 'vitest'; |
| 12 | + |
| 13 | +import { SETUP_NAV_CONTRIBUTIONS } from './setup-nav.contributions.js'; |
| 14 | +import { en } from './translations/en.js'; |
| 15 | +import { zhCN } from './translations/zh-CN.js'; |
| 16 | +import { jaJP } from './translations/ja-JP.js'; |
| 17 | +import { esES } from './translations/es-ES.js'; |
| 18 | + |
| 19 | +const LOCALES = { en, 'zh-CN': zhCN, 'ja-JP': jaJP, 'es-ES': esES } as const; |
| 20 | + |
| 21 | +type NavItem = { id?: string; label?: string }; |
| 22 | + |
| 23 | +describe('Setup nav labels are distinct within a group', () => { |
| 24 | + for (const [locale, bundle] of Object.entries(LOCALES)) { |
| 25 | + const navigation = ((bundle as any).apps?.setup?.navigation ?? {}) as Record<string, { label?: string }>; |
| 26 | + |
| 27 | + for (const contribution of SETUP_NAV_CONTRIBUTIONS) { |
| 28 | + it(`${locale} · ${contribution.group}`, () => { |
| 29 | + const seen = new Map<string, string>(); |
| 30 | + for (const item of (contribution.items ?? []) as NavItem[]) { |
| 31 | + if (!item.id) continue; |
| 32 | + const label = navigation[item.id]?.label ?? item.label; |
| 33 | + if (!label) continue; |
| 34 | + expect( |
| 35 | + seen.get(label), |
| 36 | + `${item.id} and ${seen.get(label)} both read "${label}" in ${locale}`, |
| 37 | + ).toBeUndefined(); |
| 38 | + seen.set(label, item.id); |
| 39 | + } |
| 40 | + }); |
| 41 | + } |
| 42 | + } |
| 43 | +}); |
0 commit comments