Simpl-Resultat/src/components/import/RootFilesWarning.locales.test.tsx
le king fu 7d3a616312 feat(import): warn about the CSV files placed directly in the import folder
scan_import_folder now returns ImportFolderScan { sources, root_files }:
the CSV/TXT files at the root, which no source reads, are named in a
warning on the Import page (above the source list, or under the "no
source" empty state). One action sets sources and root files, RESET keeps
both. Names stay on screen, never in the Journal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 20:59:20 -04:00

55 lines
2.1 KiB
TypeScript

// RootFilesWarning (#427) through the REAL locales: the plural forms
// (`message_one`/`message_other`, `more_one`/`more_other`) and the quotes
// around the folder name only exist in fr.json and en.json, which the marked
// `t` of RootFilesWarning.test.tsx never reads.
import { describe, it, expect, afterAll } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
import i18n from "../../i18n/config";
import RootFilesWarning from "./RootFilesWarning";
const text = (names: string[]) =>
renderToStaticMarkup(<RootFilesWarning names={names} folderName="Relevés" />)
.replace(/<[^>]+>/g, "");
const SEVEN = ["1.csv", "2.csv", "3.csv", "4.csv", "5.csv", "6.csv", "7.csv"];
afterAll(async () => {
await i18n.changeLanguage("fr");
});
describe("RootFilesWarning — French (#427)", () => {
it("singular", async () => {
await i18n.changeLanguage("fr");
expect(text(["a.csv"])).toBe(
"1 fichier est posé directement dans « Relevés » et est ignoré : a.csv. Déplacez-le dans un sous-dossier par compte.",
);
});
it("plural, five names then « et 2 autres »", async () => {
await i18n.changeLanguage("fr");
expect(text(SEVEN)).toBe(
"7 fichiers sont posés directement dans « Relevés » et sont ignorés : 1.csv, 2.csv, 3.csv, 4.csv, 5.csv et 2 autres. Déplacez-les dans un sous-dossier par compte.",
);
});
it("one more: « et 1 autre »", async () => {
await i18n.changeLanguage("fr");
expect(text(SEVEN.slice(0, 6))).toContain("5.csv et 1 autre.");
});
});
describe("RootFilesWarning — English (#427)", () => {
it("singular", async () => {
await i18n.changeLanguage("en");
expect(text(["a.csv"])).toBe(
"1 file sits directly in “Relevés” and is ignored: a.csv. Move it into a subfolder per account.",
);
});
it("plural, five names then “and 2 more”", async () => {
await i18n.changeLanguage("en");
expect(text(SEVEN)).toBe(
"7 files sit directly in “Relevés” and are ignored: 1.csv, 2.csv, 3.csv, 4.csv, 5.csv and 2 more. Move them into a subfolder per account.",
);
});
});