import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import test from 'node:test'; test('liefert eine externe, idempotente Anfangsmigration für Termine und Anmeldungen', async () => { const migration = await readFile(new URL('../database/migrations/001_booking_schema.sql', import.meta.url), 'utf8'); assert.match(migration, /CREATE TABLE IF NOT EXISTS `sufw_booking_events`/); assert.match(migration, /CREATE TABLE IF NOT EXISTS `sufw_booking_registrations`/); assert.match(migration, /FOREIGN KEY \(`event_id`\)/); assert.match(migration, /CHECK \(`capacity` BETWEEN 1 AND 100\)/); }); test('hält die statische Vorschaukopie der Buchungsassets identisch', async () => { const [componentScript, previewScript, componentStyle, previewStyle] = await Promise.all([ readFile(new URL('../public/booking/booking.js', import.meta.url), 'utf8'), readFile(new URL('../public/perspektivwerk/js/booking.js', import.meta.url), 'utf8'), readFile(new URL('../public/booking/booking.css', import.meta.url), 'utf8'), readFile(new URL('../public/perspektivwerk/js/booking.css', import.meta.url), 'utf8'), ]); assert.equal(previewScript, componentScript); assert.equal(previewStyle, componentStyle); }); test('modelliert Bestätigung, Mailausgang und ICS-Feeds als zweite Migration', async () => { const migration = await readFile(new URL('../database/migrations/002_booking_workflow.sql', import.meta.url), 'utf8'); assert.match(migration, /confirmation_token_hash/); assert.match(migration, /confirmation_expires_at/); assert.match(migration, /CREATE TABLE IF NOT EXISTS `sufw_booking_outbox`/); assert.match(migration, /CREATE TABLE IF NOT EXISTS `sufw_booking_project_settings`/); assert.match(migration, /UNIQUE KEY `sufw_booking_outbox_registration_kind`/); }); test('liefert lokale Demo-Termine und bestätigte Teilnahmen vor und nach dem heutigen Datum', async () => { const migration = await readFile(new URL('../database/migrations/003_booking_demo_data.sql', import.meta.url), 'utf8'); assert.match(migration, /Nur für lokale Entwicklungs- und Testdatenbanken/); assert.match(migration, /DATE_ADD\(CURDATE\(\), INTERVAL -1 MONTH\)/); assert.match(migration, /DATE_ADD\(CURDATE\(\), INTERVAL 1 MONTH\)/); assert.match(migration, /'confirmed'/); assert.match(migration, /sufw_booking_registrations/); }); test('erweitert Demo-Kontakte um die vorgesehenen Ansprechpartnerdaten', async () => { const migration = await readFile(new URL('../database/migrations/004_booking_contact_phones.sql', import.meta.url), 'utf8'); assert.match(migration, /ADD COLUMN IF NOT EXISTS `contact_phone`/); assert.match(migration, /Carina Hollederer/); assert.match(migration, /Sarah van den Heuvel/); }); test('liefert zusätzliche lokale Demo-Termine für Juli und August', async () => { const migration = await readFile(new URL('../database/migrations/005_booking_demo_july_august.sql', import.meta.url), 'utf8'); assert.match(migration, /Nur für lokale Entwicklungs- und Testdatenbanken/); assert.match(migration, /-07-10 09:00:00/); assert.match(migration, /-08-12 09:00:00/); assert.match(migration, /sufw_booking_registrations/); }); test('liefert die unabhängige Verwaltung unter booking-admin mit getrennten Bereichen', async () => { const [routes, admin] = await Promise.all([ readFile(new URL('../public/.htaccess', import.meta.url), 'utf8'), readFile(new URL('../public/booking-admin/index.php', import.meta.url), 'utf8'), ]); assert.match(routes, /\^booking-admin\/\?\$ booking-admin\/index\.php/); assert.match(admin, /view === 'registrations'/); assert.match(admin, /view === 'export'/); assert.doesNotMatch(admin, /getenv\(/); assert.match(admin, />TeilnahmenExport
/); assert.match(admin, /Array\.from\(\{length:24\}/); assert.match(admin, /\['00','15','30','45'\]/); assert.match(admin, /defaultDate\.setHours\(9,0,0,0\)/); assert.match(admin, /data-picker-close/); assert.match(admin, /