mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
seed two ContributionLinks
This commit is contained in:
parent
26a653fd7d
commit
7640680c42
@ -1898,6 +1898,7 @@ describe('AdminResolver', () => {
|
||||
id: linkId,
|
||||
name: 'Dokumenta 2023',
|
||||
memo: 'Danke für deine Teilnahme an der Dokumenta 2023',
|
||||
// amount: '400',
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
export interface ContributionLinkInterface {
|
||||
amount: number
|
||||
name: string
|
||||
memo: string
|
||||
validFrom?: date
|
||||
validTo?: date
|
||||
}
|
||||
18
backend/src/seeds/contributionLink/index.ts
Normal file
18
backend/src/seeds/contributionLink/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
import { ContributionLinkInterface } from './ContributionLinkInterface'
|
||||
|
||||
export const contributionLinks: ContributionLinkInterface[] = [
|
||||
{
|
||||
name: 'Dokumenta 2017',
|
||||
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2017',
|
||||
amount: 200,
|
||||
validFrom: new Date(2017, 3, 8),
|
||||
validTo: new Date(2017, 6, 16),
|
||||
},
|
||||
{
|
||||
name: 'Dokumenta 2022',
|
||||
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2022',
|
||||
amount: 200,
|
||||
validFrom: new Date(2022, 5, 18),
|
||||
validTo: new Date(2022, 8, 25),
|
||||
},
|
||||
]
|
||||
27
backend/src/seeds/factory/contributionLink.ts
Normal file
27
backend/src/seeds/factory/contributionLink.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
import { createContributionLink } from '@/seeds/graphql/mutations'
|
||||
import { login } from '@/seeds/graphql/queries'
|
||||
import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface'
|
||||
|
||||
export const contributionLinkFactory = async (
|
||||
client: ApolloServerTestClient,
|
||||
contributionLink: ContributionLinkInterface,
|
||||
): Promise<void> => {
|
||||
const { mutate, query } = client
|
||||
|
||||
// login as admin
|
||||
await query({ query: login, variables: { email: 'peter@lustig.de', password: 'Aa12345_' } })
|
||||
|
||||
const variables = {
|
||||
amount: contributionLink.amount,
|
||||
memo: contributionLink.memo,
|
||||
name: contributionLink.name,
|
||||
cycle: 'ONCE',
|
||||
maxPerCycle: 1,
|
||||
maxAmountPerMonth: 200,
|
||||
validFrom: contributionLink.validFrom ? contributionLink.validFrom.toISOString() : undefined,
|
||||
validTo: contributionLink.validTo ? contributionLink.validTo.toISOString() : undefined,
|
||||
}
|
||||
|
||||
await mutate({ mutation: createContributionLink, variables })
|
||||
}
|
||||
@ -9,9 +9,11 @@ import { name, internet, datatype } from 'faker'
|
||||
import { users } from './users/index'
|
||||
import { creations } from './creation/index'
|
||||
import { transactionLinks } from './transactionLink/index'
|
||||
import { contributionLinks } from './contributionLink/index'
|
||||
import { userFactory } from './factory/user'
|
||||
import { creationFactory } from './factory/creation'
|
||||
import { transactionLinkFactory } from './factory/transactionLink'
|
||||
import { contributionLinkFactory } from './factory/contributionLink'
|
||||
import { entities } from '@entity/index'
|
||||
import CONFIG from '@/config'
|
||||
|
||||
@ -77,6 +79,11 @@ const run = async () => {
|
||||
await transactionLinkFactory(seedClient, transactionLinks[i])
|
||||
}
|
||||
|
||||
// create Contribution Links
|
||||
for (let i = 0; i < contributionLinks.length; i++) {
|
||||
await contributionLinkFactory(seedClient, contributionLinks[i])
|
||||
}
|
||||
|
||||
await con.close()
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user