Kundenansicht P6: Widerruf des Wechsels beendet Wartungs-Funktionen, die Analyse bleibt
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d5a7312896
commit
df53cd039b
3 files changed
+104
-5
No files matched your search
@@ -1489,3 +1489,39 @@ test('K03: Abo-Modell-Dokument und alte Analyse zusammen: nur der neue Satz; Hos
|
||||
aw.resetListCalls(); assert.equal((await kuendigeMitK03()).text.includes(MODELL_SATZ), false); assert.equal(aw.listCalls('portalFeatures').length, 0)
|
||||
})
|
||||
})
|
||||
|
||||
// Kundenansicht P6 (Task 13): der Widerruf des Wechsels beendet die Funktionen des Abo-Modells, die nur im Wartungs-Abo stecken; die Analyse bleibt
|
||||
const NEU_MODUS = { mode: config.kundenansichtNeu.mode, pilotEmails: [...config.kundenansichtNeu.pilotEmails] }
|
||||
after(() => {
|
||||
config.kundenansichtNeu.mode = NEU_MODUS.mode
|
||||
config.kundenansichtNeu.pilotEmails = NEU_MODUS.pilotEmails
|
||||
})
|
||||
const pilot = (an) => { config.kundenansichtNeu.mode = an ? 'pilot' : 'off'; config.kundenansichtNeu.pilotEmails = ['k@example.invalid'] }
|
||||
const wm = (key, over = {}) => ({ $id: `wm_${key}`, customerId: 'c1', projectId: 'wf_pt', featureKey: key, siteKey: `wmkey${key}`.slice(0, 16).padEnd(16, '2'), state: 'active', enabled: true, activatedAt: daysAgo(10), unlockedBy: 'abo', unlockedByPurchase: false, einrichtungAbrechnung: 'abo', ...over })
|
||||
const wdoc = (id) => aw.docs('portalFeatures').get(id)
|
||||
const k39 = () => mails.sent.filter((m) => m.subject.startsWith('Deine Funktion wurde beendet'))
|
||||
const mitModell = async (keys, fn) => { for (const k of keys) aw.seed('portalFeatures', wm(k)); try { return await fn() } finally { for (const k of keys) await deleteDocument(config.collections.portalFeatures, `wm_${k}`).catch(() => {}) } }
|
||||
test('Widerruf Wechsel, neue Ansicht: alle Wartungs-Funktionen des Abo-Modells enden (abo_ende, K39 Hosting), Bestand und Analyse bleiben', async () => {
|
||||
pilot(true); await wartungSpiegel(); await wechselIn(3)
|
||||
aw.seed('portalFeatures', wm('shop', { $id: 'wm_shop_p', projectId: 'wf_p2', unlockedBy: 'projekt', einrichtungAbrechnung: 'projekt' })); aw.seed('portalFeatures', wm('news', { $id: 'wm_kauf', projectId: 'wf_p3', unlockedBy: 'kauf', unlockedByPurchase: true, einrichtungAbrechnung: '' }))
|
||||
await mitModell(['news', 'termine', 'shop', 'unterkunft', 'zeiten'], () => withActiveAnalyse(async (stops) => {
|
||||
const res = await withdraw({ order: 'wechsel' }); assert.equal(res.status, 200, JSON.stringify(res.body))
|
||||
for (const id of ['wm_news', 'wm_termine', 'wm_shop', 'wm_unterkunft', 'wm_zeiten', 'wm_shop_p']) assert.deepEqual([wdoc(id).state, wdoc(id).disabledReason, wdoc(id).adminNote], ['disabled', 'abo_ende', 'Abgeschaltet: Wechsel widerrufen'], id)
|
||||
assert.equal(wdoc('wm_kauf').state, 'active'); assert.deepEqual(stops, []); assert.equal(wdoc('wf_feat').state, 'active'); assert.equal(bySubject('Deine Website-Analyse wurde beendet'), null)
|
||||
assert.equal(k39().length, 5); assert.ok(k39().every((m) => /ein Hosting-Abo reicht dafür nicht/.test(m.text))); assert.ok(k04() && t09()) // zeiten: K41 kommt vom Zeiten-Abgleich
|
||||
}))
|
||||
for (const id of ['wm_shop_p', 'wm_kauf']) await deleteDocument(config.collections.portalFeatures, id).catch(() => {})
|
||||
})
|
||||
test('Widerruf Wechsel, alte Ansicht: Analyse endet wie bisher', async () => {
|
||||
pilot(false); await wartungSpiegel(); await wechselIn(3)
|
||||
await withActiveAnalyse(async (stops) => { assert.equal((await withdraw({ order: 'wechsel' })).status, 200); assert.deepEqual(stops, ['wfsitekey0123456789']); assert.equal(wdoc('wf_feat').state, 'off') })
|
||||
})
|
||||
test('Widerruf Wechsel: scheitert eine Abschaltung, bleibt der Widerruf 200 und die übrigen enden; der Tagesabgleich holt die letzte nach', async (t) => {
|
||||
const { gleicheAboFunktionenAb } = await import('../server/services/aboFunktionenAbgleich.js')
|
||||
t.mock.method(console, 'error', () => {}); pilot(true); await wartungSpiegel(); await wechselIn(3)
|
||||
await mitModell(['news', 'termine', 'shop'], async () => {
|
||||
aw.failNext({ collection: 'portalFeatures', method: 'PATCH', status: 500, message: 'kaputt' })
|
||||
assert.equal((await withdraw({ order: 'wechsel' })).status, 200); assert.equal(['wm_news', 'wm_termine', 'wm_shop'].filter((id) => wdoc(id).state === 'active').length, 1); assert.equal((await events('wechsel'))[0].status, 'widerrufen')
|
||||
await gleicheAboFunktionenAb(new Date()); assert.equal(['wm_news', 'wm_termine', 'wm_shop'].filter((id) => wdoc(id).state === 'active').length, 0); assert.equal(k39().length, 3)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user