Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed the completed status #1214

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions __tests__/Unit/Components/Tasks/TaskDropDown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<TaskDropDown
isDevMode={true}
oldProgress={oldProgress}
oldStatus={oldStatus}
onChange={onChange}
/>
);
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;
Expand Down
9 changes: 7 additions & 2 deletions __tests__/Unit/Components/Tasks/TaskStatusEditMode.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
5 changes: 4 additions & 1 deletion src/components/taskDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type Props = {
};
const TaskDetails: FC<Props> = ({ taskID }) => {
const router = useRouter();
const { dev } = router.query;
const isDevMode = dev === 'true';

const { isUserAuthorized } = useUserData();

Expand Down Expand Up @@ -325,7 +327,8 @@ const TaskDetails: FC<Props> = ({ taskID }) => {
<Details
detailType={'Status'}
value={beautifyStatus(
taskDetailsData?.status
taskDetailsData?.status,
isDevMode
)}
/>
<Details
Expand Down
11 changes: 9 additions & 2 deletions src/components/tasks/TaskDropDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export default function TaskDropDown({
newProgress: oldProgress,
});
const [message, setMessage] = useState('');
if (isDevMode && oldStatus === BACKEND_TASK_STATUS.COMPLETED) {
BACKEND_TASK_STATUS.DONE = BACKEND_TASK_STATUS.COMPLETED;
}
const taskStatus = Object.entries(BACKEND_TASK_STATUS).filter(
([key]) =>
!(isDevMode && key === 'COMPLETED') &&
Expand Down Expand Up @@ -110,8 +113,12 @@ export default function TaskDropDown({
value={newStatus}
>
{taskStatus.map(([name, status]) => (
<option key={status} value={status}>
{beautifyStatus(name)}
<option
data-testid={`task-status-${name}`}
key={status}
value={status}
>
{beautifyStatus(name, isDevMode)}
</option>
))}
</select>
Expand Down
13 changes: 12 additions & 1 deletion src/components/tasks/card/TaskStatusEditMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
10 changes: 3 additions & 7 deletions src/components/tasks/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -584,11 +584,7 @@ const Card: FC<CardProps> = ({
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)}
</p>
</div>
)}
Expand Down
7 changes: 7 additions & 0 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
Loading