fix(i18n): retain historical checklist text for unknown system keys

This commit is contained in:
cesnimda
2026-11-02 22:55:38 +01:00
parent fae2f760cd
commit 4a3da3319e
5 changed files with 125 additions and 5 deletions
@@ -68,6 +68,14 @@ test("localizes system checklist content without changing user-authored tasks",
expect(screen.getByText("Ask Sara for a referral")).toBeInTheDocument();
});
test.each(['en', 'nb'])('preserves unknown historical system task text in %s', async language => {
window.localStorage.setItem('uiLanguage', language);
mockedApi.get.mockResolvedValue({ data: checklist([item({ systemKey: 'retired-system-task', title: 'Reviewed historical task', description: 'Original task details' })]) } as any);
renderChecklist();
expect(await screen.findByText('Reviewed historical task')).toBeInTheDocument();
expect(screen.getByText('Original task details')).toBeInTheDocument();
});
test("renders the checklist grouped by category with progress", async () => {
renderChecklist();
+4 -1
View File
@@ -1,4 +1,5 @@
import { api } from "./api";
import { translations } from "./i18n/translations";
// Mirrors WorkspaceOverviewDto. Read-only aggregate — the workspace owns no data.
export type WorkspaceCv = {
@@ -93,7 +94,9 @@ export const WORKSPACE_SECTIONS: { key: WorkspaceSectionKey; label: string }[] =
export function checklistSystemTranslationToken(systemKey?: string | null): string | null {
if (!systemKey || systemKey.startsWith("learning:")) return null;
return systemKey.replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase());
const token = systemKey.replace(/-([a-z])/g, (_, letter: string) => letter.toUpperCase());
return Object.hasOwn(translations.en, `checklistItem_${token}`)
&& Object.hasOwn(translations.en, `checklistItem_${token}Description`) ? token : null;
}
const LEGACY_WORKSPACE_SECTIONS: Record<string, WorkspaceSectionKey> = {
@@ -0,0 +1,11 @@
import { checklistSystemTranslationToken } from './applicationWorkspace';
test.each(['retired-system-task', 'constructor', '__proto__'])('does not manufacture translation keys for %s', key => {
expect(checklistSystemTranslationToken(key)).toBeNull();
});
test('retains the known system translation and learning/custom boundaries', () => {
expect(checklistSystemTranslationToken('prepare-cv')).toBe('prepareCv');
expect(checklistSystemTranslationToken('learning:prepare-cv')).toBeNull();
expect(checklistSystemTranslationToken(null)).toBeNull();
});