Übernahmegutschrift: Verrechnung nach Wechsel, Mail K09, Leitfaden, Admin zeigt das Abo, Tests
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c2e50fc20
commit
e456c3de69
9 files changed
+80
-23
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
|
||||
// runAutoChecks arbeitet ohne Domain komplett offline (kein DNS-Abgleich, kein Appwrite, kein Stripe):
|
||||
// Die Pruefung vergleicht den Monatsbetrag beim bisherigen Anbieter mit der Monatsgebuehr des Abos des Kunden.
|
||||
const { runAutoChecks } = await import('../server/services/takeoverCredits.js')
|
||||
|
||||
// 240 € fuer 12 Monate = 20,00 € pro Monat: mehr als das Hosting-Abo (15,00 €), weniger als das Wartungs-Abo (50,00 €)
|
||||
const doc = { $id: 'req1', $createdAt: '2026-10-01T10:00:00.000Z', domain: '', invoiceAmountCents: 24000, billingMonths: 12, files: '[]' }
|
||||
const sub = (productKey) => ({
|
||||
status: 'active',
|
||||
startedAt: '2026-10-01T00:00:00.000Z',
|
||||
currentPeriodEnd: '2026-11-01T00:00:00.000Z',
|
||||
...(productKey === undefined ? {} : { productKey }),
|
||||
})
|
||||
const amountCheck = async (subscription) =>
|
||||
(await runAutoChecks(doc, { allRequests: [], subscription, calc: null })).find((c) => c.key === 'amount')
|
||||
|
||||
test('Plausibilität: 20 € pro Monat ist mehr als das Hosting-Abo (15,00 €)', async () => {
|
||||
const hosting = await amountCheck(sub('hosting'))
|
||||
assert.ok(hosting, 'Hinweis „mehr als die Monatsgebühr“ fehlt beim Hosting-Abo')
|
||||
assert.equal(hosting.status, 'info')
|
||||
assert.ok(hosting.label.includes('15,00'), hosting.label)
|
||||
assert.ok(hosting.label.includes('20,00'), hosting.label)
|
||||
})
|
||||
|
||||
test('Plausibilität: 20 € pro Monat ist nicht mehr als das Wartungs-Abo (50,00 €)', async () => {
|
||||
assert.equal(await amountCheck(sub('wartung')), undefined)
|
||||
})
|
||||
|
||||
test('Abos ohne oder mit unbekanntem productKey gelten als Wartungs-Abo, ohne Abo ebenso', async () => {
|
||||
assert.equal(await amountCheck(sub(undefined)), undefined, 'Altbestand ohne productKey')
|
||||
assert.equal(await amountCheck(sub('gibtsnicht')), undefined, 'unbekannter productKey darf die Prüfung nicht abbrechen')
|
||||
const ohneAbo = await runAutoChecks(doc, { allRequests: [], subscription: null, calc: null })
|
||||
assert.equal(ohneAbo.find((c) => c.key === 'amount'), undefined)
|
||||
assert.equal(ohneAbo.find((c) => c.key === 'abo')?.status, 'warn')
|
||||
})
|
||||
Reference in new issue
Block a user