Show a footer Remove on selected create-flow modules so removal is not kebab-only.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -27,6 +27,9 @@ describe("ConflictManagementScreen", () => {
|
||||
for (const field of fields) {
|
||||
expect(field).toBeEnabled();
|
||||
}
|
||||
expect(
|
||||
within(dialog).queryByRole("button", { name: "Remove" }),
|
||||
).not.toBeInTheDocument();
|
||||
fireEvent.click(
|
||||
within(dialog).getByRole("button", { name: "More options" }),
|
||||
);
|
||||
|
||||
@@ -26,6 +26,9 @@ describe("CoreValuesSelectScreen", () => {
|
||||
expect(
|
||||
within(dialog).getByRole("button", { name: "Add Value" }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
within(dialog).queryByRole("button", { name: "Remove" }),
|
||||
).not.toBeInTheDocument();
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "More options" }));
|
||||
expect(
|
||||
screen.getByRole("menuitem", { name: "Customize" }),
|
||||
@@ -124,6 +127,9 @@ describe("CoreValuesSelectScreen", () => {
|
||||
});
|
||||
fireEvent.click(screen.getByText("Accessibility"));
|
||||
const editing = await screen.findByRole("dialog");
|
||||
expect(
|
||||
within(editing).getByRole("button", { name: "Remove" }),
|
||||
).toBeInTheDocument();
|
||||
fireEvent.click(
|
||||
within(editing).getByRole("button", { name: "More options" }),
|
||||
);
|
||||
|
||||
@@ -169,6 +169,41 @@ describe("Create", () => {
|
||||
expect(screen.getByText("Custom Footer")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders a danger Remove in the left footer when showRemoveButton is true", () => {
|
||||
const onRemove = vi.fn();
|
||||
renderWithProviders(
|
||||
<Create
|
||||
{...defaultProps}
|
||||
showBackButton={false}
|
||||
showRemoveButton
|
||||
onRemove={onRemove}
|
||||
showNextButton
|
||||
nextButtonText="Save"
|
||||
/>,
|
||||
);
|
||||
const removeButton = screen.getByRole("button", { name: "Remove" });
|
||||
expect(removeButton).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Back" })).not.toBeInTheDocument();
|
||||
fireEvent.click(removeButton);
|
||||
expect(onRemove).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("prefers Remove over Back when both would occupy the left slot", () => {
|
||||
renderWithProviders(
|
||||
<Create
|
||||
{...defaultProps}
|
||||
showBackButton
|
||||
showRemoveButton
|
||||
onBack={vi.fn()}
|
||||
onRemove={vi.fn()}
|
||||
showNextButton
|
||||
nextButtonText="Save"
|
||||
/>,
|
||||
);
|
||||
expect(screen.getByRole("button", { name: "Remove" })).toBeInTheDocument();
|
||||
expect(screen.queryByRole("button", { name: "Back" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("uses responsive width at baseline (matches Login modal)", () => {
|
||||
renderWithProviders(
|
||||
<Create {...defaultProps}>Create dialog content</Create>,
|
||||
|
||||
@@ -519,7 +519,7 @@ describe("FinalReviewScreen — chip detail modal", () => {
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("closes the chip edit modal when Back is pressed", async () => {
|
||||
it("closes the chip edit modal when the close control is pressed", async () => {
|
||||
render(
|
||||
<FinalReviewWithStateProbe
|
||||
onState={() => {}}
|
||||
@@ -532,12 +532,41 @@ describe("FinalReviewScreen — chip detail modal", () => {
|
||||
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Signal" }));
|
||||
const dialog = await screen.findByRole("dialog");
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Back" }));
|
||||
expect(
|
||||
within(dialog).getByRole("button", { name: "Remove" }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
within(dialog).queryByRole("button", { name: "Back" }),
|
||||
).not.toBeInTheDocument();
|
||||
fireEvent.click(within(dialog).getByLabelText("Close dialog"));
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it("deselects a method chip from the footer Remove", async () => {
|
||||
let latest: CreateFlowState = {};
|
||||
render(
|
||||
<FinalReviewWithStateProbe
|
||||
onState={(s) => {
|
||||
latest = s;
|
||||
}}
|
||||
initial={{
|
||||
title: "Oak Park Commons",
|
||||
selectedCommunicationMethodIds: ["signal"],
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Signal" }));
|
||||
const dialog = await screen.findByRole("dialog");
|
||||
fireEvent.click(within(dialog).getByRole("button", { name: "Remove" }));
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
});
|
||||
expect(latest.selectedCommunicationMethodIds ?? []).not.toContain("signal");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,9 @@ describe("MembershipMethodsScreen", () => {
|
||||
for (const field of fields) {
|
||||
expect(field).toBeEnabled();
|
||||
}
|
||||
expect(
|
||||
within(dialog).queryByRole("button", { name: "Remove" }),
|
||||
).not.toBeInTheDocument();
|
||||
fireEvent.click(
|
||||
within(dialog).getByRole("button", { name: "More options" }),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user