import { useState } from "react"; import { Dropdown } from "antd"; import { fireEvent, screen } from "@testing-library/react"; import { describe, expect, it, vi } from "vitest"; import { renderWithProviders } from "@/test/common_setup"; function Harness({ onAction }: { onAction: () => void }) { const [open, setOpen] = useState(true); return (
setOpen(false)}> {open && ( (
event.stopPropagation()}>{menu}
)} > anchor
)}
); } describe("Desktop context menu", () => { it("runs portal menu actions before the desktop closes the menu", () => { const onAction = vi.fn(); renderWithProviders(); fireEvent.pointerDown(screen.getByText("Arrange")); fireEvent.click(screen.getByText("Arrange")); expect(onAction).toHaveBeenCalledOnce(); }); });