import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { COMMAND_IDS } from '../commands/command-ids'; import { APP_LOCALES } from '../i18n/locale'; import { SIGNATURE_COPY } from './signature-copy'; function leafPaths(value: unknown, prefix = ''): string[] { if (typeof value === 'string') { return [prefix]; } if (value !== null && typeof value === 'object') { return Object.keys(value).flatMap((key) => { const next = prefix.length > 0 ? `${prefix}.${key}` : key; return leafPaths((value as Record)[key], next); }); } return [prefix]; } function collectStrings(value: unknown): string[] { if (typeof value === 'string') { return [value]; } if (value !== null && typeof value === 'object') { return Object.values(value).flatMap((entry) => collectStrings(entry)); } return []; } describe('SIGNATURE_COPY', () => { it('exposes the same key structure in both locales', () => { const [first, ...rest] = APP_LOCALES.map((locale) => leafPaths(SIGNATURE_COPY[locale])); for (const keys of rest) { expect(keys).toEqual(first); } }); it('keeps every string non-empty', () => { for (const locale of APP_LOCALES) { for (const value of collectStrings(SIGNATURE_COPY[locale])) { expect(value.trim().length).toBeGreaterThan(0); } } }); it('does not import from src/app/shared', () => { const source = readFileSync( join(process.cwd(), 'src/app/core/content/signature-copy.ts'), 'utf8', ); expect(source).not.toMatch(/from ['"][^'"]*\/shared\//); }); it('describes every CommandId in both locales', () => { for (const locale of APP_LOCALES) { const descriptions = SIGNATURE_COPY[locale].palette.commandDescriptions; expect(Object.keys(descriptions).sort()).toEqual([...COMMAND_IDS].sort()); for (const id of COMMAND_IDS) { expect(descriptions[id].trim().length).toBeGreaterThan(0); } } }); });