Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ describe("ShowPagesListPage", () => {
}
}
);
const editButton = screen.getByTestId("EditIcon").closest("button");
await act(async () => {
await userEvent.click(editButton);
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
await userEvent.click(
screen.getByRole("menuitem", { name: "general.edit" })
);
});
expect(getSummitSponsorshipTypes).toHaveBeenCalledWith(
DEFAULT_CURRENT_PAGE,
Expand All @@ -168,9 +170,11 @@ describe("ShowPagesListPage", () => {
}
}
);
const editButton = screen.getByTestId("EditIcon").closest("button");
await act(async () => {
await userEvent.click(editButton);
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
await userEvent.click(
screen.getByRole("menuitem", { name: "general.edit" })
);
});
expect(getSummitSponsorshipTypes).toHaveBeenCalledWith(
DEFAULT_CURRENT_PAGE,
Expand Down Expand Up @@ -208,10 +212,13 @@ describe("ShowPagesListPage", () => {
}
}
);
const deleteButtons = screen.getAllByTestId("DeleteIcon");
const secondDeleteButton = deleteButtons[1].closest("button");
await act(async () => {
await userEvent.click(secondDeleteButton);
await userEvent.click(
screen.getAllByTestId("row-actions-menu-trigger")[1]
);
await userEvent.click(
screen.getByRole("menuitem", { name: "general.delete" })
);
});
expect(
await screen.findByText("general.are_you_sure")
Expand Down Expand Up @@ -244,9 +251,11 @@ describe("ShowPagesListPage", () => {
}
}
);
const deleteButton = screen.getByTestId("DeleteIcon").closest("button");
await act(async () => {
await userEvent.click(deleteButton);
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
await userEvent.click(
screen.getByRole("menuitem", { name: "general.delete" })
);
});
expect(
await screen.findByText("general.are_you_sure")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ describe("CartView", () => {
expect(
screen.queryByRole("button", { name: "edit_sponsor.cart_tab.add_form" })
).not.toBeInTheDocument();
expect(screen.queryByTestId("action-edit")).not.toBeInTheDocument();
expect(screen.queryByTestId("action-delete")).not.toBeInTheDocument();
expect(
screen.queryByTestId("row-actions-menu-trigger")
).not.toBeInTheDocument();
expect(
screen.queryByText("edit_sponsor.cart_tab.sponsor_note.title")
).not.toBeInTheDocument();
Expand All @@ -187,14 +188,19 @@ describe("CartView", () => {
).not.toBeInTheDocument();
});

it("shows them on an Open cart", () => {
it("shows them on an Open cart", async () => {
renderCartView(createCart());

expect(
screen.getByRole("button", { name: "edit_sponsor.cart_tab.add_form" })
).toBeInTheDocument();
expect(screen.getByTestId("action-edit")).toBeInTheDocument();
expect(screen.getByTestId("action-delete")).toBeInTheDocument();
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
expect(
screen.getByRole("menuitem", { name: "general.edit" })
).toBeInTheDocument();
expect(
screen.getByRole("menuitem", { name: "general.delete" })
).toBeInTheDocument();
expect(
screen.getByText("edit_sponsor.cart_tab.sponsor_note.title")
).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ const CartView = ({
}
];

const amountIndex = tableColumns.findIndex((c) => c.columnKey === "amount");

return (
<>
<GridToolbar
Expand Down Expand Up @@ -221,7 +223,6 @@ const CartView = ({
<MuiTable
columns={tableColumns}
data={cartData}
options={{ responsive: false }}
onEdit={cartIsEditable ? handleEditForm : undefined}
onDelete={cartIsEditable ? handleDelete : undefined}
deleteDialogBody={(formName) =>
Expand All @@ -231,11 +232,13 @@ const CartView = ({
}
confirmButtonColor="error"
>
{/* gap skips manage items when hidden, trailing covers lock (+ edit, delete) */}
{cartIsEditable ? (
<TotalRow total={cart?.total} colGap={5} trailing={3} />
) : (
<TotalRow total={cart?.total} colGap={4} trailing={1} />
{/* aligns the total under amount; MuiTable passes its column count */}
{(colCount) => (
<TotalRow
total={cart?.total}
colGap={amountIndex - 1}
trailing={colCount - amountIndex - 1}
/>
)}
</MuiTable>
{isCardPaymentCart && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ describe("SponsorFormsTab", () => {
const explicitRow = screen.getByText("Managed Form 1").closest("tr");
const implicitRow = screen.getByText("Managed Form 2").closest("tr");

expect(within(explicitRow).getByTestId("DeleteIcon")).toBeInTheDocument();
expect(
within(implicitRow).queryByTestId("DeleteIcon")
within(explicitRow).getByTestId("row-actions-menu-trigger")
).toBeInTheDocument();
expect(
within(implicitRow).queryByTestId("row-actions-menu-trigger")
).not.toBeInTheDocument();
});

Expand Down Expand Up @@ -232,10 +234,13 @@ describe("SponsorFormsTab", () => {
expect(screen.getByText("Managed Form 1")).toBeInTheDocument();
expect(screen.getByText("Managed Form 2")).toBeInTheDocument();

const deleteButtons = screen.getAllByTestId("DeleteIcon");
const secondDeleteButton = deleteButtons[1].closest("button");
await act(async () => {
await userEvent.click(secondDeleteButton);
await userEvent.click(
screen.getAllByTestId("row-actions-menu-trigger")[1]
);
await userEvent.click(
screen.getByRole("menuitem", { name: "general.delete" })
);
});

expect(
Expand Down Expand Up @@ -289,9 +294,11 @@ describe("SponsorFormsTab", () => {
}
});

const deleteButton = screen.getByTestId("DeleteIcon").closest("button");
await act(async () => {
await userEvent.click(deleteButton);
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
await userEvent.click(
screen.getByRole("menuitem", { name: "general.delete" })
);
});

expect(
Expand Down Expand Up @@ -322,9 +329,11 @@ describe("SponsorFormsTab", () => {
store
});

const deleteButton = screen.getByTestId("DeleteIcon").closest("button");
await act(async () => {
await userEvent.click(deleteButton);
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
await userEvent.click(
screen.getByRole("menuitem", { name: "general.delete" })
);
});

expect(
Expand Down Expand Up @@ -371,9 +380,11 @@ describe("SponsorFormsTab", () => {
}
});

const deleteButton = screen.getByTestId("DeleteIcon").closest("button");
await act(async () => {
await userEvent.click(deleteButton);
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
await userEvent.click(
screen.getByRole("menuitem", { name: "general.delete" })
);
});

expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,11 @@ describe("SponsorPagesTab", () => {
}
);

const editButton = screen.getByTestId("EditIcon").closest("button");
await act(async () => {
await userEvent.click(editButton);
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
await userEvent.click(
screen.getByRole("menuitem", { name: "general.edit" })
);
});

expect(getSponsorCustomizedPage).toHaveBeenCalledWith(1);
Expand Down Expand Up @@ -355,9 +357,11 @@ describe("SponsorPagesTab", () => {
}
);

const editButton = screen.getByTestId("EditIcon").closest("button");
await act(async () => {
await userEvent.click(editButton);
await userEvent.click(screen.getByTestId("row-actions-menu-trigger"));
await userEvent.click(
screen.getByRole("menuitem", { name: "general.edit" })
);
});

await waitFor(() => {
Expand Down
Loading