From cabb844c2c8f4ddc4654b1e4e2bbd527e0ab2f75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Tue, 31 May 2022 10:43:15 +0200 Subject: [PATCH] Fix creation date for transaction links for seeding - Add some commented code for future testing of 'withRedeemed', 'withExpired'. --- .../src/graphql/resolver/AdminResolver.test.ts | 17 +++++++++++------ .../transactionLink/TransactionLinkInterface.ts | 3 +++ backend/src/seeds/transactionLink/index.ts | 6 +++++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 37250acf2..c923e46ad 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1493,7 +1493,7 @@ describe('AdminResolver', () => { }) }) - // Wolle: works not as expected, because of wrong 'linkCount' at least + // TODO: works not as expected, because the expired link is not in the result eventhogh a link has 'createdAt' at the very first of 2022 and should be expired describe.skip('filter by expired', () => { it('finds 6 open transaction links and 1 deleted and no redeemed', async () => { await expect( @@ -1530,7 +1530,7 @@ describe('AdminResolver', () => { }) }) - // Wolle: not done jet + // 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 () => { await expect( @@ -1549,15 +1549,20 @@ describe('AdminResolver', () => { expect.objectContaining({ data: { listTransactionLinksAdmin: { - linkCount: 7, // Wolle: finds 5 but counts 7 + linkCount: 6, linkList: expect.arrayContaining([ - expect.objectContaining({ + expect.not.objectContaining({ memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - // Wolle: createdAt: new Date(2022, 0, 1), + createdAt: expect.any(String), + }), + expect.objectContaining({ + memo: 'Yeah, eingelöst!', + redeemedAt: expect.any(String), + redeemedBy: expect.any(Number), }), expect.not.objectContaining({ memo: 'Da habe ich mich wohl etwas übernommen.', - // Wolle: deletedAt: expect.any(String), + deletedAt: expect.any(String), }), ]), }, diff --git a/backend/src/seeds/transactionLink/TransactionLinkInterface.ts b/backend/src/seeds/transactionLink/TransactionLinkInterface.ts index ddc835b33..eaacfdf92 100644 --- a/backend/src/seeds/transactionLink/TransactionLinkInterface.ts +++ b/backend/src/seeds/transactionLink/TransactionLinkInterface.ts @@ -3,5 +3,8 @@ export interface TransactionLinkInterface { amount: number memo: string createdAt?: Date + // TODO: for testing + // redeemedAt?: Date + // redeemedBy?: number deletedAt?: boolean } diff --git a/backend/src/seeds/transactionLink/index.ts b/backend/src/seeds/transactionLink/index.ts index 25755c0f2..1db3d4828 100644 --- a/backend/src/seeds/transactionLink/index.ts +++ b/backend/src/seeds/transactionLink/index.ts @@ -5,7 +5,7 @@ export const transactionLinks: TransactionLinkInterface[] = [ email: 'bibi@bloxberg.de', amount: 19.99, memo: 'Leider wollte niemand meine Gradidos zum Neujahr haben :(', - createdAt: new Date(2022, 0, 1), + createdAt: new Date(2022, 1, 1), }, { email: 'bibi@bloxberg.de', @@ -30,6 +30,10 @@ bei Gradidio sei dabei!`, amount: 19.99, memo: `Kein Trick, keine Zauberrei, bei Gradidio sei dabei!`, + // TODO: for testing + // memo: `Yeah, eingelöst!`, + // redeemedAt: new Date(2022, 2, 2), + // redeemedBy: not null, }, { email: 'bibi@bloxberg.de',