From cc0fe5968d5eddc048991a318aef3dd0c79a8fcd Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 25 Jan 2023 07:54:17 +0100 Subject: [PATCH] Tests that the filterState parameter in listAllContributions works as expected. --- .../resolver/ContributionResolver.test.ts | 111 ++++++++++++++++++ backend/src/seeds/graphql/queries.ts | 19 +-- 2 files changed, 123 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 7b4186fb4..04749d8f0 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -45,6 +45,7 @@ import { Transaction as DbTransaction } from '@entity/Transaction' import { User } from '@entity/User' import { EventProtocolType } from '@/event/EventProtocolType' import { logger, i18n as localization } from '@test/testSetup' +import { ContributionStatus } from '@enum/ContributionStatus' // mock account activation email to avoid console spam // mock account activation email to avoid console spam @@ -737,11 +738,121 @@ describe('ContributionResolver', () => { contributionList: expect.arrayContaining([ expect.objectContaining({ id: expect.any(Number), + state: 'CONFIRMED', memo: 'Herzlich Willkommen bei Gradido!', amount: '1000', }), expect.objectContaining({ id: expect.any(Number), + state: 'PENDING', + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }, + }), + ) + }) + + it('returns all CONFIRMED Creation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterState: ['CONFIRMED'], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: { + contributionCount: 1, + contributionList: expect.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + state: 'CONFIRMED', + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.not.objectContaining({ + id: expect.any(Number), + state: 'PENDING', + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }, + }), + ) + }) + + it('returns all PENDING Creation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterState: ['PENDING'], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: { + contributionCount: 1, + contributionList: expect.arrayContaining([ + expect.not.objectContaining({ + id: expect.any(Number), + state: 'CONFIRMED', + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + state: 'PENDING', + memo: 'Test env contribution', + amount: '100', + }), + ]), + }, + }, + }), + ) + }) + + it('returns all DENIED Creation', async () => { + await expect( + query({ + query: listAllContributions, + variables: { + currentPage: 1, + pageSize: 25, + order: 'DESC', + filterState: ['DENIED'], + }, + }), + ).resolves.toEqual( + expect.objectContaining({ + data: { + listAllContributions: { + contributionCount: 0, + contributionList: expect.not.arrayContaining([ + expect.objectContaining({ + id: expect.any(Number), + state: 'CONFIRMED', + memo: 'Herzlich Willkommen bei Gradido!', + amount: '1000', + }), + expect.objectContaining({ + id: expect.any(Number), + state: 'PENDING', memo: 'Test env contribution', amount: '100', }), diff --git a/backend/src/seeds/graphql/queries.ts b/backend/src/seeds/graphql/queries.ts index b99b39b40..17a66951a 100644 --- a/backend/src/seeds/graphql/queries.ts +++ b/backend/src/seeds/graphql/queries.ts @@ -177,13 +177,18 @@ query ($currentPage: Int = 1, $pageSize: Int = 5, $order: Order = DESC, $filterS contributionCount contributionList { id - firstName - lastName - amount - memo - createdAt - confirmedAt - confirmedBy + firstName + lastName + amount + memo + createdAt + confirmedAt + confirmedBy + contributionDate + state + messagesCount + deniedAt + deniedBy } } }