From 7479a1c4d394fa3bcb3847f763dad295cb297010 Mon Sep 17 00:00:00 2001 From: Lakshya Satpal Date: Fri, 8 Dec 2023 15:23:23 +0530 Subject: [PATCH 1/2] requests tests completed 100% --- src/screens/Requests/Requests.test.tsx | 32 ++++++++- src/screens/Requests/Requests.tsx | 2 +- src/screens/Requests/RequestsMocks.ts | 92 ++++++++++++++++++++++++++ 3 files changed, 124 insertions(+), 2 deletions(-) diff --git a/src/screens/Requests/Requests.test.tsx b/src/screens/Requests/Requests.test.tsx index f8247905bc..cc41660601 100644 --- a/src/screens/Requests/Requests.test.tsx +++ b/src/screens/Requests/Requests.test.tsx @@ -13,11 +13,18 @@ import { store } from 'state/store'; import { StaticMockLink } from 'utils/StaticMockLink'; import i18nForTest from 'utils/i18nForTest'; import Requests from './Requests'; -import { EMPTY_ORG_MOCKS, MOCKS, ORG_LIST_MOCK } from './RequestsMocks'; +import { + EMPTY_ORG_MOCKS, + EMPTY_REQUEST_MOCKS, + MOCKS, + ORG_LIST_MOCK, +} from './RequestsMocks'; +import { userInfo } from 'os'; const link = new StaticMockLink(MOCKS, true); const link2 = new StaticMockLink(EMPTY_ORG_MOCKS, true); const link3 = new StaticMockLink(ORG_LIST_MOCK, true); +const link4 = new StaticMockLink(EMPTY_REQUEST_MOCKS, true); async function wait(ms = 100): Promise { await act(() => { @@ -91,6 +98,29 @@ describe('Testing Request screen', () => { await wait(); }); + test('Testing empty user requests', async () => { + render( + + + + + + + + + + ); + + const searchInput = screen.getByTestId('searchByName'); + userEvent.type(searchInput, 'l'); + + const notFoundDiv = await screen.findByTestId('searchAndNotFound'); + + expect(notFoundDiv).toBeInTheDocument(); + + await wait(); + }); + test('Testing accept user functionality', async () => { render( diff --git a/src/screens/Requests/Requests.tsx b/src/screens/Requests/Requests.tsx index b0b0a5f6ad..edb21aaf5b 100644 --- a/src/screens/Requests/Requests.tsx +++ b/src/screens/Requests/Requests.tsx @@ -298,7 +298,7 @@ const Requests = (): JSX.Element => { {isLoading == false && usersData?.users.length === 0 && searchByName.length > 0 ? ( -
+

{t('noResultsFoundFor')} "{searchByName}"

diff --git a/src/screens/Requests/RequestsMocks.ts b/src/screens/Requests/RequestsMocks.ts index a57bff7c83..ec3444b3b5 100644 --- a/src/screens/Requests/RequestsMocks.ts +++ b/src/screens/Requests/RequestsMocks.ts @@ -148,6 +148,98 @@ export const MOCKS = [ }, ]; +export const EMPTY_REQUEST_MOCKS = [ + { + request: { + query: USER_ORGANIZATION_LIST, + variables: { id: localStorage.getItem('id') }, + }, + result: { + data: { + user: { + _id: '123', + userType: 'SUPERADMIN', + firstName: 'John', + lastName: 'Doe', + image: '', + email: 'John_Does_Palasidoes@gmail.com', + adminFor: { + _id: 1, + name: 'Akatsuki', + image: '', + }, + }, + }, + }, + }, + { + request: { + query: USER_LIST_REQUEST, + variables: { + adminApproved: false, + first: 12, + firstName_contains: '', + lastName_contains: '', + skip: 0, + userType: 'ADMIN', + }, + notifyOnNetworkStatusChange: true, + }, + result: { + data: { + users: [], + }, + }, + }, + { + request: { + query: USER_LIST_REQUEST, + variables: { + adminApproved: false, + first: 12, + firstName_contains: 'l', + lastName_contains: '', + skip: 0, + userType: 'ADMIN', + }, + notifyOnNetworkStatusChange: true, + }, + result: { + data: { + users: [], + }, + }, + }, + { + request: { + query: ACCEPT_ADMIN_MUTATION, + variables: { + id: '123', + userType: 'ADMIN', + }, + }, + result: { + data: { + acceptAdmin: true, + }, + }, + }, + { + request: { + query: REJECT_ADMIN_MUTATION, + variables: { + id: '123', + userType: 'ADMIN', + }, + }, + result: { + data: { + rejectAdmin: true, + }, + }, + }, +]; + export const EMPTY_ORG_MOCKS = [ { request: { From aa71203f1a8fec95ac8ada7d079dfadbd20be979 Mon Sep 17 00:00:00 2001 From: Lakshya Satpal Date: Fri, 8 Dec 2023 15:24:29 +0530 Subject: [PATCH 2/2] resolved warning --- src/screens/Requests/Requests.test.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/screens/Requests/Requests.test.tsx b/src/screens/Requests/Requests.test.tsx index cc41660601..4ec0c83069 100644 --- a/src/screens/Requests/Requests.test.tsx +++ b/src/screens/Requests/Requests.test.tsx @@ -19,7 +19,6 @@ import { MOCKS, ORG_LIST_MOCK, } from './RequestsMocks'; -import { userInfo } from 'os'; const link = new StaticMockLink(MOCKS, true); const link2 = new StaticMockLink(EMPTY_ORG_MOCKS, true);