Add Test that adminUpdateContribution is not allowed on creation made by createContribution mutation.

This commit is contained in:
elweyn 2022-07-13 08:26:30 +02:00
parent 32d79bb61c
commit c6bab99a2c

View File

@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
import { createContribution, updateContribution } from '@/seeds/graphql/mutations'
import { adminUpdateContribution, createContribution, updateContribution } from '@/seeds/graphql/mutations'
import { listContributions, login } from '@/seeds/graphql/queries'
import { cleanDB, resetToken, testEnvironment } from '@test/helpers'
import { GraphQLError } from 'graphql'
@ -332,6 +332,27 @@ describe('ContributionResolver', () => {
})
})
describe('admin tries to update a user contribution', () => {
it('throws an error', async () => {
await expect(
mutate({
mutation: adminUpdateContribution,
variables: {
id: result.data.createContribution.id,
email: 'bibi@bloxberg.de',
amount: 10.0,
memo: 'Test env contribution',
creationDate: new Date().toString(),
},
}),
).resolves.toEqual(
expect.objectContaining({
errors: [new GraphQLError('An admin is not allowed to update a user contribution.')],
}),
)
})
})
describe('update too much so that the limit is exceeded', () => {
beforeAll(async () => {
await query({