Skip to content

Commit

Permalink
Merge branch 'develop' into feature/update-progress-query-param
Browse files Browse the repository at this point in the history
  • Loading branch information
AnujChhikara authored Jan 7, 2025
2 parents 9d377f7 + 00519da commit 755a8fd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
58 changes: 31 additions & 27 deletions __mocks__/handlers/self.handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@ import { rest } from 'msw';
const URL = process.env.NEXT_PUBLIC_BASE_URL;

const selfHandler = [
rest.get(`${URL}/users/self`, (_, res, ctx) => {
return res(
ctx.status(200),
ctx.json({
id: 'aTOG168A86JXY5wVosJx',
github_display_name: 'Mahima Khandelwal',
github_id: 'Maheima',
roles: {
member: true,
archived: 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'
})
);
rest.get(`${URL}/users`, (req, res, ctx) => {
const profileParam = req.url.searchParams.get('profile');
if (profileParam === 'true') {
return res(
ctx.status(200),
ctx.json({
id: 'aTOG168A86JXY5wVosJx',
github_display_name: 'Mahima Khandelwal',
github_id: 'Maheima',
roles: {
member: true,
archived: 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'
})
);
}
}),
];

export const superUserSelfHandler = rest.get(
`${URL}/users/self`,
(_, res, ctx) => {
export const superUserSelfHandler = rest.get(`${URL}/users`, (req, res, ctx) => {
const profileParam = req.url.searchParams.get('profile');
if (profileParam === 'true') {
return res(
ctx.status(200),
ctx.json({
Expand All @@ -57,6 +60,7 @@ export const superUserSelfHandler = rest.get(
})
);
}
}
);

export default selfHandler;
2 changes: 1 addition & 1 deletion __tests__/Unit/Components/Navbar/Navbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Navbar', () => {
test('shows "Sign In With Github" button when not logged in', async () => {
server.use(
rest.get(
`${process.env.NEXT_PUBLIC_BASE_URL}/users/self`,
`${process.env.NEXT_PUBLIC_BASE_URL}/users?profile=true`,
(_, res, ctx) => {
return res(
ctx.status(401),
Expand Down
2 changes: 1 addition & 1 deletion src/constants/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const STATUS_URL = 'https://status.realdevsquad.com';
export const LOGIN_URL = `https://github.com/login/oauth/authorize?client_id=23c78f66ab7964e5ef97&state=${STATUS_URL}`;
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 USER_SELF = `${BASE_URL}/users?profile=true`;
export const USERS_IDLE = `${BASE_URL}/users/search?state=IDLE`;
export const DEFAULT_AVATAR = '/Avatar.png';
export const RDS_LOGO = '/RDSLogo.png';
Expand Down

0 comments on commit 755a8fd

Please sign in to comment.