Files
api/services/nginx/app/tests/Unit/Selfserve/SelfserveSchemaBootstrapCompatibilityTest.php
T
Jeppe Bundgaard 8bf957b273 Add support for selfserve_enabled lanes and synchronize behavior across tasks, sessions, and projections
- Introduced `selfserve_enabled` property for `department_lanes` with schema update, object properties, and associated methods/tests.
- Enhanced `selfserve_wash_flow` and session logic to respect lane self-serve settings, including block handling and task filtering.
- Updated API routes and Studio Graph projections to include `selfserve_enabled` in payloads and progress callbacks.
- Added unit tests for session statuses, lane configuration, and blocking behavior due to disabled self-serve settings.
2026-04-29 17:28:42 +02:00

53 lines
2.9 KiB
PHP

<?php
it('adds dynamic_images_vehicle_type column for legacy selfserve wash session task schemas', function (): void {
$bootstrapContent = file_get_contents(app_path('classes/selfserve_schema_bootstrap.php'));
expect($bootstrapContent)->not->toBeFalse();
expect($bootstrapContent)->toContain("'selfserve_wash_session_tasks'");
expect($bootstrapContent)->toContain("'dynamic_images_vehicle_type'");
expect($bootstrapContent)->toContain('ALTER TABLE selfserve_wash_session_tasks ADD COLUMN dynamic_images_vehicle_type INT NULL AFTER buttons');
});
it('adds wash_started_at column for legacy selfserve wash session schemas', function (): void {
$bootstrapContent = file_get_contents(app_path('classes/selfserve_schema_bootstrap.php'));
expect($bootstrapContent)->not->toBeFalse();
expect($bootstrapContent)->toContain("'selfserve_wash_sessions'");
expect($bootstrapContent)->toContain("'wash_started_at'");
expect($bootstrapContent)->toContain('ALTER TABLE selfserve_wash_sessions ADD COLUMN wash_started_at DATETIME NULL AFTER machine_start_triggered_at');
});
it('adds lane-level self-serve enablement for existing department lanes', function (): void {
$bootstrapContent = file_get_contents(app_path('classes/selfserve_schema_bootstrap.php'));
expect($bootstrapContent)->not->toBeFalse();
expect($bootstrapContent)->toContain("'department_lanes'");
expect($bootstrapContent)->toContain("'selfserve_enabled'");
expect($bootstrapContent)->toContain('ALTER TABLE department_lanes ADD COLUMN selfserve_enabled TINYINT(1) NOT NULL DEFAULT 1 AFTER machine_type_id');
});
it('creates canvas-only self-serve studio layout storage', function (): void {
$bootstrapContent = file_get_contents(app_path('classes/selfserve_schema_bootstrap.php'));
expect($bootstrapContent)->not->toBeFalse();
expect($bootstrapContent)->toContain('CREATE TABLE IF NOT EXISTS department_selfserve_studio_layouts');
expect($bootstrapContent)->toContain('layout_json JSON NOT NULL');
expect($bootstrapContent)->toContain('idx_department_selfserve_studio_layouts_department_user');
});
it('uses mysql-safe identifiers for self-serve studio virtual hardware storage', function (): void {
$bootstrapContent = file_get_contents(app_path('classes/selfserve_schema_bootstrap.php'));
expect($bootstrapContent)->not->toBeFalse();
expect($bootstrapContent)->toContain('CREATE TABLE IF NOT EXISTS department_selfserve_studio_virtual_hardware');
expect($bootstrapContent)->toContain('UNIQUE KEY uniq_selfserve_vhw_department');
expect($bootstrapContent)->toContain('INDEX idx_selfserve_vhw_dept_updated');
expect($bootstrapContent)->not->toContain('idx_department_selfserve_studio_virtual_hardware_department_updated');
preg_match_all('/\b(?:UNIQUE\s+KEY|INDEX)\s+([a-zA-Z0-9_]+)/', $bootstrapContent, $matches);
foreach ($matches[1] as $identifier) {
expect(strlen($identifier))->toBeLessThanOrEqual(64);
}
});