Skip to content
Closed
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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this as this was a flaky test which was failing in CI/CD so fixed it.

Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,11 @@ describe('ExtensionStatusModal Component', () => {
});

test('should test formatToRelativeTime function', () => {
jest.useFakeTimers().setSystemTime(new Date('2025-01-01T00:00:00Z'));
const timestamp = 1640995200;
const result = formatToRelativeTime(timestamp);
expect(result).toBe('3 years ago');
jest.useRealTimers();
});

test('should open extension request form when request extension button is clicked', () => {
Expand Down
14 changes: 7 additions & 7 deletions __tests__/Unit/Components/Tasks/TaskStatusDropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('TaskStatusDropdown', () => {
expect(msgTag).toBeInTheDocument();
expect(msgTag).toHaveTextContent(msg);
});
it('should display model informing user that proceeding further will make progress 0%, on task status change from needs review to in progress', () => {
it('should display model informing user that proceeding further will make progress 0%, on task status change from needs review to assigned', () => {
const oldProgress = 100;
const oldStatus = BACKEND_TASK_STATUS.NEEDS_REVIEW;

Expand All @@ -56,14 +56,14 @@ describe('TaskStatusDropdown', () => {

const msg = `The progress of current task is ${oldProgress}%. ${MSG_ON_0_PROGRESS}`;
fireEvent.change(screen.getByTestId('task-status'), {
target: { value: BACKEND_TASK_STATUS.IN_PROGRESS },
target: { value: BACKEND_TASK_STATUS.ASSIGNED },
});

const msgTag = screen.getByTestId('msg');
expect(msgTag).toBeInTheDocument();
expect(msgTag).toHaveTextContent(msg);
});
it('should send changed status and progress if user click the proceed button of the model, on task status change from needs review to in progress', () => {
it('should send changed status and progress if user click the proceed button of the model, on task status change from needs review to assigned', () => {
const oldProgress = 100;
const oldStatus = BACKEND_TASK_STATUS.NEEDS_REVIEW;

Expand All @@ -77,16 +77,16 @@ describe('TaskStatusDropdown', () => {
);

fireEvent.change(screen.getByTestId('task-status'), {
target: { value: BACKEND_TASK_STATUS.IN_PROGRESS },
target: { value: BACKEND_TASK_STATUS.ASSIGNED },
});
fireEvent.click(screen.getByTestId('proceed'));
expect(onChange).toHaveBeenCalledWith({
newStatus: BACKEND_TASK_STATUS.IN_PROGRESS,
newStatus: BACKEND_TASK_STATUS.ASSIGNED,
newProgress: 0,
});
expect(onChange).toHaveBeenCalledTimes(1);
});
it('should send reset status and progress if user click the cancel button of the model, on task status change from needs review to in progress', () => {
it('should send reset status and progress if user click the cancel button of the model, on task status change from needs review to assigned', () => {
const oldProgress = 100;
const oldStatus = BACKEND_TASK_STATUS.NEEDS_REVIEW;

Expand All @@ -100,7 +100,7 @@ describe('TaskStatusDropdown', () => {
);

fireEvent.change(screen.getByTestId('task-status'), {
target: { value: BACKEND_TASK_STATUS.IN_PROGRESS },
target: { value: BACKEND_TASK_STATUS.ASSIGNED },
});
fireEvent.click(screen.getByTestId('cancel'));
expect(onChange).toHaveBeenCalledTimes(0);
Expand Down
7 changes: 2 additions & 5 deletions src/components/tasks/TaskStatusDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,10 @@ export function TaskStatusDropdown({
};

const shouldTaskProgressBe0 = (newStatus: string) => {
const isNewStatusInProgress =
newStatus === BACKEND_TASK_STATUS.IN_PROGRESS;
const isNewStatusAssigned = newStatus === BACKEND_TASK_STATUS.ASSIGNED;
const isCurrProgress0 = oldProgress === 0;
return (
isNewStatusInProgress &&
!isCurrentTaskStatusBlock &&
!isCurrProgress0
isNewStatusAssigned && !isCurrentTaskStatusBlock && !isCurrProgress0
);
};

Expand Down