Treat review-page value modals as unchanged when field blocks match the open snapshot so close does not ask to discard a view-only visit.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
adilallo
2026-08-21 16:41:03 -06:00
co-authored by Cursor
parent 440b6a9657
commit e416f37940
2 changed files with 87 additions and 4 deletions
+80
View File
@@ -438,6 +438,86 @@ describe("FinalReviewScreen — chip detail modal", () => {
).toBeInTheDocument();
});
it("closes a values chip without discard when nothing changed", async () => {
render(
<FinalReviewWithStateProbe
onState={() => {
/* noop */
}}
initial={{
selectedCoreValueIds: ["1"],
coreValuesChipsSnapshot: [
{ id: "1", label: "Accessibility", state: "selected" },
],
coreValueDetailsByChipId: {
"1": {
meaning: "Everyone can participate.",
signals: "Captions and ramps.",
},
},
customMethodCardFieldBlocksById: {
"1": [
{
kind: "text",
id: "facet-meaning",
blockTitle: "What this value means",
placeholderText: "Everyone can participate.",
},
{
kind: "text",
id: "facet-signals",
blockTitle: "Signals",
placeholderText: "Captions and ramps.",
},
],
},
}}
/>,
);
fireEvent.click(
await screen.findByRole("button", { name: "Accessibility" }),
);
const valuesDialog = await screen.findByRole("dialog");
expect(within(valuesDialog).getAllByRole("textbox").length).toBeGreaterThan(
0,
);
fireEvent.keyDown(document, { key: "Escape" });
await waitFor(() => {
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
});
expect(
screen.queryByRole("button", { name: "Keep editing" }),
).not.toBeInTheDocument();
});
it("closes a method chip without discard when nothing changed", async () => {
render(
<FinalReviewWithStateProbe
onState={() => {
/* noop */
}}
initial={{
title: "Oak Park Commons",
selectedCommunicationMethodIds: ["signal"],
}}
/>,
);
fireEvent.click(await screen.findByRole("button", { name: "Signal" }));
const methodDialog = await screen.findByRole("dialog");
expect(within(methodDialog).getAllByRole("textbox").length).toBeGreaterThan(
0,
);
fireEvent.keyDown(document, { key: "Escape" });
await waitFor(() => {
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
});
expect(
screen.queryByRole("button", { name: "Keep editing" }),
).not.toBeInTheDocument();
});
});
/**