From f6da2c051be164a2bc408cf8e4dd5109b8b02593 Mon Sep 17 00:00:00 2001 From: Azaliia Kasimova Date: Mon, 9 Sep 2024 19:53:32 +0400 Subject: [PATCH] fix: fixed tests for editable label --- .../__tests__/annotation-list.test.tsx | 2 +- .../task-sidebar-flow/__tests__/annotation.test.tsx | 12 ++++++++++-- .../task/task-sidebar-flow/annotationRow.tsx | 6 +++--- .../task-sidebar-flow/task-sidebar-flow.module.scss | 5 +++++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/web/src/components/task/task-sidebar-flow/__tests__/annotation-list.test.tsx b/web/src/components/task/task-sidebar-flow/__tests__/annotation-list.test.tsx index dbb1e268a..627c608b9 100644 --- a/web/src/components/task/task-sidebar-flow/__tests__/annotation-list.test.tsx +++ b/web/src/components/task/task-sidebar-flow/__tests__/annotation-list.test.tsx @@ -53,7 +53,7 @@ describe('AnnotationList', () => { ); - xit('Must select another annotation if selectedAnnotationId is changed', () => { + it('Must select another annotation if selectedAnnotationId is changed', () => { const firstAnnotationRowId = `${ANNOTATION_FLOW_ITEM_ID_PREFIX}${firstAnnotation.id}`; const secondAnnotationRowId = `${ANNOTATION_FLOW_ITEM_ID_PREFIX}${secondAnnotation.id}`; diff --git a/web/src/components/task/task-sidebar-flow/__tests__/annotation.test.tsx b/web/src/components/task/task-sidebar-flow/__tests__/annotation.test.tsx index c479f3d55..07e724622 100644 --- a/web/src/components/task/task-sidebar-flow/__tests__/annotation.test.tsx +++ b/web/src/components/task/task-sidebar-flow/__tests__/annotation.test.tsx @@ -8,6 +8,14 @@ import { ANNOTATION_PATH_SEPARATOR } from '../constants'; import { ANNOTATION_FLOW_ITEM_ID_PREFIX } from 'shared/constants/annotations'; import { stringToRGBA } from 'shared/components/annotator/utils/string-to-rgba'; +jest.mock('connectors/task-annotator-connector/task-annotator-context', () => ({ + useTaskAnnotatorContext: () => ({ + allAnnotations: { '1': [{}, {}] }, + currentPage: 1, + onAnnotationEdited: () => {} + }) +})); + describe('AnnotationRow', () => { const props = { id: '1', @@ -27,7 +35,7 @@ describe('AnnotationRow', () => { boundType: 'text' as AnnotationBoundType, bound: { y: 10, x: 100, width: 0, height: 0 } }; - xit('Must render annotation with full path', () => { + it('Must render annotation with full path', () => { const { getByText, getByTestId } = render(); const path = getByTestId('flow-path'); @@ -40,7 +48,7 @@ describe('AnnotationRow', () => { expect(text).toBeVisible(); expect(label).toBeVisible(); }); - xit('Must render annotation label with proper color', () => { + it('Must render annotation label with proper color', () => { const { getById, rerender } = render(); const rowContainer = getById(`${ANNOTATION_FLOW_ITEM_ID_PREFIX}${props.id}`); diff --git a/web/src/components/task/task-sidebar-flow/annotationRow.tsx b/web/src/components/task/task-sidebar-flow/annotationRow.tsx index d7ec72825..ae470be24 100644 --- a/web/src/components/task/task-sidebar-flow/annotationRow.tsx +++ b/web/src/components/task/task-sidebar-flow/annotationRow.tsx @@ -12,7 +12,7 @@ import { Annotation } from 'shared'; import { useOutsideClick } from 'shared/helpers/utils'; import { ReactComponent as closeIcon } from '@epam/assets/icons/common/navigation-close-12.svg'; -import { IconButton, Text, TextArea, TextInput } from '@epam/loveship'; +import { IconButton, Text, TextArea } from '@epam/loveship'; import { cx } from '@epam/uui'; import { ReactComponent as ContentEditFillIcon } from '@epam/assets/icons/common/content-edit-24.svg'; @@ -65,7 +65,7 @@ export const AnnotationRow: FC = ({ useEffect(() => { if (allAnnotations) { - const ann = allAnnotations[currentPage].find((ann: any) => { + const ann = allAnnotations[currentPage]?.find((ann: Annotation) => { return ann.id === id; }); setAnnotation(ann); @@ -139,7 +139,7 @@ export const AnnotationRow: FC = ({ )} {isEditMode && ( -
setIsEditMode(false)}> + setIsEditMode(false)} className={styles.textAreaForm}>