-
Notifications
You must be signed in to change notification settings - Fork 152
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
AssignTask to rtk #699
AssignTask to rtk #699
Changes from 15 commits
a7d13bd
6a23ab2
820f2a3
62a0210
95aeb95
260ca5e
228625f
3f9e248
4123e2b
667a696
6c704e0
73ab104
de63d38
dc98596
9ef336b
b8af4c1
c4839d7
5e74d39
9e51022
e7690b8
97c88da
24f2f0a
403cc80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { rest } from 'msw'; | ||
const URL = process.env.NEXT_PUBLIC_BASE_URL; | ||
|
||
export const userSelfData = { | ||
id: 'aTOG168A86JXY5wVosJx', | ||
github_display_name: 'Mahima Khandelwal', | ||
github_id: 'Maheima', | ||
roles: { | ||
member: true, | ||
archived: false, | ||
super_user: false, | ||
}, | ||
last_name: 'Khandelwal', | ||
username: 'mahima', | ||
incompleteUserDetails: false, | ||
profileStatus: 'BLOCKED', | ||
picture: { | ||
publicId: 'profile/aTOG168A86JXY5wVosJx/fj2c46kpmpy3gi8tl63s', | ||
url: 'https://res.cloudinary.com/realdevsquad/image/upload/v1674639637/profile/aTOG168A86JXY5wVosJx/fj2c46kpmpy3gi8tl63s.jpg' | ||
}, | ||
status: 'active', | ||
first_name: 'Mahima', | ||
profileURL: 'https://mahima-profile-service.onrender.com' | ||
Comment on lines
+5
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use dummy data for test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That data is not created by me i refactored it tor DRY them up but now i replaced my tests with duplicate data in path __ tests __/Unit/hooks/tasksApi.test.tsx so no more tests depending on that data in my tests, the file is renamed from a js file to ts file https://github.com/Real-Dev-Squad/website-status/pull/699/files#diff-6e68b838da6a1b199fcb4ef878d985dd3e29de628b6bbbcdaca7cf99de329d3e |
||
}; | ||
|
||
export const selfHandlerFn = (status: number, response: object | null) => { | ||
return rest.get(`${URL}/users/self`, (_, res, ctx) => { | ||
return res( | ||
ctx.delay(500), | ||
ctx.status(status), | ||
ctx.json(response) | ||
); | ||
}); | ||
}; | ||
|
||
const selfHandler = [ | ||
selfHandlerFn(200, userSelfData) | ||
]; | ||
|
||
export default selfHandler; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import DragDropContextWrapper from '@/components/availability-panel/drag-drop-context'; | ||
import { tasks, TASK } from '../../../../../__mocks__/db/tasks'; | ||
import { renderWithProviders } from '../../../../../src/test-utils/renderWithProvider'; | ||
|
||
export const urlPattern = | ||
/(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z]{2,}(\.[a-zA-Z]{2,})(\.[a-zA-Z]{2,})?\/[a-zA-Z0-9]{2,}|((https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z]{2,}(\.[a-zA-Z]{2,})(\.[a-zA-Z]{2,})?)|(https:\/\/www\.|http:\/\/www\.|https:\/\/|http:\/\/)?[a-zA-Z0-9]{2,}\.[a-zA-Z0-9]{2,}\.[a-zA-Z0-9]{2,}(\.[a-zA-Z0-9]{2,})?/g; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What pattern are we matching here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
i changed that pattern with a simple relative url pattern please check it |
||
export const idleMemberFallbackText = 'No idle members found'; | ||
export const tasksFallbackText = 'No task found'; | ||
|
||
describe('DrogDropContextWrapper Component', () => { | ||
describe('should show placeholder', () => { | ||
test('when there is no task & members', () => { | ||
const { queryAllByAltText, getByText } = renderWithProviders( | ||
<DragDropContextWrapper | ||
idleMembers={[]} | ||
unAssignedTasks={[]} | ||
refreshData={null} | ||
/> | ||
); | ||
getByText(idleMemberFallbackText); | ||
getByText(tasksFallbackText); | ||
const ghostNodes = queryAllByAltText('ghost'); | ||
expect(ghostNodes).toHaveLength(2); | ||
expect(ghostNodes[0]).toHaveAttribute( | ||
'src', | ||
expect.stringMatching(urlPattern) | ||
); | ||
expect(ghostNodes[1]).toHaveAttribute( | ||
'src', | ||
expect.stringMatching(urlPattern) | ||
); | ||
}); | ||
|
||
test('when there is no task', () => { | ||
const { getByAltText, getByText } = renderWithProviders( | ||
<DragDropContextWrapper | ||
idleMembers={['Akash Shukla']} | ||
unAssignedTasks={[]} | ||
refreshData={null} | ||
/> | ||
); | ||
expect(getByText(tasksFallbackText)).toBeVisible(); | ||
expect(getByAltText('ghost')).toHaveAttribute( | ||
'src', | ||
expect.stringMatching(urlPattern) | ||
); | ||
}); | ||
|
||
test('when there is no idleMemeber', () => { | ||
const { getByAltText, getByText } = renderWithProviders( | ||
<DragDropContextWrapper | ||
idleMembers={[]} | ||
unAssignedTasks={tasks} | ||
refreshData={null} | ||
/> | ||
); | ||
expect(getByText(idleMemberFallbackText)).toBeVisible(); | ||
expect(getByAltText('ghost')).toHaveAttribute( | ||
'src', | ||
expect.stringMatching(urlPattern) | ||
); | ||
}); | ||
}); | ||
|
||
test('should render all the tasks & members as expected', () => { | ||
const { queryAllByText, getByText } = renderWithProviders( | ||
<DragDropContextWrapper | ||
idleMembers={['Akash Shukla']} | ||
unAssignedTasks={tasks} | ||
refreshData={null} | ||
/> | ||
); | ||
const unAssignedTaskNodes = queryAllByText(TASK.title); | ||
expect(unAssignedTaskNodes).toHaveLength(10); | ||
expect(unAssignedTaskNodes[0]).toBeVisible(); | ||
expect(unAssignedTaskNodes[6]).toBeVisible(); | ||
getByText('Akash Shukla'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didn't understand why is this written at the end. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That line is to test if the member is in document or not. It will throw an error if the member is not in document or if that same member is in document for more than one time, resulting in test failure AFAIK I would also add toBeVisible in my next commit so that it assures that component is rendering member |
||
}); | ||
|
||
test('should have tasks & members items draggable', () => { | ||
const { container } = renderWithProviders( | ||
<DragDropContextWrapper | ||
idleMembers={['Akash Shukla']} | ||
unAssignedTasks={tasks} | ||
refreshData={null} | ||
/> | ||
); | ||
const taskList = container.querySelectorAll('.memberCard'); | ||
expect(taskList[0].getAttribute('draggable')).toBeTruthy(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we adding this rule here?
We should follow one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i doesn't add it to eslint, eslint is trying to escape character & prettier is trying to avoid escaping characters, resulting in git push failure when i try to push changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, we should fix the prettier and eslint configurations, rather than just adding some rule to make precommits pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i searched a lot to fix that issue but not found any solution for it, so i reverted my code to use defalut lint rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you face an issue that is not linked to your PR, please create a separate issue ticket and PR for it