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

Moving back Done status under dev flag #1254

Merged
merged 5 commits into from
Sep 20, 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
162 changes: 104 additions & 58 deletions __mocks__/handlers/task-details.handler.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,119 @@
import { rest } from 'msw';
const URL = process.env.NEXT_PUBLIC_BASE_URL;

const taskDetailsRes = {
'12345': {
message: 'task returned successfully',
taskData: {
id: '12345',
isNoteworthy: true,
lossRate: {
dinero: 0,
neelam: 0,
},
purpose: 'This is a sample description',
endsOn: 1618790410,
title: 'test 1 for drag and drop',
status: 'COMPLETED',
assignee: 'ankur',
links: [],
dependsOn: [],
percentCompleted: 0,
type: 'feature',
priority: 'high',
featureUrl: 'https://www.sampleUrl.com',
startedOn: 1617062400,
completionAward: {
neelam: 0,
dinero: 110,
},
github: {
issue: {
html_url:
'https://github.com/sample-org/sample-repo/issues/000',
},
},
},
},
'6KhcLU3yr45dzjQIVm0J': {
message: 'task returned successfully',
taskData: {
id: '6KhcLU3yr45dzjQIVm0J',
isNoteworthy: true,
lossRate: {
dinero: 0,
neelam: 0,
},
purpose: 'This is a sample description',
endsOn: 1618790410,
title: 'test 1 for drag and drop',
status: 'assigned',
assignee: 'ankur',
links: [],
dependsOn: [],
percentCompleted: 0,
type: 'feature',
priority: 'high',
featureUrl: 'https://www.sampleUrl.com',
startedOn: 1617062400,
completionAward: {
neelam: 0,
dinero: 110,
},
github: {
issue: {
html_url:
'https://github.com/sample-org/sample-repo/issues/000',
},
},
},
},
'6KhcLU3yr45dzjQIVm0k': {
message: 'task returned successfully',
taskData: {
id: '6KhcLU3yr45dzjQIVm0k',
isNoteworthy: true,
lossRate: {
dinero: 0,
neelam: 0,
},
endsOn: 1618790410,
title: 'test 1 for drag and drop',
status: 'assigned',
assignee: 'ankur',
links: [],
dependsOn: [],
percentCompleted: 0,
type: 'feature',
priority: 'high',
featureUrl: 'https://www.sampleUrl.com',
startedOn: 1617062400,
completionAward: {
neelam: 0,
dinero: 110,
},
},
},
};

const taskDetailsHandler = [
rest.get(`${URL}/tasks/12345/details`, (_, res, ctx) => {
try {
return res(ctx.status(200), ctx.json(taskDetailsRes['12345']));
} catch (error) {
return res(ctx.status(500), ctx.json({ error }));
}
}),
rest.get(`${URL}/tasks/6KhcLU3yr45dzjQIVm0J/details`, (_, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
message: 'task returned successfully',
taskData: {
id: '6KhcLU3yr45dzjQIVm0J',
isNoteworthy: true,
lossRate: {
dinero: 0,
neelam: 0,
},
purpose: 'This is a sample description',
endsOn: 1618790410,
title: 'test 1 for drag and drop',
status: 'assigned',
assignee: 'ankur',
links: ['null'],
dependsOn: ['null'],
percentCompleted: 0,
type: 'feature',
priority: 'high',
featureUrl: 'https://www.sampleUrl.com',
startedOn: 1617062400,
completionAward: {
neelam: 0,
dinero: 110,
},
github: {
issue: {
html_url:'https://github.com/sample-org/sample-repo/issues/000'
}
}
},
})
ctx.json(taskDetailsRes['6KhcLU3yr45dzjQIVm0J'])
);
}),
rest.get(`${URL}/tasks/6KhcLU3yr45dzjQIVm0k/details`, (_, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
message: 'task returned successfully',
taskData: {
id: '6KhcLU3yr45dzjQIVm0k',
isNoteworthy: true,
lossRate: {
dinero: 0,
neelam: 0,
},
endsOn: 1618790410,
title: 'test 1 for drag and drop',
status: 'assigned',
assignee: 'ankur',
links: ['null'],
dependsOn: ['null'],
percentCompleted: 0,
type: 'feature',
priority: 'high',
featureUrl: 'https://www.sampleUrl.com',
startedOn: 1617062400,
completionAward: {
neelam: 0,
dinero: 110,
},
},
})
ctx.json(taskDetailsRes['6KhcLU3yr45dzjQIVm0k'])
);
}),
rest.patch(`${URL}/tasks/:taskId`, (_, res, ctx) => {
Expand Down
27 changes: 13 additions & 14 deletions __tests__/Unit/Components/Tabs/Tab.test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import Tabs from '@/components/Tabs';
import { fireEvent, render, screen } from '@testing-library/react';
import { fireEvent, screen } from '@testing-library/react';
import {
Tab,
TABS,
depreciatedTaskStatus,
newTaskStatus,
} from '@/interfaces/task.type';
import { COMPLETED, DONE, AVAILABLE, UNASSIGNED } from '@/constants/constants';
import { AVAILABLE, UNASSIGNED } from '@/constants/constants';
import { renderWithRouter } from '@/test_utils/createMockRouter';

function changeName(name: string) {
if (name === COMPLETED) {
return DONE;
} else if (name === AVAILABLE) {
if (name === AVAILABLE) {
return UNASSIGNED;
} else {
return name.split('_').join(' ');
Expand All @@ -22,7 +21,7 @@ describe('Tabs Component', () => {
const onSelectMock = jest.fn();

it('should render all the buttons', () => {
render(
renderWithRouter(
<Tabs
tabs={TABS}
activeTab={Tab.ASSIGNED}
Expand All @@ -38,7 +37,7 @@ describe('Tabs Component', () => {
});

it('should render all the buttons when dev is true', () => {
render(
renderWithRouter(
<Tabs
dev={true}
tabs={TABS}
Expand All @@ -53,7 +52,7 @@ describe('Tabs Component', () => {
});

it('check if selectTab() is called with right key', () => {
render(
renderWithRouter(
<Tabs
tabs={TABS}
activeTab={Tab.ASSIGNED}
Expand All @@ -66,7 +65,7 @@ describe('Tabs Component', () => {
});

it('check if selectTab() is called with right key when dev is true', () => {
render(
renderWithRouter(
<Tabs
dev={true}
tabs={TABS}
Expand All @@ -82,19 +81,19 @@ describe('Tabs Component', () => {
});

it('Check if correct button is selected', () => {
render(
renderWithRouter(
<Tabs
tabs={TABS}
activeTab={Tab.COMPLETED}
onSelect={onSelectMock}
/>
);
const completedBtn = screen.getByRole('button', { name: /DONE/i });
const completedBtn = screen.getByRole('button', { name: /COMPLETED/i });
expect(completedBtn).toHaveClass('active');
});

it('Check if correct button is selected when dev is true', () => {
render(
renderWithRouter(
<Tabs
dev={true}
tabs={TABS}
Expand All @@ -109,7 +108,7 @@ describe('Tabs Component', () => {
});

it('should render all tabs passed with correct text', () => {
render(
renderWithRouter(
<Tabs
tabs={TABS}
activeTab={Tab.ASSIGNED}
Expand All @@ -126,7 +125,7 @@ describe('Tabs Component', () => {
});

it('should render all tabs passed with correct text when dev is true', () => {
render(
renderWithRouter(
<Tabs
dev={true}
tabs={TABS}
Expand Down
Loading
Loading