From 7286389b87d2345fb7739f0905c5bfe3ec2366cd Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 11 Oct 2022 20:03:00 +0200 Subject: [PATCH 01/19] filter contribution link list by valid to --- backend/src/graphql/resolver/AdminResolver.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 3435edb94..4f7aedd9d 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -675,6 +675,7 @@ export class AdminResolver { { currentPage = 1, pageSize = 5, order = Order.DESC }: Paginated, ): Promise { const [links, count] = await DbContributionLink.findAndCount({ + where: [{ validTo: MoreThan(new Date()) }, { validTo: IsNull() }], order: { createdAt: order }, skip: (currentPage - 1) * pageSize, take: pageSize, From 505463a3f8a03b47998939ed625649d5721667e4 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 11 Oct 2022 20:03:52 +0200 Subject: [PATCH 02/19] show default text when no contribution links are present --- frontend/src/locales/de.json | 3 ++- frontend/src/locales/en.json | 3 ++- frontend/src/pages/InfoStatistic.vue | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 1ed8af19f..5a71faef0 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -24,7 +24,8 @@ "moderator": "Moderator", "moderators": "Moderatoren", "myContributions": "Meine Beiträge zum Gemeinwohl", - "openContributionLinks": "öffentliche Beitrags-Linkliste", + "noOpenContributionLinkText": "Zur Zeit gibt es keine automatische Schöpfungen.", + "openContributionLinks": "Öffentliche Beitrags-Linkliste", "openContributionLinkText": "Folgende {count} automatische Schöpfungen werden zur Zeit durch die Gemeinschaft „{name}“ bereitgestellt.", "other-communities": "Weitere Gemeinschaften", "submitContribution": "Beitrag einreichen", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 113fa1cb9..d9f69581d 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -24,7 +24,8 @@ "moderator": "Moderator", "moderators": "Moderators", "myContributions": "My contributions to the common good", - "openContributionLinks": "open Contribution links list", + "noOpenContributionLinkText": "Currently there are no automatic creations.", + "openContributionLinks": "Open contribution-link list", "openContributionLinkText": "The following {count} automatic creations are currently provided by the \"{name}\" community.", "other-communities": "Other communities", "submitContribution": "Submit contribution", diff --git a/frontend/src/pages/InfoStatistic.vue b/frontend/src/pages/InfoStatistic.vue index 1e09f83ed..de4b9e224 100644 --- a/frontend/src/pages/InfoStatistic.vue +++ b/frontend/src/pages/InfoStatistic.vue @@ -14,7 +14,7 @@
{{ $t('community.openContributionLinks') }}
- + {{ $t('community.openContributionLinkText', { name: CONFIG.COMMUNITY_NAME, @@ -22,6 +22,9 @@ }) }} + + {{ $t('community.noOpenContributionLinkText') }} +
  • {{ item.name }}
    From bc2889a9f8b2cc92dcd48817adca33d42aef18fd Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 11 Oct 2022 20:44:41 +0200 Subject: [PATCH 03/19] fix: Disable Change of Month for Update Contribution (wallet and admin) --- .../src/graphql/resolver/AdminResolver.test.ts | 17 ++++++++++------- backend/src/graphql/resolver/AdminResolver.ts | 3 +++ .../resolver/ContributionResolver.test.ts | 4 +--- .../graphql/resolver/ContributionResolver.ts | 3 +++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index b1b4e469e..e66ed6f60 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1202,7 +1202,8 @@ describe('AdminResolver', () => { }) describe('creation update is not valid', () => { - it('throws an error', async () => { + // as this test has not clearly defined that date, it is a false positive + it.skip('throws an error', async () => { await expect( mutate({ mutation: adminUpdateContribution, @@ -1227,7 +1228,8 @@ describe('AdminResolver', () => { }) describe('creation update is successful changing month', () => { - it('returns update creation object', async () => { + // skipped as changing the month is currently disable + it.skip('returns update creation object', async () => { await expect( mutate({ mutation: adminUpdateContribution, @@ -1255,7 +1257,8 @@ describe('AdminResolver', () => { }) describe('creation update is successful without changing month', () => { - it('returns update creation object', async () => { + // actually this mutation IS changing the month + it.skip('returns update creation object', async () => { await expect( mutate({ mutation: adminUpdateContribution, @@ -1299,10 +1302,10 @@ describe('AdminResolver', () => { lastName: 'Lustig', email: 'peter@lustig.de', date: expect.any(String), - memo: 'Das war leider zu Viel!', - amount: '200', + memo: 'Herzlich Willkommen bei Gradido!', + amount: '400', moderator: admin.id, - creation: ['1000', '1000', '300'], + creation: ['1000', '600', '500'], }, { id: expect.any(Number), @@ -1313,7 +1316,7 @@ describe('AdminResolver', () => { memo: 'Grundeinkommen', amount: '500', moderator: admin.id, - creation: ['1000', '1000', '300'], + creation: ['1000', '600', '500'], }, { id: expect.any(Number), diff --git a/backend/src/graphql/resolver/AdminResolver.ts b/backend/src/graphql/resolver/AdminResolver.ts index 3435edb94..13fbb849b 100644 --- a/backend/src/graphql/resolver/AdminResolver.ts +++ b/backend/src/graphql/resolver/AdminResolver.ts @@ -339,6 +339,9 @@ export class AdminResolver { let creations = await getUserCreation(user.id) if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { creations = updateCreations(creations, contributionToUpdate) + } else { + logger.error('Currently the month of the contribution cannot change.') + throw new Error('Currently the month of the contribution cannot change.') } // all possible cases not to be true are thrown in this function diff --git a/backend/src/graphql/resolver/ContributionResolver.test.ts b/backend/src/graphql/resolver/ContributionResolver.test.ts index 20f11ff9a..fd87f1bd6 100644 --- a/backend/src/graphql/resolver/ContributionResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionResolver.test.ts @@ -489,9 +489,7 @@ describe('ContributionResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [ - new GraphQLError('No information for available creations for the given date'), - ], + errors: [new GraphQLError('Currently the month of the contribution cannot change.')], }), ) }) diff --git a/backend/src/graphql/resolver/ContributionResolver.ts b/backend/src/graphql/resolver/ContributionResolver.ts index fc93880f1..41af5d249 100644 --- a/backend/src/graphql/resolver/ContributionResolver.ts +++ b/backend/src/graphql/resolver/ContributionResolver.ts @@ -164,6 +164,9 @@ export class ContributionResolver { let creations = await getUserCreation(user.id) if (contributionToUpdate.contributionDate.getMonth() === creationDateObj.getMonth()) { creations = updateCreations(creations, contributionToUpdate) + } else { + logger.error('Currently the month of the contribution cannot change.') + throw new Error('Currently the month of the contribution cannot change.') } // all possible cases not to be true are thrown in this function From 4e13678367162a3e00d33dffce95f8b2f25f4a07 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 11 Oct 2022 20:56:02 +0200 Subject: [PATCH 04/19] fix test. Add dynamic valid to date for contribution link --- backend/src/graphql/resolver/AdminResolver.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index b1b4e469e..4170e3324 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1792,13 +1792,14 @@ describe('AdminResolver', () => { }) describe('Contribution Links', () => { + const now = new Date() const variables = { amount: new Decimal(200), name: 'Dokumenta 2022', memo: 'Danke für deine Teilnahme an der Dokumenta 2022', cycle: 'once', validFrom: new Date(2022, 5, 18).toISOString(), - validTo: new Date(2022, 7, 14).toISOString(), + validTo: new Date(now.getFullYear() + 1, 7, 14).toISOString(), maxAmountPerMonth: new Decimal(200), maxPerCycle: 1, } @@ -1980,7 +1981,7 @@ describe('AdminResolver', () => { name: 'Dokumenta 2022', memo: 'Danke für deine Teilnahme an der Dokumenta 2022', validFrom: new Date('2022-06-18T00:00:00.000Z'), - validTo: new Date('2022-08-14T00:00:00.000Z'), + validTo: expect.any(Date), cycle: 'once', maxPerCycle: 1, totalMaxCountOfContribution: null, From 7e66e299d9b10352b1d7e6c44e8adb4aa5874c14 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 12 Oct 2022 14:46:22 +0200 Subject: [PATCH 05/19] feat: Daily Rule for Contribution Links --- .../src/graphql/enum/ContributionCycleType.ts | 5 +- .../resolver/TransactionLinkResolver.ts | 69 ++++++++++++++----- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/backend/src/graphql/enum/ContributionCycleType.ts b/backend/src/graphql/enum/ContributionCycleType.ts index 5fe494a02..a3c55aa68 100644 --- a/backend/src/graphql/enum/ContributionCycleType.ts +++ b/backend/src/graphql/enum/ContributionCycleType.ts @@ -1,13 +1,14 @@ import { registerEnumType } from 'type-graphql' +// lowercase values are not implemented yet export enum ContributionCycleType { - ONCE = 'once', + ONCE = 'ONCE', HOUR = 'hour', TWO_HOURS = 'two_hours', FOUR_HOURS = 'four_hours', EIGHT_HOURS = 'eight_hours', HALF_DAY = 'half_day', - DAY = 'day', + DAILY = 'DAILY', TWO_DAYS = 'two_days', THREE_DAYS = 'three_days', FOUR_DAYS = 'four_days', diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.ts b/backend/src/graphql/resolver/TransactionLinkResolver.ts index c9acbace3..e6b28a0f8 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.ts @@ -1,6 +1,6 @@ import { backendLogger as logger } from '@/server/logger' import { Context, getUser } from '@/server/context' -import { getConnection } from '@dbTools/typeorm' +import { getConnection, Between } from '@dbTools/typeorm' import { Resolver, Args, @@ -34,6 +34,7 @@ import { getUserCreation, validateContribution } from './util/creations' import { Decay } from '@model/Decay' import Decimal from 'decimal.js-light' import { TransactionTypeId } from '@enum/TransactionTypeId' +import { ContributionCycleType } from '@enum/ContributionCycleType' const QueryLinkResult = createUnionType({ name: 'QueryLinkResult', // the name of the GraphQL union @@ -204,23 +205,55 @@ export class TransactionLinkResolver { throw new Error('Contribution link is depricated') } } - if (contributionLink.cycle !== 'ONCE') { - logger.error('contribution link has unknown cycle', contributionLink.cycle) - throw new Error('Contribution link has unknown cycle') - } - // Test ONCE rule - const alreadyRedeemed = await queryRunner.manager - .createQueryBuilder() - .select('contribution') - .from(DbContribution, 'contribution') - .where('contribution.contributionLinkId = :linkId AND contribution.userId = :id', { - linkId: contributionLink.id, - id: user.id, - }) - .getOne() - if (alreadyRedeemed) { - logger.error('contribution link with rule ONCE already redeemed by user with id', user.id) - throw new Error('Contribution link already redeemed') + let alreadyRedeemed: DbContribution | undefined + switch (contributionLink.cycle) { + case ContributionCycleType.ONCE: { + alreadyRedeemed = await queryRunner.manager + .createQueryBuilder() + .select('contribution') + .from(DbContribution, 'contribution') + .where('contribution.contributionLinkId = :linkId AND contribution.userId = :id', { + linkId: contributionLink.id, + id: user.id, + }) + .getOne() + if (alreadyRedeemed) { + logger.error( + 'contribution link with rule ONCE already redeemed by user with id', + user.id, + ) + throw new Error('Contribution link already redeemed') + } + break + } + case ContributionCycleType.DAILY: { + const start = new Date() + start.setHours(0, 0, 0, 0) + const end = new Date() + end.setHours(23, 59, 59, 999) + alreadyRedeemed = await queryRunner.manager + .createQueryBuilder() + .select('contribution') + .from(DbContribution, 'contribution') + .where('contribution.contributionLinkId = :linkId AND contribution.userId = :id', { + linkId: contributionLink.id, + id: user.id, + contributionDate: Between(start, end), + }) + .getOne() + if (alreadyRedeemed) { + logger.error( + 'contribution link with rule DAILY already redeemed by user with id', + user.id, + ) + throw new Error('Contribution link already redeemed today') + } + break + } + default: { + logger.error('contribution link has unknown cycle', contributionLink.cycle) + throw new Error('Contribution link has unknown cycle') + } } const creations = await getUserCreation(user.id, false) From 69c0c214b9b5f6a6b0a6b4af51a2dffab5aa234c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 12 Oct 2022 17:03:51 +0200 Subject: [PATCH 06/19] update browser list --- backend/yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/yarn.lock b/backend/yarn.lock index dd84e2ce5..1e5647b6f 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -1668,9 +1668,9 @@ camelcase@^6.2.0: integrity sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg== caniuse-lite@^1.0.30001264: - version "1.0.30001325" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001325.tgz" - integrity sha512-sB1bZHjseSjDtijV1Hb7PB2Zd58Kyx+n/9EotvZ4Qcz2K3d0lWB8dB4nb8wN/TsOGFq3UuAm0zQZNQ4SoR7TrQ== + version "1.0.30001418" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001418.tgz" + integrity sha512-oIs7+JL3K9JRQ3jPZjlH6qyYDp+nBTCais7hjh0s+fuBwufc7uZ7hPYMXrDOJhV360KGMTcczMRObk0/iMqZRg== chalk@^2.0.0: version "2.4.2" From 686c24a57dca16ac7bb6d39175ff4c8b3b367f6f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 12 Oct 2022 17:17:10 +0200 Subject: [PATCH 07/19] add tests for daily contribution link --- .../resolver/TransactionLinkResolver.test.ts | 116 ++++++++++++++++++ backend/src/seeds/graphql/mutations.ts | 6 + 2 files changed, 122 insertions(+) diff --git a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts index 5a1a39dca..e527eeb8a 100644 --- a/backend/src/graphql/resolver/TransactionLinkResolver.test.ts +++ b/backend/src/graphql/resolver/TransactionLinkResolver.test.ts @@ -1,4 +1,120 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ + import { transactionLinkCode } from './TransactionLinkResolver' +import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg' +import { peterLustig } from '@/seeds/users/peter-lustig' +import { cleanDB, testEnvironment } from '@test/helpers' +import { userFactory } from '@/seeds/factory/user' +import { createContributionLink, redeemTransactionLink } from '@/seeds/graphql/mutations' +import { login } from '@/seeds/graphql/queries' +import { ContributionLink as DbContributionLink } from '@entity/ContributionLink' +import Decimal from 'decimal.js-light' +import { GraphQLError } from 'graphql' + +let mutate: any, query: any, con: any +let testEnv: any + +beforeAll(async () => { + testEnv = await testEnvironment() + mutate = testEnv.mutate + query = testEnv.query + con = testEnv.con + await cleanDB() + await userFactory(testEnv, bibiBloxberg) + await userFactory(testEnv, peterLustig) +}) + +afterAll(async () => { + await cleanDB() + await con.close() +}) + +describe('TransactionLinkResolver', () => { + describe('redeem daily Contribution Link', () => { + const now = new Date() + let contributionLink: DbContributionLink | undefined + + beforeAll(async () => { + await query({ + query: login, + variables: { email: 'peter@lustig.de', password: 'Aa12345_' }, + }) + await mutate({ + mutation: createContributionLink, + variables: { + amount: new Decimal(5), + name: 'Daily Contribution Link', + memo: 'Thank you for contribute daily to the community', + cycle: 'DAILY', + validFrom: new Date(now.getFullYear(), 0, 1).toISOString(), + validTo: new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999).toISOString(), + maxAmountPerMonth: new Decimal(200), + maxPerCycle: 1, + }, + }) + }) + + it('has a daily contribution link in the database', async () => { + const cls = await DbContributionLink.find() + expect(cls).toHaveLength(1) + contributionLink = cls[0] + expect(contributionLink).toEqual( + expect.objectContaining({ + id: expect.any(Number), + name: 'Daily Contribution Link', + memo: 'Thank you for contribute daily to the community', + validFrom: new Date(now.getFullYear(), 0, 1), + validTo: new Date(now.getFullYear(), 11, 31, 23, 59, 59, 0), + cycle: 'DAILY', + maxPerCycle: 1, + totalMaxCountOfContribution: null, + maxAccountBalance: null, + minGapHours: null, + createdAt: expect.any(Date), + deletedAt: null, + code: expect.stringMatching(/^[0-9a-f]{24,24}$/), + linkEnabled: true, + // amount: '200', + // maxAmountPerMonth: '200', + }), + ) + }) + + it('allows the user to redeem the contribution link', async () => { + await expect( + mutate({ + mutation: redeemTransactionLink, + variables: { + code: 'CL-' + (contributionLink ? contributionLink.code : ''), + }, + }), + ).resolves.toMatchObject({ + data: { + redeemTransactionLink: true, + }, + errors: undefined, + }) + }) + + it('does not allow the user to redeem the contribution link a second time', async () => { + await expect( + mutate({ + mutation: redeemTransactionLink, + variables: { + code: 'CL-' + (contributionLink ? contributionLink.code : ''), + }, + }), + ).resolves.toMatchObject({ + errors: [ + new GraphQLError( + 'Creation from contribution link was not successful. Error: Contribution link already redeemed today', + ), + ], + }) + }) + }) +}) describe('transactionLinkCode', () => { const date = new Date() diff --git a/backend/src/seeds/graphql/mutations.ts b/backend/src/seeds/graphql/mutations.ts index e5f290645..99dd0e7bd 100644 --- a/backend/src/seeds/graphql/mutations.ts +++ b/backend/src/seeds/graphql/mutations.ts @@ -289,3 +289,9 @@ export const adminCreateContributionMessage = gql` } } ` + +export const redeemTransactionLink = gql` + mutation ($code: String!) { + redeemTransactionLink(code: $code) + } +` From b36abc5c6206b9dbab84e47448b119f03731593c Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 12 Oct 2022 17:23:09 +0200 Subject: [PATCH 08/19] set backend unit test coverage to 74 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b7000100e..34ebeff11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -528,7 +528,7 @@ jobs: report_name: Coverage Backend type: lcov result_path: ./backend/coverage/lcov.info - min_coverage: 68 + min_coverage: 74 token: ${{ github.token }} ########################################################################## From 463f0a060111430a9408dda632cb068941232117 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 12 Oct 2022 19:30:06 +0200 Subject: [PATCH 09/19] feat: Global Jest Extension for Decimal Equal --- backend/jest.config.js | 1 + .../graphql/resolver/AdminResolver.test.ts | 2 +- backend/test/extensions.ts | 31 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 backend/test/extensions.ts diff --git a/backend/jest.config.js b/backend/jest.config.js index 6ab44002c..a472df316 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -5,6 +5,7 @@ module.exports = { collectCoverage: true, collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**', '!src/seeds/**', '!build/**'], setupFiles: ['/test/testSetup.ts'], + setupFilesAfterEnv: ['/test/extensions.ts'], modulePathIgnorePatterns: ['/build/'], moduleNameMapper: { '@/(.*)': '/src/$1', diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index b1b4e469e..34888b2df 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1990,7 +1990,7 @@ describe('AdminResolver', () => { deletedAt: null, code: expect.stringMatching(/^[0-9a-f]{24,24}$/), linkEnabled: true, - // amount: '200', + amount: expect.decimalEqual(200), // maxAmountPerMonth: '200', }), ) diff --git a/backend/test/extensions.ts b/backend/test/extensions.ts new file mode 100644 index 000000000..49a92f521 --- /dev/null +++ b/backend/test/extensions.ts @@ -0,0 +1,31 @@ +import Decimal from 'decimal.js-light' + +expect.extend({ + decimalEqual(received, value) { + const pass = new Decimal(value).equals(received.toString()) + if (pass) { + return { + message: () => `expected ${received} to not equal ${value}`, + pass: true, + } + } else { + return { + message: () => `expected ${received} to equal ${value}`, + pass: false, + } + } + }, +}) + +interface CustomMatchers { + decimalEqual(value: number): R +} + +declare global { + // eslint-disable-next-line @typescript-eslint/no-namespace + namespace jest { + type Expect = CustomMatchers + type Matchers = CustomMatchers + type InverseAsymmetricMatchers = CustomMatchers + } +} From 39982759f2d2c307fe55907bb5afde755673d3cc Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 12 Oct 2022 19:40:26 +0200 Subject: [PATCH 10/19] test more decimal values coming from DB --- backend/src/graphql/resolver/AdminResolver.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/graphql/resolver/AdminResolver.test.ts b/backend/src/graphql/resolver/AdminResolver.test.ts index 34888b2df..a2eacc990 100644 --- a/backend/src/graphql/resolver/AdminResolver.test.ts +++ b/backend/src/graphql/resolver/AdminResolver.test.ts @@ -1991,7 +1991,7 @@ describe('AdminResolver', () => { code: expect.stringMatching(/^[0-9a-f]{24,24}$/), linkEnabled: true, amount: expect.decimalEqual(200), - // maxAmountPerMonth: '200', + maxAmountPerMonth: expect.decimalEqual(200), }), ) }) @@ -2280,7 +2280,7 @@ describe('AdminResolver', () => { id: linkId, name: 'Dokumenta 2023', memo: 'Danke für deine Teilnahme an der Dokumenta 2023', - // amount: '400', + amount: expect.decimalEqual(400), }), ) }) From 25e461188cf35311719116f93472c59137675e21 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 13 Oct 2022 09:04:29 +0200 Subject: [PATCH 11/19] ignore eslint rule no-empty-interface --- backend/test/extensions.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/test/extensions.ts b/backend/test/extensions.ts index 49a92f521..69c2ff7a6 100644 --- a/backend/test/extensions.ts +++ b/backend/test/extensions.ts @@ -1,3 +1,5 @@ +/* eslint-disable @typescript-eslint/no-empty-interface */ + import Decimal from 'decimal.js-light' expect.extend({ @@ -24,8 +26,8 @@ interface CustomMatchers { declare global { // eslint-disable-next-line @typescript-eslint/no-namespace namespace jest { - type Expect = CustomMatchers - type Matchers = CustomMatchers - type InverseAsymmetricMatchers = CustomMatchers + interface Expect extends CustomMatchers {} + interface Matchers extends CustomMatchers {} + interface InverseAsymmetricMatchers extends CustomMatchers {} } } From d662338f6a8aed337685dcc861e030e622803a1f Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 13 Oct 2022 09:52:25 +0200 Subject: [PATCH 12/19] feat: Daily Rule for Contribution Links in Admin Interface --- admin/src/components/ContributionLink.spec.js | 1 + admin/src/components/ContributionLinkForm.vue | 76 +++++++++---------- .../components/ContributionLinkList.spec.js | 1 + admin/src/components/ContributionLinkList.vue | 24 +++++- admin/src/locales/de.json | 7 +- admin/src/locales/en.json | 7 +- admin/src/pages/Overview.spec.js | 1 + 7 files changed, 62 insertions(+), 55 deletions(-) diff --git a/admin/src/components/ContributionLink.spec.js b/admin/src/components/ContributionLink.spec.js index f1b9cfb97..9818e8b93 100644 --- a/admin/src/components/ContributionLink.spec.js +++ b/admin/src/components/ContributionLink.spec.js @@ -5,6 +5,7 @@ const localVue = global.localVue const mocks = { $t: jest.fn((t) => t), + $d: jest.fn((d) => d), } const propsData = { diff --git a/admin/src/components/ContributionLinkForm.vue b/admin/src/components/ContributionLinkForm.vue index 6daf1e299..48cd98f9b 100644 --- a/admin/src/components/ContributionLinkForm.vue +++ b/admin/src/components/ContributionLinkForm.vue @@ -1,8 +1,5 @@