From 19f8a66928f2bdda789cbfca0ef8a3cdcc4ca5b4 Mon Sep 17 00:00:00 2001 From: Ashutosh Sahoo Date: Tue, 17 Sep 2024 00:09:49 +0530 Subject: [PATCH] Changing enum values to upper case snake case for consistency (#1253) * changed the date details to camel case * test are failing * changed to decided variable types * updated tests * updated mocking of system time * date is mocked * remove unnecessary test * test done * change setting * removed hardcoding --------- Co-authored-by: Amit Prakash <34869115+iamitprakash@users.noreply.github.com> --- .../Components/Tasks/TaskDetails.test.tsx | 25 +++++++++---------- src/components/taskDetails/Details.tsx | 10 ++++---- src/components/taskDetails/TaskDates.tsx | 7 +++--- src/constants/constants.ts | 2 ++ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/__tests__/Unit/Components/Tasks/TaskDetails.test.tsx b/__tests__/Unit/Components/Tasks/TaskDetails.test.tsx index 14a1f86f5..40f076ec2 100644 --- a/__tests__/Unit/Components/Tasks/TaskDetails.test.tsx +++ b/__tests__/Unit/Components/Tasks/TaskDetails.test.tsx @@ -25,6 +25,7 @@ import { taskRequestErrorHandler } from '../../../../__mocks__/handlers/task-req import { taskDetailsHandler } from '../../../../__mocks__/handlers/task-details.handler'; import { superUserSelfHandler } from '../../../../__mocks__/handlers/self.handler'; import convertTimeStamp from '@/helperFunctions/convertTimeStamp'; +import { STARTED_ON, ENDS_ON } from '@/constants/constants'; const details = { url: 'https://realdevsquad.com/tasks/6KhcLU3yr45dzjQIVm0J/details', taskID: '6KhcLU3yr45dzjQIVm0J', @@ -194,14 +195,14 @@ describe('TaskDetails Page', () => { renderWithRouter(
); const dateElements = screen.queryAllByText('3/30/2024, 11:20:00 AM'); - expect(dateElements.length).toBeGreaterThan(0); + expect(dateElements).not.toBeNull(); }); it('Renders N/A when link is empty or undefined', async () => { @@ -213,7 +214,6 @@ describe('TaskDetails Page', () => { expect(element).toBeInTheDocument(); }); }); - it('Renders Task Assignee', async () => { const { getByText } = renderWithRouter( @@ -226,22 +226,21 @@ describe('TaskDetails Page', () => { }); }); it('Renders Task Ends-on Date', async () => { - const { getAllByText } = renderWithRouter( + renderWithRouter( -
+
); await waitFor(() => { - const dateElements = getAllByText('4/19/2021, 12:00:10 AM'); - expect(dateElements.length).toBeGreaterThan(0); + const dateElements = screen.queryAllByText('4/19/2021, 12:00:10 AM'); + expect(dateElements).not.toBeNull(); }); }); - it('Does not render Extension Request icon when URL not available', async () => { const { queryByTestId } = render(
@@ -638,7 +637,7 @@ describe('Details component', () => { }); it('Does not display tooltip on hover when timestamp is not provided', async () => { - render(
); + render(
); const detailValue = screen.getByText('Started:'); fireEvent.mouseOver(detailValue); const tooltip = screen.queryByText('N/A', { selector: '.tooltip' }); @@ -647,7 +646,7 @@ describe('Details component', () => { it('Renders an extension request icon for Ends On with URL', () => { const url = 'https://example.com'; - renderWithRouter(
); + renderWithRouter(
); const extensionRequestIcon = screen.getByTestId( 'extension-request-icon' ); @@ -656,7 +655,7 @@ describe('Details component', () => { }); it('Does not render an extension request icon for Ends On without URL', () => { - renderWithRouter(
); + renderWithRouter(
); const extensionRequestIcon = screen.queryByTestId( 'extension-request-icon' ); @@ -669,7 +668,7 @@ describe('Details component', () => { startedOn: '1707869428.523', }; renderWithRouter( -
+
); try { const detailTypeElement = screen.getByText('Started:'); diff --git a/src/components/taskDetails/Details.tsx b/src/components/taskDetails/Details.tsx index a222f921a..4fa1017e0 100644 --- a/src/components/taskDetails/Details.tsx +++ b/src/components/taskDetails/Details.tsx @@ -7,6 +7,7 @@ import setColor from './taskPriorityColors'; import extractRepoName from '@/utils/extractRepoName'; import styles from './task-details.module.scss'; import { TaskDetailsProps } from '@/interfaces/taskDetails.type'; +import { STARTED_ON, ENDS_ON } from '@/constants/constants'; type StringNumberOrUndefined = string | number | undefined; @@ -53,13 +54,12 @@ const Details: FC = ({ detailType, value, url }) => { setTooltipActive((prev) => !prev); }; - const isTimeDetail = - detailType === 'Started On' || detailType === 'Ends On'; + const isTimeDetail = detailType === STARTED_ON || detailType === ENDS_ON; const formattedDetailType = - detailType === 'Started On' + detailType === STARTED_ON ? 'Started' - : detailType === 'Ends On' + : detailType === ENDS_ON ? 'Ended' : detailType; @@ -97,7 +97,7 @@ const Details: FC = ({ detailType, value, url }) => { )} - {detailType === 'Ends On' && url && ( + {detailType === ENDS_ON && url && ( = ({ return ( <>
-
+
{isExtensionRequestPending && (
= ({ /> )} {!isExtensionRequestPending && ( -
+
)} {isEditing && isUserAuthorized && (