Skip to content

Commit

Permalink
Merge branch 'develop' into modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajeyakrishna-k authored Oct 17, 2023
2 parents 7b4234e + 51e8c73 commit d6be303
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 123 deletions.
70 changes: 70 additions & 0 deletions __mocks__/handlers/idle-users.handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { rest } from 'msw';
const URL = process.env.NEXT_PUBLIC_BASE_URL;

const idleUsersHandler = [
rest.get(`${URL}/users/search?state=IDLE`, (_, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
message: 'Users found successfully!',
users: [
{
id: '26gZFJaXRfd8ghb3p0at',
discordId: '759647978121068544',
last_name: 'reddy',
first_name: 'chandra',
updated_at: 1695404825067,
username: 'chandra',
picture: {
url: 'https://res.cloudinary.com/realdevsquad/image/upload/v1689296550/profile/It0BbP0M2Wh8vdWUmMJB/a4j7tbh4g5ccbfepss88.jpg',
},
roles: {
archived: false,
in_discord: true,
member: false,
},
},
{
id: '2iaxlIok0itcIhD0zlsT',
discordId: '824562502310035487',
last_name: 'joy',
first_name: 'khushi',
roles: {
archived: false,
},
updated_at: 1695404825078,
username: 'khushi',
},
{
id: '3KeWfLRLN98L0QGv0hdL',
discordId: '619787720713175040',
roles: {
archived: false,
},
last_name: 'b',
first_name: 'pronoy',
updated_at: 1695404825079,
username: 'pronoy',
},
],
count: 3,
})
);
}),
];

export const failedIdleUsersHandler = rest.get(
`${URL}/users/search?state=IDLE`,
(_, res, ctx) => {
return res(
ctx.status(500),
ctx.json({
statusCode: 500,
error: 'Internal Server Error',
message: 'An internal server error occurred',
})
);
}
);

export default idleUsersHandler;
67 changes: 0 additions & 67 deletions __mocks__/handlers/members.handler.js

This file was deleted.

6 changes: 2 additions & 4 deletions __tests__/Unit/Components/Tasks/TaskDependency.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ describe('TaskDependency', () => {
isEditing={true}
setEditedTaskDetails={setEditedTaskDetails}
/>
</Provider>,
{ query: { dev: 'true' } }
</Provider>
);
const checkboxes = container.querySelectorAll('input[type="checkbox"]');
const firstCheckbox = checkboxes[0] as HTMLInputElement;
Expand All @@ -68,8 +67,7 @@ describe('TaskDependency', () => {
isEditing={true}
setEditedTaskDetails={setEditedTaskDetails}
/>
</Provider>,
{ query: { dev: 'true' } }
</Provider>
);
const loadingText = await waitFor(() => getByText('Loading...'));
expect(loadingText).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { setupServer } from 'msw/node';
import handlers, {
failedIdleMembersHandler,
} from '../../../__mocks__/handlers/members.handler.js';
failedIdleUsersHandler,
} from '../../../__mocks__/handlers/idle-users.handler.js';

import { PropsWithChildren } from 'react';
import { act, renderHook } from '@testing-library/react-hooks';
import { Provider } from 'react-redux';
import { store } from '@/app/store';
import { useGetIdleMembersQuery } from '@/app/services/membersApi';
import { useGetIdleUsersQuery } from '@/app/services/idleUsersApi';

const server = setupServer(...handlers);

Expand All @@ -23,10 +23,10 @@ function Wrapper({
return <Provider store={store()}>{children}</Provider>;
}

describe('useGetIdleMembersQuery', () => {
test('returns idle members', async () => {
describe('useGetIdleUsersQuery', () => {
test('returns idle users', async () => {
const { result, waitForNextUpdate } = renderHook(
() => useGetIdleMembersQuery(),
() => useGetIdleUsersQuery(),
{
wrapper: Wrapper,
}
Expand All @@ -46,9 +46,9 @@ describe('useGetIdleMembersQuery', () => {
});

test('checks for error response', async () => {
server.use(failedIdleMembersHandler);
server.use(failedIdleUsersHandler);
const { result, waitForNextUpdate } = renderHook(
() => useGetIdleMembersQuery(),
() => useGetIdleUsersQuery(),
{
wrapper: Wrapper,
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const api = createApi({
'Tags',
'Levels',
'Challenges',
'Idle_Members',
'Idle_Users',
'Progress_Details',
'User_Standup',
'TASK_REQUEST',
Expand Down
20 changes: 20 additions & 0 deletions src/app/services/idleUsersApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { USERS_IDLE } from '@/constants/url';
import { api } from './api';
import { UserResponseData } from '@/types/AvailabilityPanel';
type IdleUsersResponse = { users: UserResponseData[] };

export const idleUsersApi = api.injectEndpoints({
endpoints: (build) => ({
getIdleUsers: build.query<string[], void>({
query: () => USERS_IDLE,
providesTags: ['Idle_Users'],
transformResponse: (response: IdleUsersResponse) => {
const IdleUsers = response.users.map((user) => user.username);
IdleUsers.sort();
return IdleUsers;
},
}),
}),
});

export const { useGetIdleUsersQuery } = idleUsersApi;
22 changes: 0 additions & 22 deletions src/app/services/membersApi.ts

This file was deleted.

32 changes: 14 additions & 18 deletions src/components/taskDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,20 @@ const TaskDetails: FC<Props> = ({ taskID }) => {
</div>
</TaskContainer>
<Progress taskProgress={taskProgress} />
{isDevModeEnabled && (
<>
<TaskContainer
title="Task Dependencies"
hasImg={false}
>
<TaskDependency
taskDependencyIds={
taskDependencyIds
}
isEditing={isEditing}
setEditedTaskDetails={
setEditedTaskDetails
}
/>
</TaskContainer>
</>
)}
<>
<TaskContainer
title="Task Dependencies"
hasImg={false}
>
<TaskDependency
taskDependencyIds={taskDependencyIds}
isEditing={isEditing}
setEditedTaskDetails={
setEditedTaskDetails
}
/>
</TaskContainer>
</>
</section>

<section className={classNames.rightContainer}>
Expand Down
2 changes: 1 addition & 1 deletion src/constants/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const LOGIN_URL = `https://github.com/login/oauth/authorize?client_id=23c
export const MEMBERS_URL = 'https://members.realdevsquad.com';
export const CHALLENGES_URL = `${BASE_URL}/challenges`;
export const USER_SELF = `${BASE_URL}/users/self`;
export const MEMBERS_IDLE = `${BASE_URL}/members/idle`;
export const USERS_IDLE = `${BASE_URL}/users/search?state=IDLE`;
export const DEFAULT_AVATAR = '/Avatar.png';
export const RDS_LOGO = '/RDSLogo.png';
export const GITHUB_LOGO = '/github-white.png';
Expand Down
4 changes: 2 additions & 2 deletions src/pages/availability-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import updateTasksStatus from '@/helperFunctions/updateTasksStatus';
import { AVAILABLE } from '@/constants/task-status';
import { FEATURE } from '@/constants/task-type';
import { BASE_URL } from '@/constants/url';
import { useGetIdleMembersQuery } from '@/app/services/membersApi';
import { useGetIdleUsersQuery } from '@/app/services/idleUsersApi';

const AvailabilityPanel: FC = () => {
const [unAssignedTasks, setUnAssignedTasks] = useState<task[]>([]);
Expand All @@ -21,7 +21,7 @@ const AvailabilityPanel: FC = () => {
isError: isIdleMembersError,
isLoading: isIdleMemberLoading,
refetch: refreshMemberList,
} = useGetIdleMembersQuery();
} = useGetIdleUsersQuery();

useEffect(() => {
const fetchTasks = async () => {
Expand Down
30 changes: 30 additions & 0 deletions src/types/AvailabilityPanel.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export interface UserResponseData {
id: string;
incompleteUserDetails: boolean;
website: string;
discordJoinedAt: string;
discordId: string;
roles: {
archived: boolean;
in_discord: boolean;
member: boolean;
};
last_name: string;
linkedin_id: string;
yoe: number;
picture: {
publicId: string;
url: string;
};
github_created_at: number;
github_display_name: string;
github_id: string;
company: string;
designation: string;
twitter_id: string;
first_name: string;
status: string;
username: string;
updated_at: number;
created_at: number;
}

0 comments on commit d6be303

Please sign in to comment.