Funktionen: Bestellung serialisiert, Sitzung nachtragen, Freischaltung einmalig
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0cc35bf1a5
commit
8374a570aa
3 files changed
+120
-34
No files matched your search
@@ -178,3 +178,38 @@ test('aktivierung_mailt', async () => {
|
||||
assert.deepEqual(await sf.runActivation(), [])
|
||||
assert.equal(mails.sent.length - mailsBefore, 1)
|
||||
})
|
||||
|
||||
test('parallele_checkouts_eine_sitzung', async () => {
|
||||
aw.seed('websiteProjects', { $id: 'p8', customerId: 'c1', projectName: 'Gärtnerei' })
|
||||
const before = sessions().length
|
||||
const results = await Promise.all([checkout('p8'), checkout('p8')])
|
||||
assert.deepEqual(results.map((r) => r.status).sort(), [200, 409])
|
||||
assert.equal(sessions().length, before + 1)
|
||||
})
|
||||
|
||||
test('bezahlte_sitzung_mit_ueberschriebener_id_wird_zugeordnet', async () => {
|
||||
aw.seed('websiteProjects', { $id: 'p9', customerId: 'c1', projectName: 'Tischlerei' })
|
||||
await checkout('p9')
|
||||
const paidId = sessions().at(-1).id
|
||||
const doc = await sf.getFeatureDoc('c1', 'p9', 'news')
|
||||
aw.seed('portalFeatures', { ...aw.docs('portalFeatures').get(doc.$id), stripeSessionId: 'cs_ueberschrieben' })
|
||||
const wosBefore = workorders().length
|
||||
assert.equal((await postWebhook(event('checkout.session.completed', paidSession(paidId, 'p9')))).status, 200)
|
||||
const after = await sf.getFeatureDoc('c1', 'p9', 'news')
|
||||
assert.equal(after.state, 'setup')
|
||||
assert.equal(after.stripeSessionId, paidId)
|
||||
assert.equal(workorders().length, wosBefore + 1)
|
||||
})
|
||||
|
||||
test('parallele_aktivierung_mailt_einmal', async () => {
|
||||
aw.seed('websiteProjects', { $id: 'p10', customerId: 'c1', projectName: 'Schreinerei' })
|
||||
await checkout('p10')
|
||||
const id = sessions().at(-1).id
|
||||
await postWebhook(event('checkout.session.completed', paidSession(id, 'p10')))
|
||||
const doc = await sf.getFeatureDoc('c1', 'p10', 'news')
|
||||
aw.seed('workorders', { ...aw.docs('workorders').get(doc.ticketId), status: 'Closed' })
|
||||
const mailsBefore = mails.sent.length
|
||||
const [a, b] = await Promise.all([sf.runActivation(), sf.runActivation({ customerId: 'c1' })])
|
||||
assert.equal(a.length + b.length, 1)
|
||||
assert.equal(mails.sent.slice(mailsBefore).filter((m) => m.subject === 'Deine News-Pinnwand ist bereit').length, 1)
|
||||
})
|
||||
Reference in new issue
Block a user