fix(ui): render each policy template parameter once

A template with no LLM enrichment rendered every parameter field twice: the
shared list already covers them, because nonEnrichmentParams is the full
parameter list when there is no enrichment, and a second no-enrichment branch
mapped the same list again.

Predates the shadcn migration and was carried forward by it. The test now
asserts exactly one field per parameter, and fails if the duplicate branch
comes back.
This commit is contained in:
Yuneng Jiang 2026-07-23 23:30:18 -07:00
parent 68bba5ac0d
commit 64f6f45c92
No known key found for this signature in database
2 changed files with 9 additions and 9 deletions

View file

@ -75,13 +75,15 @@ describe("TemplateParameterModal", () => {
expect(screen.getByText("Configure competitor blocking for your brand")).toBeInTheDocument();
});
it("renders a labelled field per template parameter and marks the required ones", async () => {
it("renders exactly one labelled field per template parameter", async () => {
renderModal();
expect((await screen.findAllByText("Organization Name")).length).toBeGreaterThan(0);
expect(screen.getAllByText("Note").length).toBeGreaterThan(0);
expect(screen.getAllByPlaceholderText("e.g. Contoso").length).toBeGreaterThan(0);
expect(screen.getAllByPlaceholderText("optional note").length).toBeGreaterThan(0);
// Exactly one: a plain template used to render every parameter twice, once from
// the shared list and again from a duplicate no-enrichment branch.
expect(await screen.findByText("Organization Name")).toBeInTheDocument();
expect(screen.getByText("Note")).toBeInTheDocument();
expect(screen.getAllByPlaceholderText("e.g. Contoso")).toHaveLength(1);
expect(screen.getAllByPlaceholderText("optional note")).toHaveLength(1);
});
it("keeps Continue disabled until every required parameter is filled", async () => {
@ -91,7 +93,7 @@ describe("TemplateParameterModal", () => {
await screen.findByText("Basic Redaction");
expect(screen.getByRole("button", { name: "Continue" })).toBeDisabled();
await user.type(screen.getAllByPlaceholderText("e.g. Contoso")[0], "Contoso");
await user.type(screen.getByPlaceholderText("e.g. Contoso"), "Contoso");
expect(screen.getByRole("button", { name: "Continue" })).not.toBeDisabled();
});
@ -102,7 +104,7 @@ describe("TemplateParameterModal", () => {
renderModal({ onConfirm });
await screen.findByText("Basic Redaction");
await user.type(screen.getAllByPlaceholderText("e.g. Contoso")[0], "Contoso");
await user.type(screen.getByPlaceholderText("e.g. Contoso"), "Contoso");
await user.click(screen.getByRole("button", { name: "Continue" }));
expect(onConfirm).toHaveBeenCalledTimes(1);

View file

@ -387,8 +387,6 @@ const TemplateParameterModal: React.FC<TemplateParameterModalProps> = ({
)}
</>
)}
{!hasEnrichment && parameters.map(renderParameterField)}
</div>
<DialogFooter>