Skip to content

Commit

Permalink
Merge branch 'main' into merx-1351-fix-category-description
Browse files Browse the repository at this point in the history
  • Loading branch information
poulch authored Dec 16, 2024
2 parents 929db47 + ee7cb07 commit 4853ab6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-swans-serve.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now close order manual transaction modal by clicking the close button
8 changes: 7 additions & 1 deletion src/components/Modal/Close.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ import React from "react";
export const Close = ({ onClose, ...rest }: PropsWithBox<{ onClose: () => void }>) => {
return (
<Modal.Close {...rest}>
<Button icon={<CloseIcon />} size="small" variant="tertiary" onClick={onClose} />
<Button
data-test-id="close-button"
icon={<CloseIcon />}
size="small"
variant="tertiary"
onClick={onClose}
/>
</Modal.Close>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { act, render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import React from "react";

import { OrderManualTransactionDialog } from "./OrderManualTransactionDialog";

jest.mock("react-intl", () => ({
useIntl: jest.fn(() => ({
formatMessage: jest.fn(x => x.defaultMessage),
})),
defineMessages: jest.fn(x => x),
FormattedMessage: ({ defaultMessage }: { defaultMessage: string }) => <>{defaultMessage}</>,
}));

describe("OrderManualTransactionDialog", () => {
it("should call onClose when click in close button", async () => {
// Arrange
const onClose = jest.fn();

render(
<OrderManualTransactionDialog
error={undefined}
dialogProps={{
open: true,
onClose,
}}
submitState="default"
currency="USD"
onAddTransaction={jest.fn()}
/>,
);

// Act
await act(async () => {
await userEvent.click(screen.getByTestId("close-button"));
});

// Assert
expect(onClose).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const OrderManualTransactionDialog: React.FC<OrderManualTransactionDialog

return (
<OrderManualTransactionForm {...props}>
<DashboardModal {...dialogProps}>
<DashboardModal {...dialogProps} onChange={onClose}>
<DashboardModal.Content size="xs">
<DashboardModal.Header>
<FormattedMessage {...manualTransactionMessages.dialogTitle} />
Expand Down

0 comments on commit 4853ab6

Please sign in to comment.