From 8ee1b7fa403d50f7f8dc17d426e6dc976aa56ca5 Mon Sep 17 00:00:00 2001 From: Hariom Vashista Date: Sat, 28 Dec 2024 20:06:09 +0530 Subject: [PATCH] Updated deprecated API endpoint users/self to users?profile=true (#931) --- __tests__/applications/applications.test.js | 2 +- __tests__/groups/group.test.js | 2 +- __tests__/home/home.test.js | 2 +- __tests__/task-requests/task-requestDetails.test.js | 2 +- __tests__/user-details/task-duedate-hover.test.js | 2 +- .../users/onboarding-31-days-multiple-selections.test.js | 2 +- __tests__/users/onboarding31days.test.js | 2 +- admin-panel/index.js | 2 +- applications/utils.js | 2 +- groups/utils.js | 2 +- identity-service-logs/utils.js | 2 +- mock-data/taskRequests/index.js | 3 ++- profile/utils.js | 2 +- taskEvents/utils.js | 2 +- utils.js | 4 ++-- 15 files changed, 17 insertions(+), 16 deletions(-) diff --git a/__tests__/applications/applications.test.js b/__tests__/applications/applications.test.js index 2d805e3c..56ee4701 100644 --- a/__tests__/applications/applications.test.js +++ b/__tests__/applications/applications.test.js @@ -60,7 +60,7 @@ describe('Applications page', () => { 'Access-Control-Allow-Headers': 'Content-Type, Authorization', }, }); - } else if (url === `${STAGING_API_URL}/users/self`) { + } else if (url === `${STAGING_API_URL}/users?profile=true`) { interceptedRequest.respond({ status: 200, contentType: 'application/json', diff --git a/__tests__/groups/group.test.js b/__tests__/groups/group.test.js index be21648d..f0a108b6 100644 --- a/__tests__/groups/group.test.js +++ b/__tests__/groups/group.test.js @@ -51,7 +51,7 @@ describe('Discord Groups Page', () => { }, body: JSON.stringify(allUsersData), }); - } else if (url === `${STAGING_API_URL}/users/self`) { + } else if (url === `${STAGING_API_URL}/users?profile=true`) { interceptedRequest.respond({ status: 200, contentType: 'application/json', diff --git a/__tests__/home/home.test.js b/__tests__/home/home.test.js index c1582559..0dfa2949 100644 --- a/__tests__/home/home.test.js +++ b/__tests__/home/home.test.js @@ -21,7 +21,7 @@ describe('Home Page', () => { await page.setRequestInterception(true); page.on('request', (interceptedRequest) => { const url = interceptedRequest.url(); - if (url === `${STAGING_API_URL}/users/self`) { + if (url === `${STAGING_API_URL}/users?profile=true`) { interceptedRequest.respond({ status: 200, contentType: 'application/json', diff --git a/__tests__/task-requests/task-requestDetails.test.js b/__tests__/task-requests/task-requestDetails.test.js index 7a49605d..ca33d925 100644 --- a/__tests__/task-requests/task-requestDetails.test.js +++ b/__tests__/task-requests/task-requestDetails.test.js @@ -25,7 +25,7 @@ describe('Request container for non-super users', () => { await page.setRequestInterception(true); page.on('request', (interceptedRequest) => { const url = interceptedRequest.url(); - if (url == `${STAGING_API_URL}/users/self`) { + if (url == `${STAGING_API_URL}/users?profile=true`) { interceptedRequest.respond({ ...defaultMockResponseHeaders, body: JSON.stringify(user), diff --git a/__tests__/user-details/task-duedate-hover.test.js b/__tests__/user-details/task-duedate-hover.test.js index fc041c4c..1fc4d345 100644 --- a/__tests__/user-details/task-duedate-hover.test.js +++ b/__tests__/user-details/task-duedate-hover.test.js @@ -45,7 +45,7 @@ describe('Tasks On User Management Page', () => { body: JSON.stringify(userDetails), }); } else if ( - url === `${STAGING_API_URL}/users/self` || + url === `${STAGING_API_URL}/users?profile=true` || url === `${STAGING_API_URL}/users/ankush` ) { interceptedRequest.respond({ diff --git a/__tests__/users/onboarding-31-days-multiple-selections.test.js b/__tests__/users/onboarding-31-days-multiple-selections.test.js index ddac366a..ab866dc1 100644 --- a/__tests__/users/onboarding-31-days-multiple-selections.test.js +++ b/__tests__/users/onboarding-31-days-multiple-selections.test.js @@ -33,7 +33,7 @@ describe('Tests the "Onboarding > 31 Days" Filter', () => { }, body: JSON.stringify(userDetailsApi), }); - } else if (url === `${STAGING_API_URL}/users/self`) { + } else if (url === `${STAGING_API_URL}/users?profile=true`) { // When we encounter the respective api call we respond with the below response interceptedRequest.respond({ status: 200, diff --git a/__tests__/users/onboarding31days.test.js b/__tests__/users/onboarding31days.test.js index 80bb9497..84893769 100644 --- a/__tests__/users/onboarding31days.test.js +++ b/__tests__/users/onboarding31days.test.js @@ -34,7 +34,7 @@ describe('Tests the "Onboarding > 31 Days" Filter', () => { }, body: JSON.stringify(userDetailsApi), }); - } else if (url === `${STAGING_API_URL}/users/self`) { + } else if (url === `${STAGING_API_URL}/users?profile=true`) { // When we encounter the respective api call we respond with the below response interceptedRequest.respond({ status: 200, diff --git a/admin-panel/index.js b/admin-panel/index.js index b0f28001..885f1c2d 100644 --- a/admin-panel/index.js +++ b/admin-panel/index.js @@ -5,7 +5,7 @@ const loading = document.getElementById('loading'); const selectElement = document.getElementById('select-tags'); (async function setAuth() { try { - const res = await fetch(`${API_BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/applications/utils.js b/applications/utils.js index d5541409..173e6af3 100644 --- a/applications/utils.js +++ b/applications/utils.js @@ -68,7 +68,7 @@ async function getApplicationById(applicationId) { async function getIsSuperUser() { try { - const res = await fetch(`${BASE_URL}/users/self`, { + const res = await fetch(`${BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/groups/utils.js b/groups/utils.js index 3ad47aaf..f97112f4 100644 --- a/groups/utils.js +++ b/groups/utils.js @@ -17,7 +17,7 @@ async function getMembers() { } async function getUserSelf() { try { - const res = await fetch(`${BASE_URL}/users/self`, { + const res = await fetch(`${BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/identity-service-logs/utils.js b/identity-service-logs/utils.js index bcf6c8b3..8b81f33f 100644 --- a/identity-service-logs/utils.js +++ b/identity-service-logs/utils.js @@ -216,7 +216,7 @@ function showToaster(message) { async function getIsSuperUser() { try { - const res = await fetch(`${API_BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/mock-data/taskRequests/index.js b/mock-data/taskRequests/index.js index c17e92ca..63a829e8 100644 --- a/mock-data/taskRequests/index.js +++ b/mock-data/taskRequests/index.js @@ -351,7 +351,8 @@ const defaultMockResponseHeaders = { }; const urlMappings = { - 'https://staging-api.realdevsquad.com/users/self': superUserDetails.user, + 'https://staging-api.realdevsquad.com/users?profile=true': + superUserDetails.user, 'https://api.realdevsquad.com/taskRequests/dM5wwD9QsiTzi7eG7Oq5': individualTaskReqDetail, 'https://api.realdevsquad.com/taskRequests/dM5wwD9QsiTzi7eG7Oq6': diff --git a/profile/utils.js b/profile/utils.js index 08b4c278..411a2a34 100644 --- a/profile/utils.js +++ b/profile/utils.js @@ -318,7 +318,7 @@ function wantedData(data) { } async function getSelfUser() { - const res = await fetch(`${API_BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/taskEvents/utils.js b/taskEvents/utils.js index b10e0e4b..abd081d8 100644 --- a/taskEvents/utils.js +++ b/taskEvents/utils.js @@ -80,7 +80,7 @@ async function getUserData(username) { } async function getSelfDetails() { - const res = await fetch(`${API_BASE_URL}/users/self`, { + const res = await fetch(`${API_BASE_URL}/users?profile=true`, { method: 'GET', credentials: 'include', headers: { diff --git a/utils.js b/utils.js index 246077da..e5466e42 100644 --- a/utils.js +++ b/utils.js @@ -4,7 +4,7 @@ function goToAuthPage() { window.open(authUrl, '_self'); } -async function getSelfUser(endpoint = '/users/self') { +async function getSelfUser(endpoint = '/users?profile=true') { try { const res = await fetch(`${API_BASE_URL}${endpoint}`, { method: 'GET', @@ -13,7 +13,7 @@ async function getSelfUser(endpoint = '/users/self') { 'Content-type': 'application/json', }, }); - if (endpoint === '/users/self') { + if (endpoint === '/users?profile=true') { const self_user = await res.json(); if (res.status === 200) { return self_user?.user || self_user;