From ca8ce34f68baca58bb7a39f8608514cb89242a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Thu, 2 Jun 2022 11:20:58 +0200 Subject: [PATCH] Move 'searchUsers' query from mutations to queries, correct and refine test descriptions --- .../graphql/resolver/AdminResolver.test.ts | 14 +++++++---- backend/src/seeds/graphql/mutations.ts | 24 ------------------- backend/src/seeds/graphql/queries.ts | 24 +++++++++++++++++++ 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index eee013e84..acf880efb 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -15,14 +15,18 @@ import { garrickOllivander } from '@/seeds/users/garrick-ollivander' import { deleteUser, unDeleteUser, - searchUsers, createPendingCreation, createPendingCreations, updatePendingCreation, deletePendingCreation, confirmPendingCreation, } from '@/seeds/graphql/mutations' -import { getPendingCreations, login, listTransactionLinksAdmin } from '@/seeds/graphql/queries' +import { + getPendingCreations, + login, + searchUsers, + listTransactionLinksAdmin, +} from '@/seeds/graphql/queries' import { GraphQLError } from 'graphql' import { User } from '@entity/User' /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ @@ -1478,7 +1482,7 @@ describe('AdminResolver', () => { }) describe('filter with deleted', () => { - it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + it('finds 6 open transaction links, 1 deleted, and no redeemed', async () => { await expect( query({ query: listTransactionLinksAdmin, @@ -1512,7 +1516,7 @@ describe('AdminResolver', () => { }) describe('filter by expired', () => { - it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + it('finds 5 open transaction links, 1 expired, and no redeemed', async () => { await expect( query({ query: listTransactionLinksAdmin, @@ -1547,7 +1551,7 @@ describe('AdminResolver', () => { // TODO: works not as expected, because 'redeemedAt' and 'redeemedBy' have to be added to the transaktion link factory describe.skip('filter by redeemed', () => { - it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { + it('finds 6 open transaction links, 1 deleted, and no redeemed', async () => { await expect( query({ query: listTransactionLinksAdmin, diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index 44a9499bf..e66827566 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -105,30 +105,6 @@ export const unDeleteUser = gql` } ` -export const searchUsers = gql` - query ($searchText: String!, $currentPage: Int, $pageSize: Int, $filters: SearchUsersFilters) { - searchUsers( - searchText: $searchText - currentPage: $currentPage - pageSize: $pageSize - filters: $filters - ) { - userCount - userList { - userId - firstName - lastName - email - creation - emailChecked - hasElopage - emailConfirmationSend - deletedAt - } - } - } -` - export const createPendingCreations = gql` mutation ($pendingCreations: [CreatePendingCreationArgs!]!) { createPendingCreations(pendingCreations: $pendingCreations) { diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index f3b9f03c2..03ee3b53e 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -91,6 +91,30 @@ export const sendResetPasswordEmail = gql` } ` +export const searchUsers = gql` + query ($searchText: String!, $currentPage: Int, $pageSize: Int, $filters: SearchUsersFilters) { + searchUsers( + searchText: $searchText + currentPage: $currentPage + pageSize: $pageSize + filters: $filters + ) { + userCount + userList { + userId + firstName + lastName + email + creation + emailChecked + hasElopage + emailConfirmationSend + deletedAt + } + } + } +` + export const listGDTEntriesQuery = gql` query ($currentPage: Int!, $pageSize: Int!) { listGDTEntries(currentPage: $currentPage, pageSize: $pageSize) {