diff --git a/__tests__/Unit/Components/Tasks/Card.test.tsx b/__tests__/Unit/Components/Tasks/Card.test.tsx index c09ad7232..095e41c3d 100644 --- a/__tests__/Unit/Components/Tasks/Card.test.tsx +++ b/__tests__/Unit/Components/Tasks/Card.test.tsx @@ -41,7 +41,7 @@ const DEFAULT_PROPS = { startedOn: '1618790400', isNoteworthy: true, title: 'test 1 for drag and drop', - purpose: 'string', + purpose: 'to test purpose', percentCompleted: 0, endsOn: 1618790400, status: COMPLETED, @@ -54,9 +54,55 @@ const DEFAULT_PROPS = { onContentChange: jest.fn(), }; +describe("Task card, self task's purpose and status", () => { + it('renders the card with title and status', () => { + renderWithRouter( + + + , + { + query: { dev: 'true' }, + } + ); + expect( + screen.getByText('test 1 for drag and drop') + ).toBeInTheDocument(); + expect(screen.getByText('Done')).toBeInTheDocument(); + }); + + it('displays the purpose if provided', () => { + renderWithRouter( + + + , + { + query: { dev: 'true' }, + } + ); + expect(screen.getByText('to test purpose')).toBeInTheDocument(); + }); + + it('does not display the purpose if not provided', () => { + const PROPS_WITHOUT_PURPOSE = { + ...DEFAULT_PROPS, + content: { ...DEFAULT_PROPS.content, purpose: '' }, + }; + renderWithRouter( + + + , + { + query: { dev: 'true' }, + } + ); + expect(screen.queryByText('to test purpose')).not.toBeInTheDocument(); + }); +}); + jest.mock('@/hooks/useUserData', () => { return () => ({ data: { + username: 'ankur', roles: { admin: true, super_user: true, diff --git a/__tests__/Unit/Components/Tasks/TaskDropDown.test.tsx b/__tests__/Unit/Components/Tasks/TaskDropDown.test.tsx index 935ee282c..c16225705 100644 --- a/__tests__/Unit/Components/Tasks/TaskDropDown.test.tsx +++ b/__tests__/Unit/Components/Tasks/TaskDropDown.test.tsx @@ -97,6 +97,29 @@ describe('TaskDropDown', () => { expect(onChange).toHaveBeenCalledTimes(0); expect(screen.getByTestId('task-status')).toHaveValue(oldStatus); }); + + it('should render cardPurposeAndStatusFont for label and taskStatusUpdate for select when isDevMode is true', () => { + const oldProgress = 100; + const oldStatus = BACKEND_TASK_STATUS.NEEDS_REVIEW; + const TASK_STATUS_UPDATE = 'taskStatusUpdate'; + const CARD_PURPOSE_STATUS_FONT = 'cardPurposeAndStatusFont'; + + render( + + ); + expect(screen.getByTestId('task-status')).toHaveClass( + TASK_STATUS_UPDATE + ); + expect(screen.getByTestId('task-status-label')).toHaveClass( + CARD_PURPOSE_STATUS_FONT + ); + }); + it('should not show any model info on change of status from in progress to backlog', () => { const oldProgress = 80; 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 3f9c312bb..4f78dab5a 100644 --- a/__tests__/Unit/Components/Tasks/TaskStatusEditMode.test.tsx +++ b/__tests__/Unit/Components/Tasks/TaskStatusEditMode.test.tsx @@ -19,8 +19,10 @@ const BLOCKED_TASK = { describe('TaskStatusEditMode', () => { let updateTaskSpy: any; + let updateSelfTaskSpy: any; beforeEach(() => { updateTaskSpy = jest.spyOn(tasksApi, 'useUpdateTaskMutation'); + updateSelfTaskSpy = jest.spyOn(tasksApi, 'useUpdateSelfTaskMutation'); }); afterEach(() => { @@ -173,6 +175,27 @@ describe('TaskStatusEditMode', () => { expect(screen.getByTestId('error')).toBeInTheDocument(); }); }); + + it('change task status from BLOCKED to IN_PROGRESS when and isDevMode are true', async () => { + const setEditedTaskDetails = jest.fn(); + + renderWithRouter( + + + + ); + + const statusSelect = screen.getByLabelText('Status:'); + expect(statusSelect).toHaveValue('BLOCKED'); + + fireEvent.change(statusSelect, { target: { value: 'IN_PROGRESS' } }); + expect(statusSelect).toHaveValue('IN_PROGRESS'); + }); }); describe('test beautifyStatus function', () => { diff --git a/src/components/tasks/TaskDropDown.tsx b/src/components/tasks/TaskDropDown.tsx index 2a177c952..ff55b376d 100644 --- a/src/components/tasks/TaskDropDown.tsx +++ b/src/components/tasks/TaskDropDown.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react'; import { BACKEND_TASK_STATUS } from '@/constants/task-status'; import { beautifyStatus } from './card/TaskStatusEditMode'; +import styles from '@/components/tasks/card/card.module.scss'; import { MSG_ON_0_PROGRESS, MSG_ON_100_PROGRESS } from '@/constants/constants'; import TaskDropDownModel from './TaskDropDownModel'; @@ -102,6 +103,40 @@ export default function TaskDropDown({ onChange(payload); setMessage(''); }; + if (isDevMode) { + return ( + <> + + + + ); + } return ( <>