mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
test that second creation throws when not waiting for first to be completed
This commit is contained in:
parent
201e952c08
commit
9c00e5b592
@ -1053,6 +1053,53 @@ describe('AdminResolver', () => {
|
||||
expect(transaction[0].typeId).toEqual(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('confirm two creations one after the other quickly', () => {
|
||||
let c1: AdminPendingCreation | void
|
||||
let c2: AdminPendingCreation | void
|
||||
|
||||
beforeAll(async () => {
|
||||
const now = new Date()
|
||||
c1 = await creationFactory(testEnv, {
|
||||
email: 'bibi@bloxberg.de',
|
||||
amount: 50,
|
||||
memo: 'Herzlich Willkommen bei Gradido liebe Bibi!',
|
||||
creationDate: new Date(now.getFullYear(), now.getMonth() - 2, 1).toISOString(),
|
||||
})
|
||||
c2 = await creationFactory(testEnv, {
|
||||
email: 'bibi@bloxberg.de',
|
||||
amount: 50,
|
||||
memo: 'Herzlich Willkommen bei Gradido liebe Bibi!',
|
||||
creationDate: new Date(now.getFullYear(), now.getMonth() - 2, 1).toISOString(),
|
||||
})
|
||||
})
|
||||
|
||||
// In the futrue this should not throw anymore
|
||||
it('throws an error for the second confirmation', async () => {
|
||||
const r1 = mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
variables: {
|
||||
id: c1 ? c1.id : -1,
|
||||
},
|
||||
})
|
||||
const r2 = mutate({
|
||||
mutation: confirmPendingCreation,
|
||||
variables: {
|
||||
id: c2 ? c2.id : -1,
|
||||
},
|
||||
})
|
||||
await expect(r1).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { confirmPendingCreation: true },
|
||||
}),
|
||||
)
|
||||
await expect(r2).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
errors: [new GraphQLError('Unable to confirm creation.')],
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -362,8 +362,7 @@ export class AdminResolver {
|
||||
transaction.decay = decay ? decay.decay : new Decimal(0)
|
||||
transaction.decayStart = decay ? decay.start : null
|
||||
await transaction.save().catch(() => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Unable to save transaction.')
|
||||
throw new Error('Unable to confirm creation.')
|
||||
})
|
||||
|
||||
await AdminPendingCreation.delete(pendingCreation)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user