Skip to content

Commit

Permalink
Fix frontend tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrés Vidal <[email protected]>
  • Loading branch information
andres-vidal committed Mar 17, 2024
1 parent a59fa7f commit 9764059
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions frontend/components/Modal.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ describe("Modal", () => {
expect(close).toBe(modal);
});

it("closes when the modal is clicked", () => {
it("closes when the modal is moused down", () => {
const onClose = vi.fn();
render(<Modal isOpen={true} onClose={onClose} />);

fireEvent.click(document.querySelector("[aria-modal=true]")!);
fireEvent.mouseDown(document.querySelector("[aria-modal=true]")!);

expect(onClose).toHaveBeenCalled();
});
Expand Down
26 changes: 13 additions & 13 deletions frontend/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ const Modal: FC<Props> = ({ children, isOpen, onClose }) => {
<AnimatePresence>
{isOpen && (
<FloatingPortal>
<motion.div
aria-modal="true"
aria-label="Close modal"
className="fixed inset-0 z-50 bg-indigo-900/30"
onMouseDown={handleOverlayMouseDown}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<Header onClose={onClose} />
<FocusTrap>
<FocusTrap active={process.env.NODE_ENV !== "test"}>
<motion.div
aria-modal="true"
aria-label="Close modal"
className="fixed inset-0 z-50 bg-indigo-900/30"
onMouseDown={handleOverlayMouseDown}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<Header onClose={onClose} />
<motion.dialog
open
role="dialog"
Expand All @@ -118,8 +118,8 @@ const Modal: FC<Props> = ({ children, isOpen, onClose }) => {
>
{children}
</motion.dialog>
</FocusTrap>
</motion.div>
</motion.div>
</FocusTrap>
</FloatingPortal>
)}
</AnimatePresence>
Expand Down

0 comments on commit 9764059

Please sign in to comment.