mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-08 22:38:05 -05:00
fix(frontend): add missing onClose prop to conversation panel modals (#12219)
Co-authored-by: amanape <83104063+amanape@users.noreply.github.com>
This commit is contained in:
@@ -885,4 +885,83 @@ describe("ConversationPanel", () => {
|
|||||||
title: "Special @#$%^&*()_+ Characters",
|
title: "Special @#$%^&*()_+ Characters",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should close delete modal when clicking backdrop", async () => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
renderConversationPanel();
|
||||||
|
|
||||||
|
const cards = await screen.findAllByTestId("conversation-card");
|
||||||
|
|
||||||
|
// Open context menu and click delete
|
||||||
|
const ellipsisButton = within(cards[0]).getByTestId("ellipsis-button");
|
||||||
|
await user.click(ellipsisButton);
|
||||||
|
const deleteButton = within(cards[0]).getByTestId("delete-button");
|
||||||
|
await user.click(deleteButton);
|
||||||
|
|
||||||
|
// Modal should be visible
|
||||||
|
expect(
|
||||||
|
screen.getByRole("button", { name: /confirm/i }),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
|
||||||
|
// Click the backdrop (the dark overlay behind the modal)
|
||||||
|
const backdrop = document.querySelector(".bg-black.opacity-60");
|
||||||
|
expect(backdrop).toBeInTheDocument();
|
||||||
|
await user.click(backdrop!);
|
||||||
|
|
||||||
|
// Modal should be closed
|
||||||
|
expect(
|
||||||
|
screen.queryByRole("button", { name: /confirm/i }),
|
||||||
|
).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should close stop modal when clicking backdrop", async () => {
|
||||||
|
const user = userEvent.setup();
|
||||||
|
|
||||||
|
// Create mock data with a RUNNING conversation
|
||||||
|
const mockRunningConversations: Conversation[] = [
|
||||||
|
{
|
||||||
|
conversation_id: "1",
|
||||||
|
title: "Running Conversation",
|
||||||
|
selected_repository: null,
|
||||||
|
git_provider: null,
|
||||||
|
selected_branch: null,
|
||||||
|
last_updated_at: "2021-10-01T12:00:00Z",
|
||||||
|
created_at: "2021-10-01T12:00:00Z",
|
||||||
|
status: "RUNNING" as const,
|
||||||
|
runtime_status: null,
|
||||||
|
url: null,
|
||||||
|
session_api_key: null,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
vi.spyOn(ConversationService, "getUserConversations").mockResolvedValue({
|
||||||
|
results: mockRunningConversations,
|
||||||
|
next_page_id: null,
|
||||||
|
});
|
||||||
|
|
||||||
|
renderConversationPanel();
|
||||||
|
|
||||||
|
const cards = await screen.findAllByTestId("conversation-card");
|
||||||
|
|
||||||
|
// Open context menu and click stop
|
||||||
|
const ellipsisButton = within(cards[0]).getByTestId("ellipsis-button");
|
||||||
|
await user.click(ellipsisButton);
|
||||||
|
const stopButton = within(cards[0]).getByTestId("stop-button");
|
||||||
|
await user.click(stopButton);
|
||||||
|
|
||||||
|
// Modal should be visible
|
||||||
|
expect(
|
||||||
|
screen.getByRole("button", { name: /confirm/i }),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
|
||||||
|
// Click the backdrop
|
||||||
|
const backdrop = document.querySelector(".bg-black.opacity-60");
|
||||||
|
expect(backdrop).toBeInTheDocument();
|
||||||
|
await user.click(backdrop!);
|
||||||
|
|
||||||
|
// Modal should be closed
|
||||||
|
expect(
|
||||||
|
screen.queryByRole("button", { name: /confirm/i }),
|
||||||
|
).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export function ConfirmDeleteModal({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalBackdrop>
|
<ModalBackdrop onClose={onCancel}>
|
||||||
<ModalBody className="items-start border border-tertiary">
|
<ModalBody className="items-start border border-tertiary">
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<BaseModalTitle title={t(I18nKey.CONVERSATION$CONFIRM_DELETE)} />
|
<BaseModalTitle title={t(I18nKey.CONVERSATION$CONFIRM_DELETE)} />
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ export function ConfirmStopModal({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalBackdrop>
|
<ModalBackdrop onClose={onCancel}>
|
||||||
<ModalBody className="items-start border border-tertiary">
|
<ModalBody className="items-start border border-tertiary">
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<BaseModalTitle
|
<BaseModalTitle
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ export function ConversationPanel({ onClose }: ConversationPanelProps) {
|
|||||||
onClose();
|
onClose();
|
||||||
}}
|
}}
|
||||||
onClose={() => setConfirmExitConversationModalVisible(false)}
|
onClose={() => setConfirmExitConversationModalVisible(false)}
|
||||||
|
onCancel={() => setConfirmExitConversationModalVisible(false)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,16 +8,18 @@ import { I18nKey } from "#/i18n/declaration";
|
|||||||
interface ExitConversationModalProps {
|
interface ExitConversationModalProps {
|
||||||
onConfirm: () => void;
|
onConfirm: () => void;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
onCancel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ExitConversationModal({
|
export function ExitConversationModal({
|
||||||
onConfirm,
|
onConfirm,
|
||||||
onClose,
|
onClose,
|
||||||
|
onCancel,
|
||||||
}: ExitConversationModalProps) {
|
}: ExitConversationModalProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalBackdrop>
|
<ModalBackdrop onClose={onCancel}>
|
||||||
<ModalBody testID="confirm-new-conversation-modal">
|
<ModalBody testID="confirm-new-conversation-modal">
|
||||||
<BaseModalTitle title={t(I18nKey.CONVERSATION$EXIT_WARNING)} />
|
<BaseModalTitle title={t(I18nKey.CONVERSATION$EXIT_WARNING)} />
|
||||||
<div className="flex w-full gap-2">
|
<div className="flex w-full gap-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user