Abo-API: Nachweis-ID nach Appwrite-Regeln, Webhook bei dauerhaften Fehlern, Tests
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
7df0b72019
commit
887e1e54a0
10 files changed
+409
-107
No files matched your search
@@ -29,6 +29,27 @@ test('Appwrite-Nachbau: Schema wie Appwrite', async () => {
|
||||
await assert.rejects(createDocument('subscriptions', { unbekannt: 1 }, 'sub_b'), (e) => e.status === 400)
|
||||
})
|
||||
|
||||
// Appwrite 1.8: Dokument-IDs hoechstens 36 Zeichen aus a-z, A-Z, 0-9, Punkt, Bindestrich, Unterstrich,
|
||||
// nicht mit einem Sonderzeichen beginnend - sonst 400 (Task 7, Fix 1)
|
||||
test('Appwrite-Nachbau: Dokument-ID nach Appwrite-Regeln', async () => {
|
||||
const tooLong = 'abschluss-sub_1SD6vPRxAbCdEfGhIjKlMnOp' // 38 Zeichen
|
||||
await assert.rejects(createDocument('subscriptions', { customerId: 'c1' }, tooLong), (e) => e.status === 400 && /documentId/.test(e.message))
|
||||
await assert.rejects(createDocument('subscriptions', { customerId: 'c1' }, '-abc'), (e) => e.status === 400)
|
||||
await assert.rejects(createDocument('subscriptions', { customerId: 'c1' }, 'abc/def'), (e) => e.status === 400)
|
||||
const ok = await createDocument('subscriptions', { customerId: 'c1' }, `abschluss-${'f'.repeat(26)}`)
|
||||
assert.equal(ok.$id.length, 36)
|
||||
})
|
||||
|
||||
test('Appwrite-Nachbau: failNext liefert einmal den gewuenschten Fehler', async () => {
|
||||
aw.failNext({ collection: 'subscriptions', method: 'POST', status: 500 })
|
||||
await assert.rejects(createDocument('subscriptions', { customerId: 'c9' }, 'sub_fail'), (e) => e.status === 500)
|
||||
assert.equal((await createDocument('subscriptions', { customerId: 'c9' }, 'sub_fail')).$id, 'sub_fail')
|
||||
// Nur die passende Anfrage scheitert; andere Collections/Methoden laufen durch
|
||||
aw.failNext({ collection: 'hourCredits', method: 'POST', status: 404 })
|
||||
assert.equal((await getDocument('subscriptions', 'sub_fail')).$id, 'sub_fail')
|
||||
await assert.rejects(createDocument('hourCredits', { customerId: 'c9' }, 'hc_1'), (e) => e.status === 404)
|
||||
})
|
||||
|
||||
test('Stripe-Nachbau: getStripe spricht mit 127.0.0.1', async () => {
|
||||
st.subscriptions.set('sub_1', { id: 'sub_1', object: 'subscription', items: { object: 'list', data: [] } })
|
||||
assert.equal((await getStripe().subscriptions.retrieve('sub_1')).id, 'sub_1')
|
||||
|
||||
Reference in new issue
Block a user