Files

100 lines
5.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/perspektivwerk/booking/booking.js', import.meta.url), 'utf8'),
readFile(new URL('../public/perspektivwerk/js/booking.js', import.meta.url), 'utf8'),
readFile(new URL('../public/perspektivwerk/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('entfernt den Test-Mailausgang mit einer Folgemigration', async () => {
const migration = await readFile(new URL('../database/migrations/006_remove_booking_outbox.sql', import.meta.url), 'utf8');
assert.match(migration, /DROP TABLE IF EXISTS `sufw_booking_outbox`/);
assert.match(migration, /INSERT IGNORE INTO `sufw_booking_schema_migrations` \(`version`\) VALUES \('006_remove_booking_outbox'\)/);
});
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 admin = await readFile(new URL('../public/perspektivwerk/booking-admin/index.php', import.meta.url), 'utf8');
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, /<\?php if \(\$view === 'events'\): \?><div class="picker-time" data-picker-time-controls>/);
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, /<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.match(admin, /new DateTimeImmutable\('first day of next month'\)/);
assert.doesNotMatch(admin, /text\/csv|fputcsv/i);
});