This commit is contained in:
@@ -173,4 +173,26 @@ describe('Pot API', async () => {
|
||||
$fetch(`/api/pots/${pot.slug}/participants/${alice.id}`, { method: 'PATCH', body: { paymentLink: 'javascript:alert(1)' } }),
|
||||
).rejects.toMatchObject({ statusCode: 400 })
|
||||
})
|
||||
|
||||
it('removes a participant without expenses but blocks removing one with expenses', async () => {
|
||||
const pot = await $fetch('/api/pots', { method: 'POST', body: { name: 'Ski Trip', currency: 'EUR', creatorName: 'Alice' } })
|
||||
const alice = pot.creator
|
||||
const bob = await $fetch(`/api/pots/${pot.slug}/participants`, { method: 'POST', body: { name: 'Bob' } })
|
||||
|
||||
await $fetch(`/api/pots/${pot.slug}/expenses`, {
|
||||
method: 'POST',
|
||||
body: { description: 'Lift pass', amountCents: 1000, payerId: alice.id, participantIds: [alice.id, bob.id] },
|
||||
})
|
||||
|
||||
await expect(
|
||||
$fetch(`/api/pots/${pot.slug}/participants/${bob.id}`, { method: 'DELETE' }),
|
||||
).rejects.toMatchObject({ statusCode: 409 })
|
||||
|
||||
const carol = await $fetch(`/api/pots/${pot.slug}/participants`, { method: 'POST', body: { name: 'Carol' } })
|
||||
const result = await $fetch(`/api/pots/${pot.slug}/participants/${carol.id}`, { method: 'DELETE' })
|
||||
expect(result.success).toBe(true)
|
||||
|
||||
const fetched = await $fetch(`/api/pots/${pot.slug}`)
|
||||
expect(fetched.participants.map(p => p.id)).not.toContain(carol.id)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user