From 0a21a16eb03a2456428f7004ce10301f46771e33 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Mon, 29 Jul 2024 18:50:35 +0200 Subject: [PATCH] Raise coverage (#6441) Adding a few tests and remove a few unused files to raise code coverage a bit --- .../CalendarEventParticipantsResponseStatusField.tsx | 4 ++-- .../activities/components/ActivityEditorFields.tsx | 2 +- .../components/ActivityTargetInlineCellEditMode.tsx | 5 +---- .../utils/getActivityTargetObjectFieldName.ts | 7 ------- .../ui/layout/right-drawer/components/RightDrawer.tsx | 4 ++-- ...ted.ts => isRightDrawerAnimationCompletedState.ts} | 0 .../src/utils/__tests__/isValidUuid.test.ts | 11 +++++++++++ 7 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 packages/twenty-front/src/modules/activities/utils/getActivityTargetObjectFieldName.ts rename packages/twenty-front/src/modules/ui/layout/right-drawer/states/{isRightDrawerAnimationCompleted.ts => isRightDrawerAnimationCompletedState.ts} (100%) create mode 100644 packages/twenty-front/src/utils/__tests__/isValidUuid.test.ts diff --git a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventParticipantsResponseStatusField.tsx b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventParticipantsResponseStatusField.tsx index 14ccd69a2..2f29177c5 100644 --- a/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventParticipantsResponseStatusField.tsx +++ b/packages/twenty-front/src/modules/activities/calendar/components/CalendarEventParticipantsResponseStatusField.tsx @@ -1,6 +1,6 @@ -import { useRef } from 'react'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; +import { useRef } from 'react'; import { useRecoilValue } from 'recoil'; import { IconCheck, IconQuestionMark, IconX } from 'twenty-ui'; @@ -9,7 +9,7 @@ import { ParticipantChip } from '@/activities/components/ParticipantChip'; import { PropertyBox } from '@/object-record/record-inline-cell/property-box/components/PropertyBox'; import { EllipsisDisplay } from '@/ui/field/display/components/EllipsisDisplay'; import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList'; -import { isRightDrawerAnimationCompletedState } from '@/ui/layout/right-drawer/states/isRightDrawerAnimationCompleted'; +import { isRightDrawerAnimationCompletedState } from '@/ui/layout/right-drawer/states/isRightDrawerAnimationCompletedState'; const StyledInlineCellBaseContainer = styled.div` align-items: center; diff --git a/packages/twenty-front/src/modules/activities/components/ActivityEditorFields.tsx b/packages/twenty-front/src/modules/activities/components/ActivityEditorFields.tsx index e8b189258..e29b774b6 100644 --- a/packages/twenty-front/src/modules/activities/components/ActivityEditorFields.tsx +++ b/packages/twenty-front/src/modules/activities/components/ActivityEditorFields.tsx @@ -14,7 +14,7 @@ import { import { RecordInlineCell } from '@/object-record/record-inline-cell/components/RecordInlineCell'; import { PropertyBox } from '@/object-record/record-inline-cell/property-box/components/PropertyBox'; import { recordStoreFamilyState } from '@/object-record/record-store/states/recordStoreFamilyState'; -import { isRightDrawerAnimationCompletedState } from '@/ui/layout/right-drawer/states/isRightDrawerAnimationCompleted'; +import { isRightDrawerAnimationCompletedState } from '@/ui/layout/right-drawer/states/isRightDrawerAnimationCompletedState'; import { isDefined } from '~/utils/isDefined'; const StyledPropertyBox = styled(PropertyBox)` diff --git a/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetInlineCellEditMode.tsx b/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetInlineCellEditMode.tsx index 0b85e2007..5ebc52826 100644 --- a/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetInlineCellEditMode.tsx +++ b/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetInlineCellEditMode.tsx @@ -10,7 +10,6 @@ import { Activity } from '@/activities/types/Activity'; import { ActivityTarget } from '@/activities/types/ActivityTarget'; import { ActivityTargetWithTargetRecord } from '@/activities/types/ActivityTargetObject'; import { getActivityTargetObjectFieldIdName } from '@/activities/utils/getActivityTargetObjectFieldIdName'; -import { getActivityTargetObjectFieldName } from '@/activities/utils/getActivityTargetObjectFieldName'; import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; import { useCreateManyRecordsInCache } from '@/object-record/cache/hooks/useCreateManyRecordsInCache'; @@ -163,9 +162,7 @@ export const ActivityTargetInlineCellEditMode = ({ ); const newActivityTargetId = v4(); - const fieldName = getActivityTargetObjectFieldName({ - nameSingular: record.objectMetadataItem.nameSingular, - }); + const fieldName = record.objectMetadataItem.nameSingular; const fieldNameWithIdSuffix = getActivityTargetObjectFieldIdName({ nameSingular: record.objectMetadataItem.nameSingular, }); diff --git a/packages/twenty-front/src/modules/activities/utils/getActivityTargetObjectFieldName.ts b/packages/twenty-front/src/modules/activities/utils/getActivityTargetObjectFieldName.ts deleted file mode 100644 index a4081e2a1..000000000 --- a/packages/twenty-front/src/modules/activities/utils/getActivityTargetObjectFieldName.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const getActivityTargetObjectFieldName = ({ - nameSingular, -}: { - nameSingular: string; -}) => { - return `${nameSingular}`; -}; diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawer.tsx b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawer.tsx index 0fc54fbda..1da369918 100644 --- a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawer.tsx +++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawer.tsx @@ -1,12 +1,12 @@ -import { useRef } from 'react'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { motion } from 'framer-motion'; +import { useRef } from 'react'; import { useRecoilCallback, useRecoilState, useRecoilValue } from 'recoil'; import { Key } from 'ts-key-enum'; import { RIGHT_DRAWER_CLICK_OUTSIDE_LISTENER_ID } from '@/ui/layout/right-drawer/constants/RightDrawerClickOutsideListener'; -import { isRightDrawerAnimationCompletedState } from '@/ui/layout/right-drawer/states/isRightDrawerAnimationCompleted'; +import { isRightDrawerAnimationCompletedState } from '@/ui/layout/right-drawer/states/isRightDrawerAnimationCompletedState'; import { isRightDrawerMinimizedState } from '@/ui/layout/right-drawer/states/isRightDrawerMinimizedState'; import { rightDrawerCloseEventState } from '@/ui/layout/right-drawer/states/rightDrawerCloseEventsState'; import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys'; diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerAnimationCompleted.ts b/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerAnimationCompletedState.ts similarity index 100% rename from packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerAnimationCompleted.ts rename to packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerAnimationCompletedState.ts diff --git a/packages/twenty-front/src/utils/__tests__/isValidUuid.test.ts b/packages/twenty-front/src/utils/__tests__/isValidUuid.test.ts new file mode 100644 index 000000000..768972b53 --- /dev/null +++ b/packages/twenty-front/src/utils/__tests__/isValidUuid.test.ts @@ -0,0 +1,11 @@ +import { isValidUuid } from '~/utils/isValidUuid'; + +describe('isValidUuid', () => { + it('returns true if value is a valid UUID', () => { + expect(isValidUuid('bec09e27-4ecc-4a85-afc1-f2c0ace28bfa')).toBe(true); + }); + + it('returns false if value is not a valid UUID', () => { + expect(isValidUuid('123e4567-e89b-12d3-a456-42661417400')).toBe(false); + }); +});