From d23f0d4401904fac81952bde1735449555a6ee85 Mon Sep 17 00:00:00 2001 From: rebelchris Date: Sat, 28 Mar 2026 05:26:36 +0000 Subject: [PATCH 1/2] fix(shared): resolve mobile comment modal overflow --- .../modals/post/CommentModal.spec.tsx | 228 ++++++++++++++++++ .../components/modals/post/CommentModal.tsx | 62 ++++- 2 files changed, 278 insertions(+), 12 deletions(-) create mode 100644 packages/shared/src/components/modals/post/CommentModal.spec.tsx diff --git a/packages/shared/src/components/modals/post/CommentModal.spec.tsx b/packages/shared/src/components/modals/post/CommentModal.spec.tsx new file mode 100644 index 00000000000..0eb37bd7b63 --- /dev/null +++ b/packages/shared/src/components/modals/post/CommentModal.spec.tsx @@ -0,0 +1,228 @@ +import React, { type ReactNode } from 'react'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { render, screen } from '@testing-library/react'; +import CommentModal, { getCommentInputMinHeight } from './CommentModal'; +import Post from '../../../../__tests__/fixture/post'; +import loggedUser from '../../../../__tests__/fixture/loggedUser'; +import { useAuthContext } from '../../../contexts/AuthContext'; +import useCommentById from '../../../hooks/comments/useCommentById'; +import { useNotificationToggle } from '../../../hooks/notifications'; +import { useMutateComment } from '../../../hooks/post/useMutateComment'; +import { useVisualViewport } from '../../../hooks/utils/useVisualViewport'; + +jest.mock('../common/Modal', () => { + const mockReact = jest.requireActual('react') as typeof React; + + const MockModalBody = mockReact.forwardRef< + HTMLElement, + { children: ReactNode; className?: string } + >(({ children, className }, ref) => ( +
+ {children} +
+ )); + + MockModalBody.displayName = 'MockModalBody'; + + const Modal = ({ children }: { children: ReactNode }) => ( +
{children}
+ ); + + Modal.Body = MockModalBody; + + return { Modal }; +}); + +jest.mock('../../comments/CommentContainer', () => ({ + __esModule: true, + default: () =>
, +})); + +jest.mock('../../fields/Switch', () => { + const mockReact = jest.requireActual('react') as typeof React; + + const MockSwitch = mockReact.forwardRef< + HTMLLabelElement, + { + children: ReactNode; + className?: string; + labelClassName?: string; + } + >(({ children, className, labelClassName }, ref) => ( + + )); + + MockSwitch.displayName = 'MockSwitch'; + + return { + Switch: MockSwitch, + }; +}); + +jest.mock('../../fields/MarkdownInput/CommentMarkdownInput', () => { + const mockReact = jest.requireActual('react') as typeof React; + + const MockCommentMarkdownInput = mockReact.forwardRef< + HTMLFormElement, + { + className?: Record; + formProps?: Record; + } + >(({ className, formProps }, ref) => ( +
+
+