From b77c3291c58e40c577483f539a5e2dadedd4b5eb Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 16 Oct 2026 16:50:49 +0000 Subject: [PATCH] =?UTF-8?q?Kundenansicht=20neu=20P2:=20Wortlaut-Orakel=20f?= =?UTF-8?q?=C3=BCr=20die=20Texte=20der=20Fassung=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- test/knAnsichtOrakel.test.js | 22 ++++++ test/support/knWortlautOrakel.js | 125 +++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 test/knAnsichtOrakel.test.js create mode 100644 test/support/knWortlautOrakel.js diff --git a/test/knAnsichtOrakel.test.js b/test/knAnsichtOrakel.test.js new file mode 100644 index 0000000..db3be66 --- /dev/null +++ b/test/knAnsichtOrakel.test.js @@ -0,0 +1,22 @@ +import { test } from 'node:test' +import assert from 'node:assert/strict' +import { sichtbarerText, ohneKopf, ladeAlteApp } from './support/knWortlautOrakel.js' +import { aboAntwort, abo, VORSCHAU, LIMITS } from './support/knDaten.js' + +test('sichtbarerText: Tags, Skripte und jeder Leerraum fallen weg, Entitäten werden Text', () => { + assert.equal(sichtbarerText('

Hallo Welt & Co

'), 'HalloWelt&Co') + assert.equal(sichtbarerText('50,00 € '), '50,00€') +}) +test('ohneKopf streicht nur den Kopf, nicht die Absätze danach', () => { + assert.equal(sichtbarerText(ohneKopf('

A

B

C

')), 'C') + assert.equal(sichtbarerText(ohneKopf('

A

C

')), 'C') + assert.equal(sichtbarerText(ohneKopf('

C

')), 'C') +}) +test('altes app.js rendert in der VM: Bestellen, Wechsel, Speicher, Gutschrift', async () => { + const alt = ladeAlteApp() + assert.match(sichtbarerText(alt.bestellen(aboAntwort(), 'wartung')), /Zahlungspflichtigbestellen/) + const hosting = aboAntwort({ subscription: abo({ produkt: 'hosting', canSwitch: true }) }) + assert.match(sichtbarerText(await alt.wechsel(hosting, VORSCHAU)), /Zahlungspflichtigbestellen/) + assert.match(sichtbarerText(await alt.speicher(aboAntwort({ subscription: abo() }))), /E-Mail-Speicher/) + assert.match(sichtbarerText(await alt.gutschrift(aboAntwort({ subscription: abo() }), { requests: [], limits: LIMITS })), /Antragabsenden/) +}) diff --git a/test/support/knWortlautOrakel.js b/test/support/knWortlautOrakel.js new file mode 100644 index 0000000..131076e --- /dev/null +++ b/test/support/knWortlautOrakel.js @@ -0,0 +1,125 @@ +// Wortlaut-Orakel (P2): lädt das alte public/app.js in eine VM, rendert die vier Wortlaut-Seiten (Bestellen, Wechsel, E-Mail-Speicher, +// Gutschrift) mit Attrappen und liefert deren HTML. Die neuen Seiten müssen denselben sichtbaren Text haben (C14, Fassung 5). +// Nur lesend: app.js bleibt unverändert. P10 friert dieses Hilfsmittel vor dem Löschen von app.js ein (N40, N51). +import vm from 'node:vm' +import { readFileSync } from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { setImmediate as takt } from 'node:timers/promises' + +const APP_JS = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'public', 'app.js') + +const ENTITAETEN = { '&': '&', '<': '<', '>': '>', '"': '"', ''': "'", ' ': ' ' } + +/** Sichtbarer Text eines HTML-Strings oder Elements: ohne Tags, Kommentare,