diff --git a/src/elements/common/content-answers/ContentAnswers.tsx b/src/elements/common/content-answers/ContentAnswers.tsx index 9080e8b20b..a25aad94cf 100644 --- a/src/elements/common/content-answers/ContentAnswers.tsx +++ b/src/elements/common/content-answers/ContentAnswers.tsx @@ -4,7 +4,6 @@ import getProp from 'lodash/get'; import ContentAnswersModal, { ExternalProps as ContentAnswersModalExternalProps } from './ContentAnswersModal'; import ContentAnswersOpenButton from './ContentAnswersOpenButton'; // @ts-ignore: no ts definition -// eslint-disable-next-line import/named import { BoxItem } from '../../common/types/core'; interface ExternalProps extends ContentAnswersModalExternalProps { @@ -12,10 +11,13 @@ interface ExternalProps extends ContentAnswersModalExternalProps { } interface Props { + className?: string; file: BoxItem; } -const ContentAnswers = ({ file, onAsk, onRequestClose, ...rest }: ContentAnswersModalExternalProps & Props) => { +const ContentAnswers = (props: ContentAnswersModalExternalProps & Props) => { + const { className = '', file, onAsk, onRequestClose, ...rest } = props; + const [isModalOpen, setIsModalOpen] = useState(false); const [hasQuestions, setHasQuestions] = useState(false); const [isHighlighted, setIsHighlighted] = useState(false); @@ -44,7 +46,7 @@ const ContentAnswers = ({ file, onAsk, onRequestClose, ...rest }: ContentAnswers const currentExtension = getProp(file, 'extension'); return ( -
+
import(/* webpackMode: "lazy", webpackChunkName: "content-answers" */ '../../common/content-answers'), +}); const LoadableContentOpenWith = AsyncLoad({ loader: () => import(/* webpackMode: "lazy", webpackChunkName: "content-open-with" */ '../../content-open-with'), }); @@ -101,7 +103,13 @@ const PreviewHeader = ({ {...contentOpenWithProps} /> )} - {shouldRenderAnswers && } + {shouldRenderAnswers && ( + + )} {canAnnotate && ( <> { @@ -31,7 +29,7 @@ describe('elements/content-preview/preview-header/PreviewHeader', () => { const contentAnswersProps = { show }; const wrapper = getWrapper({ contentAnswersProps, file }); - expect(wrapper.exists(ContentAnswers)).toBe(expected); + expect(wrapper.exists('.bcpr-PreviewHeader-contentAnswers')).toBe(expected); }); it('should render ContentAnswers correctly and provided the correct props', () => { @@ -41,7 +39,7 @@ describe('elements/content-preview/preview-header/PreviewHeader', () => { contentAnswersProps, file, }); - expect(wrapper.find(ContentAnswers).prop('file')).toBe(file); + expect(wrapper.find('.bcpr-PreviewHeader-contentAnswers').prop('file')).toBe(file); }); test.each([