From ffe6288e4a5f75e2381e2d203786ec2bbbff863a Mon Sep 17 00:00:00 2001 From: le king fu Date: Mon, 19 Oct 2026 21:09:01 -0400 Subject: [PATCH] test(import): the sample folder messages name the folder in both languages (#384) Review 25592, point 3: the page's tests take the marked t and the key guard compares no value, so a translation that lost {{name}} passed the suite. The real locale files, through a real i18next with the app's options, now render folderExists with the folder's name in French and in English, and the two other codes without a leftover placeholder. Co-Authored-By: Claude Opus 5.5 --- src/hooks/useImportWizard.test.ts | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/hooks/useImportWizard.test.ts b/src/hooks/useImportWizard.test.ts index 11f66cc..05f0a3b 100644 --- a/src/hooks/useImportWizard.test.ts +++ b/src/hooks/useImportWizard.test.ts @@ -24,6 +24,9 @@ vi.mock("../services/db", () => { import { readFileSync } from "fs"; import { resolve } from "path"; +import i18next from "i18next"; +import fr from "../i18n/locales/fr.json"; +import en from "../i18n/locales/en.json"; import { wizardReducer, initialWizardState, @@ -271,6 +274,35 @@ describe("sampleFolderError — the refusals of create_sample_import_folders (#3 expect(sampleFolderError("invalid_date")).toEqual({ key: "import.empty.sampleErrors.invalidDate" }); }); + it("the real messages name the folder, in French and in English, as the banner renders them", async () => { + // The tests of the page take the marked `t`, and the key guard (#453) + // compares no value: only the real locale files, through a real i18next + // with the app's options, prove the `{{name}}` of the message. + const i18n = i18next.createInstance(); + await i18n.init({ + resources: { fr: { translation: fr }, en: { translation: en } }, + lng: "fr", + fallbackLng: "en", + interpolation: { escapeValue: false }, + }); + for (const lng of ["fr", "en"]) { + const t = i18n.getFixedT(lng); + for (const name of ["Exemple Desjardins", "Exemple Tangerine"]) { + const error = sampleFolderError(`sample_folder_exists:${name}`)!; + // ImportPage: t(state.error, { ...errorValues, defaultValue: state.error }). + const text = t(error.key, { ...error.values, defaultValue: error.key }); + expect(text, `${lng} ${name}`).toContain(name); + expect(text, `${lng} ${name}`).not.toContain("{{"); + } + for (const code of ["import_folder_missing", "invalid_date"]) { + const error = sampleFolderError(code)!; + const text = t(error.key, { defaultValue: error.key }); + expect(text, `${lng} ${code}`).not.toBe(error.key); + expect(text, `${lng} ${code}`).not.toContain("{{"); + } + } + }); + it("any other message is unknown, so the banner shows it raw", () => { for (const raw of [ "Cannot write Exemple Desjardins/releve-2026-09.csv: Permission denied (os error 13)",