Files
Portfolio/src/app/core/content/signature-copy.spec.ts
Antonio Ledebuhr 46c86447d1 integration: add route metadata, JSON-LD and harden the public shell
Ship prerendered SEO, crawl files and palette/map a11y so every locale route is indexable, honest and keyboard-usable without inventing claims.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 18:28:22 +02:00

71 lines
2.0 KiB
TypeScript

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<string, unknown>)[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);
}
}
});
});