test(import): pin the read-only source name of the configuration panel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-10-13 21:06:07 -04:00
parent ed3a4bb9a0
commit 00b4319c44

View file

@ -0,0 +1,44 @@
// SourceConfigPanel — the source name is read-only, the subfolder's (#426).
// No jsdom: rendered to static markup with the shared marked `t`.
import { describe, it, expect, vi } from "vitest";
import { renderToStaticMarkup } from "react-dom/server";
vi.mock("react-i18next", async () => (await import("../../test/i18nMock")).i18nMock());
import SourceConfigPanel from "./SourceConfigPanel";
import { initialWizardState } from "../../hooks/useImportWizard";
const noop = () => undefined;
const render = () =>
renderToStaticMarkup(
<SourceConfigPanel
source={{ folder_name: "Desjardins", folder_path: "/releves/Desjardins", files: [] }}
config={{ ...initialWizardState.sourceConfig, name: "Mon compte chèques" }}
selectedFiles={[]}
headers={[]}
configTemplates={[]}
onConfigChange={noop}
onFileToggle={noop}
onSelectAllFiles={noop}
onAutoDetect={noop}
onSaveAsTemplate={noop}
onApplyTemplate={noop}
onUpdateTemplate={noop}
onDeleteTemplate={noop}
selectedTemplateId={null}
/>,
);
describe("SourceConfigPanel — source name (#426)", () => {
it("shows the subfolder name with its hint", () => {
const html = render();
expect(html).toContain("t(import.config.sourceNameHint)");
expect(html).toMatch(/<p[^>]*>Desjardins<\/p>/);
});
it("has no field holding the configured name", () => {
const html = render();
expect(html).not.toContain("Mon compte chèques");
});
});