Terminplaner: Kurzfassung der Einbauanleitung fuer das Einrichtungs-Ticket, T16-Gesundheitsblock

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Sonnet 5.5 committed 2026-10-05 00:45:56 +00:00
1 parent 90692b646b
commit 2db3eca357
9 files changed
+1181 -49

No files matched your search

+73 -1
View File
@@ -31,7 +31,7 @@ const { leerFragebogen, normalisiereFragebogen, FRAGEBOGEN_MAX } = await import(
const { activate } = await import('../server/services/siteFeatures.js')
const K = await import('../server/services/termine/kontext.js')
const M = await import('../server/services/termine/mails.js')
const { ladeEinstellung, speichereEinstellung, speichereFragebogen, kontextPerSiteKey, kontextPerFeature, kontextFuerPortal, websiteUrl, liveHost, resetKontextForTests } = K
const { ladeEinstellung, ladeStand, speichereEinstellung, speichereFragebogen, kontextPerSiteKey, kontextPerFeature, kontextFuerPortal, websiteUrl, liveHost, resetKontextForTests } = K
const { BETREFFE, werteFuer, anGast, anBetrieb } = M
after(() => setMailTransportForTests(null))
@@ -266,6 +266,78 @@ test('ladeEinstellung: unlesbares JSON gilt als nicht gespeichert (mit Log); feh
})
})
// ---------------------------------------------------------------- ladeStand (TP2 D4: Stand fuer das Einrichtungs-Ticket)
test('ladeStand: ohne termineConfig-Dokument null, mit Dokument Einstellung, Version, updatedAt und der Fragebogen als gespeicherte Angaben', async () => {
assert.equal(await ladeStand(FEATURE), null, 'noch nichts gespeichert')
const e = einstellung()
const fb = frage({ branche: 'salon', bestaetigt: ['branche'], einbau: { modus: 'knopf', knopfText: 'Termin buchen', stelle: 'Startseite' } })
await speichereEinstellung(feature(), e, { version: 0, now: JETZT, fragebogen: fb })
const stand = await ladeStand(FEATURE)
assert.deepEqual(Object.keys(stand).sort(), ['einstellung', 'fragebogen', 'updatedAt', 'version'])
assert.deepEqual(stand.einstellung, e)
assert.equal(stand.version, 1)
assert.equal(new Date(stand.updatedAt).getTime(), JETZT.getTime())
assert.deepEqual(stand.fragebogen, JSON.parse(gespeichert().fragebogen))
assert.equal(stand.fragebogen.einbau.knopfText, 'Termin buchen')
await speichereEinstellung(feature(), einstellung({ betrieb: betriebMit({ name: 'Salon Neu' }) }), { version: 1, now: SEKUNDEN(60) })
const zweit = await ladeStand(FEATURE)
assert.equal(zweit.version, 2)
assert.equal(zweit.einstellung.betrieb.name, 'Salon Neu')
assert.equal(new Date(zweit.updatedAt).getTime(), SEKUNDEN(60).getTime())
assert.deepEqual(zweit.fragebogen, stand.fragebogen, 'der Fragebogen bleibt, wenn nur die Einstellung gespeichert wird')
assert.equal(log.error.mock.callCount(), 0, 'lesbare Dokumente: keine Logzeile')
})
test('ladeStand: kaputtes fragebogen-JSON gibt fragebogen null bei gueltiger Einstellung (mit Log), kaputte Einstellung gibt einstellung null mit der Version', async () => {
const e = einstellung()
aw.seed('termineConfig', { $id: FEATURE, customerId: KUNDE, projectId: PROJEKT, einstellung: JSON.stringify(e), version: 2, updatedAt: JETZT.toISOString(), updatedBy: '', fragebogen: '{kaputt' })
const stand = await ladeStand(FEATURE)
assert.deepEqual(stand.einstellung, e)
assert.equal(stand.fragebogen, null)
assert.equal(stand.version, 2)
assert.equal(log.error.mock.callCount(), 1)
assert.match(String(log.error.mock.calls[0].arguments[0]), /Fragebogen f_p_projekt01_termine/)
const fb = frage({ branche: 'salon' })
await deleteDocument('termineConfig', FEATURE)
aw.seed('termineConfig', { $id: FEATURE, customerId: KUNDE, projectId: PROJEKT, einstellung: '{kaputt', version: 3, updatedAt: JETZT.toISOString(), updatedBy: '', fragebogen: JSON.stringify(fb) })
const kaputt = await ladeStand(FEATURE)
assert.equal(kaputt.einstellung, null)
assert.equal(kaputt.version, 3, 'die Version des Dokuments bleibt')
assert.deepEqual(kaputt.fragebogen, fb)
assert.equal(log.error.mock.callCount(), 2)
})
test('ladeStand: fehlendes oder leeres fragebogen-Attribut, ein Nicht-Objekt und fehlende Zeit ergeben null; Version ohne Zahl ist 0', async () => {
const e = einstellung()
const doc = { $id: FEATURE, customerId: KUNDE, projectId: PROJEKT, einstellung: JSON.stringify(e), version: 1, updatedAt: JETZT.toISOString(), updatedBy: '' }
for (const fragebogen of [undefined, null, '']) {
await deleteDocument('termineConfig', FEATURE).catch(() => {})
aw.seed('termineConfig', { ...doc, ...(fragebogen === undefined ? {} : { fragebogen }) })
assert.equal((await ladeStand(FEATURE)).fragebogen, null, String(fragebogen))
}
assert.equal(log.error.mock.callCount(), 0, 'nichts gespeichert ist kein Fehler')
for (const roh of ['[1,2]', '"text"', '42', 'null']) {
await deleteDocument('termineConfig', FEATURE)
aw.seed('termineConfig', { ...doc, fragebogen: roh })
assert.equal((await ladeStand(FEATURE)).fragebogen, null, roh)
}
await deleteDocument('termineConfig', FEATURE)
aw.seed('termineConfig', { $id: FEATURE, customerId: KUNDE, projectId: PROJEKT, einstellung: JSON.stringify(e) })
const ohneZeit = await ladeStand(FEATURE)
assert.equal(ohneZeit.updatedAt, null)
assert.equal(ohneZeit.version, 0)
assert.deepEqual(ohneZeit.einstellung, e)
})
test('ladeStand: Eingabepruefung wie ladeEinstellung, fehlende Collection ist ein Fehler und kein "nichts"', async () => {
for (const id of [undefined, null, '', 7]) await assert.rejects(() => ladeStand(id), TypeError, String(id))
await mitFehlenderCollection('termineConfig', async () => {
await assert.rejects(() => ladeStand(FEATURE), (err) => err.status === 404 && err.type === 'collection_not_found')
})
})
test('R40 speichereEinstellung mit Funktion: laeuft nach der Versionspruefung, bekommt die bisherige Einstellung (erst null), Ergebnis wird gespeichert', async () => {
const aufrufe = []
const erste = einstellung({ betrieb: betriebMit({ name: 'Erste' }) })