Files
Webklar-Kundenbereich/test/takeoverCredits.test.js
T
ClaudeandClaude Opus 5.5 e4efdac226 Hosting-Abo: Preis 15 € -> 20 € pro Monat (Vertragsbedingungen v4, Katalog, Leitfaden)
- server/config.js: amountCents 2000, lookup_key webklar_hosting_monatlich_2000
- ensurePrice haengt einen neuen Preis an das vorhandene Stripe-Produkt (metadata.webklar),
  statt ein zweites "WEBklar Hosting-Abo" anzulegen
- abo-bedingungen.html (Uebersicht, Preise, Leistungsbeschreibung) + PDF, Leitfaden + PDF
- Tests auf 20 € umgestellt (399/399)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 16:29:01 +00:00

38 lines
2.1 KiB
JavaScript

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')
// 300 € fuer 12 Monate = 25,00 € pro Monat: mehr als das Hosting-Abo (20,00 €), weniger als das Wartungs-Abo (50,00 €)
const doc = { $id: 'req1', $createdAt: '2026-10-01T10:00:00.000Z', domain: '', invoiceAmountCents: 30000, 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: 25 € pro Monat ist mehr als das Hosting-Abo (20,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('20,00'), hosting.label)
assert.ok(hosting.label.includes('25,00'), hosting.label)
})
test('Plausibilität: 25 € 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')
})