fix: follow-ups of the lot-v018 stack reviews #482
1 changed files with 32 additions and 0 deletions
|
|
@ -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)",
|
||||
|
|
|
|||
Loading…
Reference in a new issue