mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
extensions to test contributionLink more detailed
This commit is contained in:
parent
ccb69b2631
commit
0ce0e9b2d7
10
backend/src/seeds/creation/ContributionInterface.ts
Normal file
10
backend/src/seeds/creation/ContributionInterface.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export interface ContributionInterface {
|
||||
startDate: string
|
||||
endDate: string
|
||||
name: string
|
||||
amount: string
|
||||
memo: string
|
||||
cycle: string
|
||||
repetition: string
|
||||
maxAmount: string
|
||||
}
|
||||
59
backend/src/seeds/factory/contribution.ts
Normal file
59
backend/src/seeds/factory/contribution.ts
Normal file
@ -0,0 +1,59 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import { createContributionLink } from '@/seeds/graphql/mutations'
|
||||
// import { User } from '@entity/User'
|
||||
import { login } from '@/seeds/graphql/queries'
|
||||
import { ContributionInterface } from '@/seeds/creation/ContributionInterface'
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
import { ContributionLink } from '@/graphql/model/ContributionLink'
|
||||
// import { ContributionLinks } from '@entity/ContributionLinks'
|
||||
|
||||
// import CONFIG from '@/config/index'
|
||||
|
||||
export const nMonthsBefore = (date: Date, months = 1): string => {
|
||||
return new Date(date.getFullYear(), date.getMonth() - months, 1).toISOString()
|
||||
}
|
||||
|
||||
export const contributionFactory = async (
|
||||
client: ApolloServerTestClient,
|
||||
contribution: ContributionInterface,
|
||||
): Promise<ContributionLink | void> => {
|
||||
const { mutate, query } = client
|
||||
|
||||
await query({ query: login, variables: { email: 'peter@lustig.de', password: 'Aa12345_' } })
|
||||
|
||||
// let contributionLink: ContributionLink
|
||||
// TODO it would be nice to have this mutation return the id
|
||||
const contributionLink = await mutate({
|
||||
mutation: createContributionLink,
|
||||
variables: { ...contribution },
|
||||
})
|
||||
|
||||
// const user = await User.findOneOrFail({ where: { email: creation.email } })
|
||||
|
||||
/*
|
||||
if (contribution.linkEnabled) {
|
||||
await mutate({ mutation: confirmPendingCreation, variables: { id: pendingCreation.id } })
|
||||
|
||||
if (creation.moveCreationDate) {
|
||||
const transaction = await Transaction.findOneOrFail({
|
||||
where: { userId: user.id, creationDate: new Date(creation.creationDate) },
|
||||
order: { balanceDate: 'DESC' },
|
||||
})
|
||||
if (transaction.decay.equals(0) && transaction.creationDate) {
|
||||
transaction.creationDate = new Date(
|
||||
nMonthsBefore(transaction.creationDate, creation.moveCreationDate),
|
||||
)
|
||||
transaction.balanceDate = new Date(
|
||||
nMonthsBefore(transaction.balanceDate, creation.moveCreationDate),
|
||||
)
|
||||
await transaction.save()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return pendingCreation
|
||||
}
|
||||
*/
|
||||
return contributionLink
|
||||
}
|
||||
@ -137,3 +137,13 @@ export const deletePendingCreation = gql`
|
||||
deletePendingCreation(id: $id)
|
||||
}
|
||||
`
|
||||
|
||||
export const createContributionLink = gql`
|
||||
mutation ($pendingCreations: [CreateContributionLinkArgs!]!) {
|
||||
createContributionLink(pendingCreations: $pendingCreations) {
|
||||
success
|
||||
successfulCreation
|
||||
failedCreation
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user