Test that when an admin user create a contribution in FE he can not delete it in admin interface.

This commit is contained in:
elweyn 2022-09-24 11:32:07 +02:00
parent e7b5400db2
commit 6df8b9a83f

View File

@ -16,6 +16,7 @@ import {
setUserRole,
deleteUser,
unDeleteUser,
createContribution,
adminCreateContribution,
adminCreateContributions,
adminUpdateContribution,
@ -77,6 +78,7 @@ afterAll(async () => {
let admin: User
let user: User
let creation: Contribution | void
let result: any
describe('AdminResolver', () => {
describe('set user role', () => {
@ -1360,6 +1362,38 @@ describe('AdminResolver', () => {
})
})
describe('admin deletes own user contribution', () => {
beforeAll(async () => {
await query({
query: login,
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
})
result = await mutate({
mutation: createContribution,
variables: {
amount: 100.0,
memo: 'Test env contribution',
creationDate: new Date().toString(),
},
})
})
it('throws an error', async () => {
await expect(
mutate({
mutation: adminDeleteContribution,
variables: {
id: result.data.createContribution.id,
},
}),
).resolves.toEqual(
expect.objectContaining({
errors: [new GraphQLError('Own contribution can not be deleted as admin')],
}),
)
})
})
describe('creation id does exist', () => {
it('returns true', async () => {
await expect(