Funktionen-Seite: Preis und Bestelltexte aus dem Register
GET /api/funktionen liefert features.news und features.termine (oeffentlicheAnsicht, auch wenn der Terminplaner noch nicht freigegeben ist) und ustHinweis; setupEstimate und consentText bleiben als News-Alias. Die News-Kachel und die Buchungsseite lesen Preis, Knopftext und Zustimmungstext aus features.news und fallen ohne features auf die bisherigen Werte zurueck. News sendet weiter consent: true an /api/funktionen/news/checkout. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f57dad73ca
commit
cf9f9b30a0
4 files changed
+186
-13
No files matched your search
@@ -67,6 +67,66 @@ test('liste_zustaende', async () => {
|
||||
// Terminplaner: zweite Funktion je Projekt, Schalter TERMINE_ENABLED (Vorgabe off) - Einzelheiten in funktionenTermine.test.js
|
||||
for (const p of body.projects) assert.equal(p.features.termine.state, 'off')
|
||||
assert.deepEqual(body.termine, { verfuegbar: false })
|
||||
|
||||
// Register-Ansicht (B12): Preise und Bestelltexte beider Funktionen aus config.features, auch bei termine.verfuegbar: false
|
||||
assert.deepEqual(Object.keys(body.features).sort(), ['news', 'termine'])
|
||||
assert.equal(body.features.news.priceLabel, '30 €')
|
||||
assert.equal(body.features.termine.priceLabel, '149 €')
|
||||
assert.equal(body.ustHinweis, config.ustHinweis)
|
||||
assert.ok(typeof body.ustHinweis === 'string' && body.ustHinweis.length > 0)
|
||||
// Items vollstaendig: Kennung, Wortlaut und Haken jedes Registerpunkts, dazu Fassung und Knopf
|
||||
for (const key of ['news', 'termine']) {
|
||||
const eintrag = config.features[key]
|
||||
const ansicht = body.features[key]
|
||||
assert.equal(ansicht.key, key)
|
||||
assert.equal(ansicht.name, eintrag.label.name)
|
||||
assert.equal(ansicht.setupEstimate, eintrag.setupEstimate)
|
||||
assert.equal(ansicht.consent.version, eintrag.consent.version)
|
||||
assert.equal(ansicht.consent.knopf, eintrag.consent.knopf)
|
||||
assert.ok(eintrag.consent.items.length > 0)
|
||||
assert.deepEqual(
|
||||
ansicht.consent.items,
|
||||
eintrag.consent.items.map((item) => ({ id: item.id, text: item.text, haken: item.haken === true })),
|
||||
)
|
||||
assert.equal(ansicht.requiresWartungsAbo, eintrag.requiresWartungsAbo)
|
||||
assert.equal(ansicht.returnHash, eintrag.returnHash)
|
||||
// nichts Internes: nur die oeffentlichen Felder (kein ticket, keine mails, keine Haken oder Meldungen)
|
||||
assert.deepEqual(Object.keys(ansicht).sort(), [
|
||||
'avv', 'consent', 'key', 'kurz', 'leistungsbeschreibung', 'name', 'priceLabel', 'requiresWartungsAbo', 'returnHash', 'setupEstimate', 'widerruf',
|
||||
])
|
||||
assert.deepEqual(Object.keys(ansicht.consent).sort(), ['items', 'knopf', 'version'])
|
||||
}
|
||||
assert.deepEqual(body.features.termine.consent.items.map((item) => item.id), ['unterlagen', 'gesundheit', 'beginn', 'information'])
|
||||
assert.deepEqual(body.features.news.consent.items.map((item) => item.id), ['beginn'])
|
||||
const flach = JSON.stringify(body.features)
|
||||
assert.equal(flach.includes('"ticket"') || flach.includes('"mails"'), false)
|
||||
// Alias: setupEstimate und consentText bleiben die News-Werte (Rueckfall aelterer Clients)
|
||||
assert.equal(body.setupEstimate, body.features.news.setupEstimate)
|
||||
assert.equal(body.consentText, body.features.news.consent.items[0].text)
|
||||
})
|
||||
|
||||
test('liste_register_ohne_freigabe: features.termine steht auch bei Schalter off und Pilot ohne Teilnahme', async () => {
|
||||
const vorher = { mode: config.termine.mode, pilotEmails: config.termine.pilotEmails }
|
||||
try {
|
||||
for (const [mode, pilotEmails] of [['off', []], ['pilot', ['andere@example.test']]]) {
|
||||
config.termine.mode = mode
|
||||
config.termine.pilotEmails = pilotEmails
|
||||
const body = await get('/api/funktionen', { cookie })
|
||||
assert.equal(body.termine.verfuegbar, false, mode)
|
||||
assert.equal(body.features.termine.priceLabel, '149 €', mode)
|
||||
assert.equal(body.features.termine.consent.items.length, config.features.termine.consent.items.length, mode)
|
||||
assert.equal(body.features.news.priceLabel, '30 €', mode)
|
||||
}
|
||||
// mit Freigabe dieselbe Ansicht
|
||||
config.termine.mode = 'pilot'
|
||||
config.termine.pilotEmails = ['*']
|
||||
const frei = await get('/api/funktionen', { cookie })
|
||||
assert.equal(frei.termine.verfuegbar, true)
|
||||
assert.equal(frei.features.termine.priceLabel, '149 €')
|
||||
} finally {
|
||||
config.termine.mode = vorher.mode
|
||||
config.termine.pilotEmails = vorher.pilotEmails
|
||||
}
|
||||
})
|
||||
|
||||
test('checkout_ohne_zustimmung_400', async () => {
|
||||
|
||||
Reference in new issue
Block a user