From ac0f1325d946bd3c8de7cecd39d35c6e16ffb8cc Mon Sep 17 00:00:00 2001 From: Shubham Sharma <68867418+skv93-coder@users.noreply.github.com> Date: Tue, 4 Jun 2024 23:21:49 +0530 Subject: [PATCH] Removed the completed status (#1214) Co-authored-by: Shubham Sharma --- .../Components/Tasks/TaskDropDown.test.tsx | 18 ++++++++++++++++++ .../Tasks/TaskStatusEditMode.test.tsx | 9 +++++++-- src/components/taskDetails/index.tsx | 5 ++++- src/components/tasks/TaskDropDown.tsx | 11 +++++++++-- .../tasks/card/TaskStatusEditMode.tsx | 13 ++++++++++++- src/components/tasks/card/index.tsx | 10 +++------- src/constants/constants.ts | 7 +++++++ 7 files changed, 60 insertions(+), 13 deletions(-) diff --git a/__tests__/Unit/Components/Tasks/TaskDropDown.test.tsx b/__tests__/Unit/Components/Tasks/TaskDropDown.test.tsx index c1c8bb420..935ee282c 100644 --- a/__tests__/Unit/Components/Tasks/TaskDropDown.test.tsx +++ b/__tests__/Unit/Components/Tasks/TaskDropDown.test.tsx @@ -120,6 +120,24 @@ describe('TaskDropDown', () => { const msgTag = screen.queryByTestId('msg'); expect(msgTag).toBeNull(); }); + it('should show text Done as selected option when a task with completed status is passed down.', () => { + const oldProgress = 100; + const oldStatus = BACKEND_TASK_STATUS.COMPLETED; + + render( + + ); + const option: HTMLOptionElement = screen.getByTestId( + 'task-status-DONE' + ) as HTMLOptionElement; + expect(option.selected).toBeTruthy(); + }); + it('should not show any model info on change of status from in progress to blocked', () => { const oldProgress = 70; const oldStatus = BACKEND_TASK_STATUS.IN_PROGRESS; diff --git a/__tests__/Unit/Components/Tasks/TaskStatusEditMode.test.tsx b/__tests__/Unit/Components/Tasks/TaskStatusEditMode.test.tsx index 2285e2917..b02f8319c 100644 --- a/__tests__/Unit/Components/Tasks/TaskStatusEditMode.test.tsx +++ b/__tests__/Unit/Components/Tasks/TaskStatusEditMode.test.tsx @@ -177,7 +177,12 @@ describe('TaskStatusEditMode', () => { describe('test beautifyStatus function', () => { it('test usage', () => { - const output = beautifyStatus('I_N'); - expect(output).toEqual('I N'); + const output = beautifyStatus('IN_PROGRESS'); + expect(output).toEqual('In Progress'); + }); + + it('returns DONE when completed is passed and dev mode is one', () => { + const res = beautifyStatus('COMPLETED', true); + expect(res).toEqual('Done'); }); }); diff --git a/src/components/taskDetails/index.tsx b/src/components/taskDetails/index.tsx index 41d79edce..8c063b480 100755 --- a/src/components/taskDetails/index.tsx +++ b/src/components/taskDetails/index.tsx @@ -63,6 +63,8 @@ type Props = { }; const TaskDetails: FC = ({ taskID }) => { const router = useRouter(); + const { dev } = router.query; + const isDevMode = dev === 'true'; const { isUserAuthorized } = useUserData(); @@ -325,7 +327,8 @@ const TaskDetails: FC = ({ taskID }) => {
!(isDevMode && key === 'COMPLETED') && @@ -110,8 +113,12 @@ export default function TaskDropDown({ value={newStatus} > {taskStatus.map(([name, status]) => ( - ))} diff --git a/src/components/tasks/card/TaskStatusEditMode.tsx b/src/components/tasks/card/TaskStatusEditMode.tsx index 76fed2ed8..8d4c31b37 100644 --- a/src/components/tasks/card/TaskStatusEditMode.tsx +++ b/src/components/tasks/card/TaskStatusEditMode.tsx @@ -8,6 +8,7 @@ import { PENDING, SAVED, ERROR_STATUS } from '../constants'; import { useUpdateTaskMutation } from '@/app/services/tasksApi'; import { StatusIndicator } from './StatusIndicator'; import TaskDropDown from '../TaskDropDown'; +import { TASK_STATUS_MAPING } from '@/constants/constants'; type Props = { task: task; @@ -16,8 +17,18 @@ type Props = { }; // TODO: remove this after fixing the card beautify status -const beautifyStatus = (status: string) => status.split('_').join(' '); +const beautifyStatus = (status: string, isDevMode?: boolean) => { + let beautifiedStatus = status; + if (beautifiedStatus === 'COMPLETED' && isDevMode) { + beautifiedStatus = 'DONE'; + } + return ( + TASK_STATUS_MAPING[ + beautifiedStatus as keyof typeof TASK_STATUS_MAPING + ] || status + ); +}; const TaskStatusEditMode = ({ task, setEditedTaskDetails, diff --git a/src/components/tasks/card/index.tsx b/src/components/tasks/card/index.tsx index 9b19e91fb..a2e8457f6 100644 --- a/src/components/tasks/card/index.tsx +++ b/src/components/tasks/card/index.tsx @@ -7,13 +7,13 @@ import { CardProps } from '@/interfaces/task.type'; import { ALT_KEY } from '@/constants/key'; import { toast, ToastTypes } from '@/helperFunctions/toast'; import TaskLevelEdit from './TaskTagEdit'; -import { TaskStatusEditMode } from './TaskStatusEditMode'; +import { TaskStatusEditMode, beautifyStatus } from './TaskStatusEditMode'; import { updateTaskDetails } from '@/interfaces/task.type'; import { DUMMY_NAME, DUMMY_PROFILE as placeholderImageURL, } from '@/constants/display-sections'; -import { MAX_SEARCH_RESULTS, TASK_STATUS_MAPING } from '@/constants/constants'; +import { MAX_SEARCH_RESULTS } from '@/constants/constants'; import { COMPLETED, VERIFIED, @@ -584,11 +584,7 @@ const Card: FC = ({ data-testid="task-status" className={styles.statusText} > - {TASK_STATUS_MAPING[ - cardDetails.status as keyof typeof TASK_STATUS_MAPING - ] || - cardDetails.status || - 'NA'} + {beautifyStatus(cardDetails.status, isDevMode)}

)} diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 5d417d2b2..7135cb3a3 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -23,6 +23,13 @@ export const TASK_STATUS_MAPING = { APPROVED: 'Approved', IN_REVIEW: 'In Review', NEEDS_REVIEW: 'Needs Review', + DONE: 'Done', + RELEASED: 'Released', + SMOKE_TESTING: 'Smoke Testing', + SANITY_CHECK: 'Sanity Check', + REGRESSION_CHECK: 'Regression Check', + UN_ASSIGNED: 'Un Assigned', + BACKLOG: 'Backlog', }; export const SEARCH_OPTIONS = ['title', 'assignee', 'status']; export const STATUSES = [