mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
added redeem register event test, transaction link execution failing
This commit is contained in:
parent
390bb1db3d
commit
b8442e1725
@ -24,6 +24,8 @@ import { EventProtocol } from '@entity/EventProtocol'
|
|||||||
import { logger } from '@test/testSetup'
|
import { logger } from '@test/testSetup'
|
||||||
import { validate as validateUUID, version as versionUUID } from 'uuid'
|
import { validate as validateUUID, version as versionUUID } from 'uuid'
|
||||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||||
|
import { TransactionLink } from '@entity/TransactionLink'
|
||||||
|
import { transactionLinkFactory } from '@/seeds/factory/transactionLink'
|
||||||
|
|
||||||
// import { klicktippSignIn } from '@/apis/KlicktippController'
|
// import { klicktippSignIn } from '@/apis/KlicktippController'
|
||||||
|
|
||||||
@ -261,13 +263,19 @@ describe('UserResolver', () => {
|
|||||||
const peter = await User.findOneOrFail({ id: user[0].id })
|
const peter = await User.findOneOrFail({ id: user[0].id })
|
||||||
peter.isAdmin = new Date()
|
peter.isAdmin = new Date()
|
||||||
await peter.save()
|
await peter.save()
|
||||||
|
|
||||||
|
// date statement
|
||||||
|
const actualDate = new Date()
|
||||||
|
const futureDate = new Date() // Create a future day from the executed day
|
||||||
|
futureDate.setDate(futureDate.getDate() + 1)
|
||||||
|
|
||||||
// factory logs in as Peter Lustig
|
// factory logs in as Peter Lustig
|
||||||
link = await contributionLinkFactory(testEnv, {
|
link = await contributionLinkFactory(testEnv, {
|
||||||
name: 'Dokumenta 2022',
|
name: 'Dokumenta 2022',
|
||||||
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2022',
|
memo: 'Vielen Dank für deinen Besuch bei der Dokumenta 2022',
|
||||||
amount: 200,
|
amount: 200,
|
||||||
validFrom: new Date(2022, 5, 18),
|
validFrom: actualDate,
|
||||||
validTo: new Date(2022, 8, 25),
|
validTo: futureDate,
|
||||||
})
|
})
|
||||||
resetToken()
|
resetToken()
|
||||||
await mutate({
|
await mutate({
|
||||||
@ -292,6 +300,39 @@ describe('UserResolver', () => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('stores the redeem register event in the database', () => {
|
||||||
|
expect(EventProtocol.find()).resolves.toContainEqual(
|
||||||
|
expect.objectContaining({
|
||||||
|
type: EventProtocolType.REDEEM_REGISTER,
|
||||||
|
userId: expect.any(Number), // as it is randomly generated
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('transaction link', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
await transactionLinkFactory(testEnv, {
|
||||||
|
email: 'peter@lustig.de',
|
||||||
|
amount: 19.99,
|
||||||
|
memo: `Kein Trick, keine Zauberrei,
|
||||||
|
bei Gradidio sei dabei!`,
|
||||||
|
})
|
||||||
|
|
||||||
|
const transactionLink = await TransactionLink.findOneOrFail()
|
||||||
|
resetToken()
|
||||||
|
await mutate({
|
||||||
|
mutation: createUser,
|
||||||
|
variables: { ...variables, email: 'neuer@user.de', redeemCode: transactionLink.code },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets the referrer id to Peter Lustigs id', () => {
|
||||||
|
expect(User.findOne({ email: 'neuer@user.de' })).resolves.toEqual(
|
||||||
|
expect.objectContaining({ referrerId: user[0].id }),
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
/* A transaction link requires GDD on account
|
/* A transaction link requires GDD on account
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user