Buchungskalender: Verdrahtung absichern (Outbox, Shop-Webhook, Session)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a68baf10d9
commit
d7b5b98187
6 files changed
+45
-4
No files matched your search
@@ -1283,7 +1283,7 @@ test('einreihen: optionaler Anhang-Verweis wird gespeichert (Senden unverändert
|
||||
const mit = await einreihen(eintrag({ bookingId: 'b_anhang', anhang: 'uk-rechnung:r_123' }), JETZT)
|
||||
assert.equal((await lies(mit.$id)).anhang, 'uk-rechnung:r_123')
|
||||
const ohne = await einreihen(eintrag({ bookingId: 'b_ohne' }), JETZT)
|
||||
assert.equal((await lies(ohne.$id)).anhang, '')
|
||||
assert.equal(Object.hasOwn(await lies(ohne.$id), 'anhang'), false, 'ohne Angabe wird das Feld nicht geschrieben')
|
||||
await assert.rejects(() => einreihen(eintrag({ anhang: 'x'.repeat(501) }), JETZT), TypeError)
|
||||
await warteAufVersand()
|
||||
assert.equal(tr.senke.sent.length, 2, 'Versand nicht verändert')
|
||||
|
||||
@@ -29,7 +29,8 @@ const jobs = await import('../server/services/unterkunft/jobs.js')
|
||||
const { default: publicRoutes } = await import('../server/routes/publicUnterkunft.js')
|
||||
const { default: webhookRoutes } = await import('../server/routes/shopWebhook.js')
|
||||
const W = await import('../server/routes/unterkunftWebhook.js')
|
||||
const app = await startTestApp({ '/api/public/unterkunft/v1': publicRoutes, '/api/shop/stripe-webhook': webhookRoutes })
|
||||
const { default: ukRoutes } = await import('../server/routes/unterkunft.js')
|
||||
const app = await startTestApp({ '/api/unterkunft': ukRoutes, '/api/public/unterkunft/v1': publicRoutes, '/api/shop/stripe-webhook': webhookRoutes })
|
||||
after(async () => {
|
||||
await app.close()
|
||||
await aw.close()
|
||||
@@ -284,3 +285,30 @@ test('Webhook: account.updated speichert den Status auch in ukEinstellungen mit
|
||||
assert.equal(await W.kontoAktualisiertUk('acct_unbekannt', konto, T0), 0)
|
||||
assert.equal(await W.kontoAktualisiertUk('kein-konto', konto, T0), 0)
|
||||
})
|
||||
|
||||
test('Kunden-API: ohne Sitzung 401 (Router-weiter Guard)', async () => {
|
||||
assert.equal((await rawGet('/api/unterkunft/status')).status, 401)
|
||||
})
|
||||
|
||||
test('Webhook: Shop-Erstattung ohne Uk-Metadaten geht nicht an Uk', async () => {
|
||||
config.shop.connectWebhookSecret = SECRET
|
||||
const gesehen = []
|
||||
W.setzeUkEreignisHandlerFuerTests(async (event) => void gesehen.push(event.type))
|
||||
const r = await postWebhook(ereignis('charge.refunded', { id: 'ch_9', payment_intent: null, metadata: { webklar: 'shop' } }), { path: PFAD, secret: SECRET })
|
||||
assert.equal(r.status, 200)
|
||||
assert.deepEqual(gesehen, [])
|
||||
})
|
||||
|
||||
test('Webhook: ein Fehler im Uk-Teil von account.updated lässt den Shop-Teil gelten und die Antwort 200', async () => {
|
||||
await leere()
|
||||
config.shop.connectWebhookSecret = SECRET
|
||||
config.unterkunft.mode = 'on'
|
||||
aw.seed('shopConfig', { $id: 'f_shop1', customerId: KUNDE, projectId: PROJEKT, siteKey: SITE_KEY, stripeAccountId: ACCOUNT, stripeStatus: JSON.stringify({ charges_enabled: false }), einstellungen: '{}', rechtstexte: '{}', version: 1 })
|
||||
// Uk-Abfrage scheitert: Index fehlt (400) bzw. Collection-Fehler
|
||||
mock.method(console, 'warn', () => {})
|
||||
aw.failNext({ collection: config.collections.ukEinstellungen, method: 'GET', status: 500 })
|
||||
const konto = { id: ACCOUNT, charges_enabled: true, payouts_enabled: true, details_submitted: true, requirements: { currently_due: [], past_due: [], disabled_reason: null } }
|
||||
const r = await postWebhook(ereignis('account.updated', konto), { path: PFAD, secret: SECRET })
|
||||
assert.equal(r.status, 200)
|
||||
assert.equal(JSON.parse(aw.docs('shopConfig').get('f_shop1').stripeStatus).charges_enabled, true)
|
||||
})
|
||||
Reference in new issue
Block a user