Simpl-Resultat/src/components/import/SourceNameDisplay.test.tsx
le king fu ed3a4bb9a0 fix(import): name a source after its subfolder, read-only
The source name typed during configuration was saved, but the next import
looks the source and its imported files up by the subfolder name, so a
renamed source looked new: format guessed again, every file pre-checked,
and a second source created under the folder name.

The name field becomes a read-only SourceNameDisplay showing the subfolder
name with a hint, and executeImport writes selectedSource.folder_name on
create and update, whatever config.name holds, behind a selectedSource
guard. The import card sentence no longer asks to check the source name.

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

27 lines
1.1 KiB
TypeScript

// SourceNameDisplay (#426). No jsdom: rendered to static markup with the shared
// marked `t`, so the label and hint keys are read as written.
import { describe, it, expect, vi } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
vi.mock("react-i18next", async () => (await import("../../test/i18nMock")).i18nMock());
import SourceNameDisplay from "./SourceNameDisplay";
const render = (folderName: string) =>
renderToStaticMarkup(<SourceNameDisplay folderName={folderName} />);
describe("SourceNameDisplay (#426)", () => {
it("shows the subfolder name, the label and the hint", () => {
const html = render("Desjardins chèques");
expect(html).toContain("Desjardins chèques");
expect(html).toContain("t(import.config.sourceName)");
expect(html).toContain("t(import.config.sourceNameHint)");
});
it("has no input field: the name cannot be edited", () => {
const html = render("Tangerine");
expect(html).not.toContain("<input");
expect(html).not.toContain("<textarea");
expect(html).not.toContain("contenteditable");
});
});