Add department self-serve config versioning routes with lifecycle actions (list, validate, publish, rollback) and associated logic for managing config versions.

This commit is contained in:
Jeppe Bundgaard
2026-03-25 17:54:41 +01:00
parent 482a17f093
commit 76729f1b99
24 changed files with 1722 additions and 43 deletions
@@ -32,6 +32,33 @@ it('keeps machine type support wired into lanes, tasks, and conditions routes',
->toContain('product');
});
it('wires self-serve config draft/publish/rollback lifecycle endpoints', function (): void {
$configRoute = file_get_contents(app_path('routes/departmentSelfserveConfigVersionsRoute.php'));
expect($configRoute)->not->toBeFalse();
expect($configRoute)->toContain('/department/selfserve/config/versions');
expect($configRoute)->toContain('/department/selfserve/config/history');
expect($configRoute)->toContain('/department/selfserve/config/active');
expect($configRoute)->toContain('/department/selfserve/config/draft');
expect($configRoute)->toContain('/department/selfserve/config/validate');
expect($configRoute)->toContain('/department/selfserve/config/publish');
expect($configRoute)->toContain('/department/selfserve/config/rollback');
expect($configRoute)->toContain('publish_department_selfserve_config_versions');
expect($configRoute)->toContain('rollback_department_selfserve_config_versions');
});
it('keeps legacy self-serve CRUD routes syncing canonical drafts', function (): void {
$questionsRoute = file_get_contents(app_path('routes/departmentSelfserveQuestionsRoute.php'));
$conditionsRoute = file_get_contents(app_path('routes/departmentSelfserveConditionsRoute.php'));
$rulesRoute = file_get_contents(app_path('routes/departmentSelfserveConditionRulesRoute.php'));
$tasksRoute = file_get_contents(app_path('routes/departmentSelfserveTasksRoute.php'));
expect($questionsRoute)->toContain('syncDraftFromLegacyForDepartment');
expect($conditionsRoute)->toContain('syncDraftFromLegacyForDepartment');
expect($rulesRoute)->toContain('syncDraftFromLegacyForDepartment');
expect($tasksRoute)->toContain('syncDraftFromLegacyForDepartment');
});
it('wires machine relay status get and set endpoints', function (): void {
$moduleSelfServeRoute = file_get_contents(app_path('routes/moduleSelfServeRoute.php'));
@@ -72,4 +99,31 @@ it('wires in-progress self-serve wash details endpoint', function (): void {
expect($moduleSelfServeRoute)->toContain("'in_progress' => false");
expect($moduleSelfServeRoute)->toContain('selfserve_lane_status::OCCUPIED');
expect($moduleSelfServeRoute)->toContain('selfserve_lane_state::IN_WASH');
expect($moduleSelfServeRoute)->toContain('getWashStartTime');
expect($moduleSelfServeRoute)->toContain("'included_minutes' =>");
expect($moduleSelfServeRoute)->toContain("'machine_relay_enabled' =>");
expect($moduleSelfServeRoute)->toContain("'machine_relay_enabled_at' =>");
expect($moduleSelfServeRoute)->toContain("'wash_started_at' =>");
});
it('wires vehicle type override into self-serve preview and synchronization routes', function (): void {
$vehicleConditionsRoute = file_get_contents(app_path('routes/departmentSelfserveVehicleConditionsRoute.php'));
$washFlow = file_get_contents(app_path('modules/selfserve/classes/selfserve_wash_flow.php'));
expect($vehicleConditionsRoute)->not->toBeFalse();
expect($vehicleConditionsRoute)->toContain('vehicle_type_id');
expect($vehicleConditionsRoute)->toContain('vehicle_type');
expect($vehicleConditionsRoute)->toContain('resolveVehicleTypeIdFromQuery');
expect($vehicleConditionsRoute)->toContain('resolveVehicleTypeIdFromRequest');
expect($vehicleConditionsRoute)->toContain('normalizeVehicleTypeOverride');
expect($vehicleConditionsRoute)->toContain('shouldRefreshSummaryForVehicleType');
expect($vehicleConditionsRoute)->toContain('previewVehicleEligibility($lane_id, $reg, $customer_number, $vehicle_type_id)');
expect($vehicleConditionsRoute)->toContain('synchronizeSession($lane_id, $reg, $customer_number, false, $vehicle_type_id)');
expect($vehicleConditionsRoute)->toContain('synchronizeSession($lane, $reg, $customer_id, true, $vehicle_type_id)');
expect($washFlow)->not->toBeFalse();
expect($washFlow)->toContain('resolveVehicleTypeId($vehicle, $vehicleTypeIdOverride)');
expect($washFlow)->toContain("'vehicle_type_id' => \$snapshot['vehicle_type_id']");
expect($washFlow)->toContain("\$session->vehicle_type_id->set(\$snapshot['vehicle_type_id']);");
expect($washFlow)->toContain("\$session->vehicle_id->set(\$snapshot['vehicle']['id'] ?? null);");
});