85 lines
4.2 KiB
JavaScript
85 lines
4.2 KiB
JavaScript
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 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, />Teilnahmen</);
|
|
assert.match(admin, />Export</);
|
|
assert.match(admin, /data-datetime-picker/);
|
|
assert.match(admin, /data-date-picker/);
|
|
assert.doesNotMatch(admin, /datetime-local/);
|
|
assert.match(admin, /data-picker-hour/);
|
|
assert.match(admin, /data-picker-quarter/);
|
|
assert.match(admin, /Array\.from\(\{length:24\}/);
|
|
assert.match(admin, /\['00','15','30','45'\]/);
|
|
assert.match(admin, /data-picker-close/);
|
|
assert.match(admin, /<select name="title"/);
|
|
assert.match(admin, /data-dropdown-indicator/);
|
|
assert.match(admin, /SELECT DISTINCT contact_name, contact_email, contact_phone/);
|
|
assert.match(admin, /contactByName\[contactName\.value\]/);
|
|
assert.match(admin, /contactByEmail\[contactEmail\.value\]/);
|
|
assert.match(admin, /booking-datetime-change/);
|
|
assert.match(admin, /id="export-project"/);
|
|
assert.match(admin, /DATE\(e\.starts_at\) AS event_day/);
|
|
assert.match(admin, /export-project/);
|
|
assert.doesNotMatch(admin, /text\/csv|fputcsv/i);
|
|
});
|