Analyse: Einschalten im WOMS nur mit Datum und Weg der Zustimmung in Textform

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-01 19:02:05 +00:00
1 parent 72f07410fe
commit 52968b3017
4 files changed
+183 -21

No files matched your search

+53 -3
View File
@@ -2,7 +2,7 @@ import test from 'node:test'
import assert from 'node:assert/strict'
import { loadModule } from './load.mjs'
const { analyseStatus, avvLabel } = await loadModule('src/lib/analyseView.js')
const { analyseStatus, textformLabel, canSubmitTextform, channelLabel, analyseSetBody, legalLinks, chatTemplate, privacyHint } = await loadModule('src/lib/analyseView.js')
test('analyseStatus: Schalter aus => noch nicht freigeschaltet, kein Button', () => {
const s = analyseStatus({ enabled: false })
@@ -48,6 +48,56 @@ test('analyseStatus: robust bei leerer Antwort', () => {
assert.equal(analyseStatus(null).text, '')
})
test('avvLabel nennt die Fassung', () => {
assert.equal(avvLabel('2026-10-01'), 'Der Kunde hat den Auftragsverarbeitungsvertrag (Fassung 2026-10-01) bestätigt')
test('textformLabel nennt die Fassung und die Zielgruppen-Bestaetigung', () => {
const t = textformLabel('2026-10-02')
assert.match(t.after, /\(Fassung 2026-10-02\) in Textform zugestimmt und bestätigt, dass seine Website sich nicht gezielt an Kinder unter 16 Jahren richtet\.$/)
assert.equal(t.avv, 'AVV Website-Analyse')
assert.equal(t.lb, 'Leistungsbeschreibung Website-Analyse')
})
const ok = { confirmed: true, date: '2026-10-02', channel: 'email', today: '2026-10-03', minDate: '2026-10-02' }
test('canSubmitTextform: alles gueltig => true (Grenzen eingeschlossen)', () => {
assert.equal(canSubmitTextform(ok), true)
assert.equal(canSubmitTextform({ ...ok, channel: 'chat', date: '2026-10-03' }), true)
})
test('canSubmitTextform: fehlende oder ungueltige Angaben => false', () => {
assert.equal(canSubmitTextform({ ...ok, confirmed: false }), false)
assert.equal(canSubmitTextform({ ...ok, date: '' }), false)
assert.equal(canSubmitTextform({ ...ok, channel: '' }), false)
assert.equal(canSubmitTextform({ ...ok, channel: 'telefon' }), false)
assert.equal(canSubmitTextform({ ...ok, date: '2026-10-01' }), false)
assert.equal(canSubmitTextform({ ...ok, date: '2026-10-04' }), false)
assert.equal(canSubmitTextform({ ...ok, date: 'morgen' }), false)
})
test('channelLabel', () => {
assert.equal(channelLabel('chat'), 'Chat im Kundenportal')
assert.equal(channelLabel('email'), 'E-Mail')
assert.equal(channelLabel('x'), '')
})
test('analyseStatus: aktiv zeigt Zustimmung in Textform', () => {
const t = analyseStatus({ enabled: true, state: 'active', eligible: true, activatedAt: '2026-10-03T08:00:00Z', avvConsentDate: '2026-10-02', avvConsentChannel: 'email' }).text
assert.ok(t.includes('An seit 03.10.2026'))
assert.ok(t.includes('Zustimmung in Textform am 02.10.2026 per E-Mail'))
})
test('analyseSetBody sendet Textform-Felder und kein avvConfirmedVerbally', () => {
const b = analyseSetBody({ on: true, textformDate: '2026-10-02', textformChannel: 'chat', audienceConfirmed: true })
assert.deepEqual(b, { on: true, textformDate: '2026-10-02', textformChannel: 'chat', audienceConfirmed: true })
assert.deepEqual(analyseSetBody({ on: false }), { on: false })
})
test('legalLinks und chatTemplate fuellen echte Links', () => {
const l = legalLinks('2026-10-02')
assert.equal(l.avv, 'https://project.webklar.com/rechtliches/avv-website-analyse-2026-10-02.html')
assert.equal(l.lb, 'https://project.webklar.com/rechtliches/leistungsbeschreibung-website-analyse-2026-10-02.html')
const t = chatTemplate('2026-10-02')
assert.ok(t.includes(l.avv) && t.includes(l.lb))
assert.ok(!t.includes('{Link'))
})
test('privacyHint nennt fehlende Felder', () => {
assert.equal(privacyHint({ ok: true, missing: [] }), '')
assert.match(privacyHint({ ok: false, missing: ['firma', 'email'] }), /Firma.*E-Mail/)
})