Show our own save-email error, and open review cards as the deck row view.

A bad address was stopped by the browser bubble before the designed line could appear. Final review opened every part of a method card at once instead of the three-row policy the decks use.
This commit is contained in:
adilallo committed 2026-11-11 10:47:40 -07:00
1 parent 0efc907633
commit 7336cba6f5
13 files changed
+274 -685

No files matched your search

+61 -47
View File
@@ -19,6 +19,10 @@ function catalogChipName(label: string) {
);
}
function openMethodStep(dialog: HTMLElement, name: string) {
fireEvent.click(within(dialog).getByRole("button", { name }));
}
async function confirmDiscardCustomizeEdits() {
fireEvent.click(
await screen.findByRole("button", { name: "Discard" }),
@@ -312,12 +316,18 @@ describe("FinalReviewScreen — chip detail modal", () => {
await screen.findByRole("button", { name: catalogChipName("Video meetings") }),
);
const dialog = await screen.findByRole("dialog");
expect(within(dialog).getAllByRole("textbox")).toHaveLength(3);
expect(within(dialog).queryAllByRole("textbox")).toHaveLength(0);
expect(
within(dialog).queryByText("No custom fields yet."),
).not.toBeInTheDocument();
expect(
within(dialog).getByText(/core principle/i),
within(dialog).getByRole("button", { name: "Core principle and scope" }),
).toBeInTheDocument();
expect(
within(dialog).getByRole("button", { name: "How it works" }),
).toBeInTheDocument();
expect(
within(dialog).getByRole("button", { name: "Norms" }),
).toBeInTheDocument();
});
@@ -571,26 +581,33 @@ describe("FinalReviewScreen — chip detail modal", () => {
expect(screen.getByPlaceholderText("Policy description")).toHaveValue("");
});
it("opens method chip modal editable, with Save disabled until a field changes", async () => {
it("opens a method chip as the deck's routing card, with Save off until a part changes", async () => {
render(<FinalReviewWithCustomizeSelections />);
fireEvent.click(await screen.findByRole("button", { name: catalogChipName("Signal") }));
const dialog = await screen.findByRole("dialog");
const saveButton = within(dialog).getByRole("button", { name: "Save" });
expect(saveButton).toBeDisabled();
expect(within(dialog).queryAllByRole("textbox")).toHaveLength(0);
expect(
within(dialog).getByRole("button", { name: "Core principle and scope" }),
).toBeInTheDocument();
expect(within(dialog).getByRole("button", { name: "Save" })).toBeDisabled();
openMethodStep(dialog, "Core principle and scope");
const principleField = within(dialog).getByRole("textbox", {
name: /core principle/i,
});
expect(principleField).not.toBeDisabled();
expect(principleField).toHaveValue("");
fireEvent.change(principleField, { target: { value: "Edited principle" } });
fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
await waitFor(() => {
expect(
within(dialog).getByRole("button", { name: "Save" }),
).not.toBeDisabled();
within(dialog).getByRole("button", { name: "Core principle and scope" }),
).toBeInTheDocument();
});
expect(within(dialog).getByRole("button", { name: "Save" })).toBeEnabled();
});
it("opens a core-values chip with the matching preset meaning/signals", async () => {
@@ -792,9 +809,10 @@ describe("FinalReviewScreen — chip detail modal", () => {
fireEvent.click(await screen.findByRole("button", { name: catalogChipName("Signal") }));
const methodDialog = await screen.findByRole("dialog");
expect(within(methodDialog).getAllByRole("textbox").length).toBeGreaterThan(
0,
);
expect(
within(methodDialog).getByRole("button", { name: "Core principle and scope" }),
).toBeInTheDocument();
expect(within(methodDialog).queryAllByRole("textbox")).toHaveLength(0);
fireEvent.keyDown(document, { key: "Escape" });
await waitFor(() => {
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
@@ -818,7 +836,7 @@ describe("FinalReviewScreen — chip detail modal", () => {
fireEvent.click(await screen.findByRole("button", { name: catalogChipName("Signal") }));
const dialog = await screen.findByRole("dialog");
expect(
within(dialog).getByRole("button", { name: "Remove" }),
within(dialog).getByRole("button", { name: "Deselect" }),
).toBeInTheDocument();
expect(
within(dialog).queryByRole("button", { name: "Back" }),
@@ -845,7 +863,7 @@ describe("FinalReviewScreen — chip detail modal", () => {
fireEvent.click(await screen.findByRole("button", { name: catalogChipName("Signal") }));
const dialog = await screen.findByRole("dialog");
fireEvent.click(within(dialog).getByRole("button", { name: "Remove" }));
fireEvent.click(within(dialog).getByRole("button", { name: "Deselect" }));
await waitFor(() => {
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
});
@@ -855,13 +873,10 @@ describe("FinalReviewScreen — chip detail modal", () => {
});
/**
* Save semantics for {@link FinalReviewChipEditModal}. Mirrors the
* "edits ride along to publish" promise documented in the modal:
*
* 1. Save starts disabled (no edits yet → nothing to persist).
* 2. Editing any field flips Save on; clicking it writes the typed
* `{group}MethodDetailsById[id]` entry into create-flow state.
* 3. Closing without Save discards every typed change.
* Save semantics for {@link FinalReviewChipEditModal}. A method chip opens
* the deck routing card. Save on a part returns to the rows. Save on the
* card writes `{group}MethodDetailsById[id]`. Closing without that card
* Save discards the typed change.
*/
describe("FinalReviewScreen — chip edit modal save semantics", () => {
const baseSelections: CreateFlowState = {
@@ -883,20 +898,18 @@ describe("FinalReviewScreen — chip edit modal save semantics", () => {
fireEvent.click(await screen.findByRole("button", { name: catalogChipName("Signal") }));
const dialog = await screen.findByRole("dialog");
const saveButton = within(dialog).getByRole("button", { name: "Save" });
expect(saveButton).toBeDisabled();
const principleField = within(dialog).getByRole("textbox", {
name: /core principle/i,
});
fireEvent.change(principleField, {
target: { value: "Edited principle" },
});
expect(within(dialog).getByRole("button", { name: "Save" })).toBeDisabled();
openMethodStep(dialog, "Core principle and scope");
fireEvent.change(
within(dialog).getByRole("textbox", { name: /core principle/i }),
{ target: { value: "Edited principle" } },
);
fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
await waitFor(() => {
expect(
within(dialog).getByRole("button", { name: "Save" }),
).not.toBeDisabled();
).toBeEnabled();
});
});
@@ -913,12 +926,13 @@ describe("FinalReviewScreen — chip edit modal save semantics", () => {
fireEvent.click(await screen.findByRole("button", { name: catalogChipName("Signal") }));
const dialog = await screen.findByRole("dialog");
const principleField = within(dialog).getByRole("textbox", {
name: /core principle/i,
});
fireEvent.change(principleField, {
target: { value: "Edited principle" },
});
openMethodStep(dialog, "Core principle and scope");
fireEvent.change(
within(dialog).getByRole("textbox", { name: /core principle/i }),
{ target: { value: "Edited principle" } },
);
fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
expect(latest.communicationMethodDetailsById?.signal?.corePrinciple).toBeUndefined();
fireEvent.click(within(dialog).getByRole("button", { name: "Save" }));
await waitFor(() => {
@@ -941,13 +955,14 @@ describe("FinalReviewScreen — chip edit modal save semantics", () => {
fireEvent.click(await screen.findByRole("button", { name: catalogChipName("Signal") }));
const dialog = await screen.findByRole("dialog");
const principleField = within(dialog).getByRole("textbox", {
name: /core principle/i,
});
fireEvent.change(principleField, {
target: { value: "Should NOT persist" },
});
openMethodStep(dialog, "Core principle and scope");
fireEvent.change(
within(dialog).getByRole("textbox", { name: /core principle/i }),
{ target: { value: "Should NOT persist" } },
);
fireEvent.keyDown(document, { key: "Escape" });
expect(screen.getByRole("dialog")).toBeInTheDocument();
fireEvent.keyDown(document, { key: "Escape" });
await confirmDiscardCustomizeEdits();
await waitFor(() => {
@@ -970,12 +985,11 @@ describe("FinalReviewScreen — chip edit modal save semantics", () => {
fireEvent.click(await screen.findByRole("button", { name: catalogChipName("Signal") }));
const dialog = await screen.findByRole("dialog");
expect(dispatchBeforeUnload()).toBe(false);
const principleField = within(dialog).getByRole("textbox", {
name: /core principle/i,
});
fireEvent.change(principleField, {
target: { value: "Unsaved on tab close" },
});
openMethodStep(dialog, "Core principle and scope");
fireEvent.change(
within(dialog).getByRole("textbox", { name: /core principle/i }),
{ target: { value: "Unsaved on tab close" } },
);
expect(dispatchBeforeUnload()).toBe(true);
});