diff --git a/services/nginx/app/routes/moduleSelfServeRoute.php b/services/nginx/app/routes/moduleSelfServeRoute.php index 9f690b93..e81bcf9d 100644 --- a/services/nginx/app/routes/moduleSelfServeRoute.php +++ b/services/nginx/app/routes/moduleSelfServeRoute.php @@ -14,6 +14,7 @@ use modules\selfserve\classes\selfserve_wash_flow; use modules\selfserve\helpers\selfserve_lane_command; use modules\selfserve\helpers\selfserve_lane_port; use modules\selfserve\helpers\selfserve_lane_relay; +use modules\selfserve\helpers\selfserve_lane_services; use modules\selfserve\helpers\selfserve_lane_state; use modules\selfserve\helpers\selfserve_lane_status; use modules\selfserve\helpers\selfserve_wash_session_status; diff --git a/services/nginx/app/tests/Api/SelfserveCustomerStartApiTest.php b/services/nginx/app/tests/Api/SelfserveCustomerStartApiTest.php index f7e4b398..97f989f7 100644 --- a/services/nginx/app/tests/Api/SelfserveCustomerStartApiTest.php +++ b/services/nginx/app/tests/Api/SelfserveCustomerStartApiTest.php @@ -264,6 +264,55 @@ it('derives allowed services from published v2 config task snapshots when no ses } }); +it('keeps questions visible but disables machine services and tasks when machine wash is globally disabled', function (): void { + $group = api_fixtures()->createGroup([], [ + 'list_own_department_selfserve_vehicle_conditions', + ]); + $scenario = api_fixtures()->createSelfServeScenario([ + 'customer' => ['group_id' => $group['id']], + 'department_selfserve_enabled' => true, + 'lane_selfserve_enabled' => true, + 'machine_wash_enabled' => false, + ]); + $headers = api_fixtures()->bearerHeaders( + api_fixtures()->createAuthToken((int)$scenario['customer']['id']) + ); + $laneId = (int)$scenario['lane']['id']; + $reg = (string)$scenario['vehicle']['reg']; + $productId = (int)$scenario['product']['id']; + $machineTaskId = (int)$scenario['tasks'][1]['id']; + + $allowedResponse = api_client() + ->get( + '/department/selfserve/vehicle/allowed?lane_id=' . $laneId + . '®=' . urlencode($reg) + . '&vehicle_type=' . $productId, + $headers + ) + ->assertStatus(200) + ->assertSuccess(true); + + expect($allowedResponse->data()['questions'] ?? [])->not->toBeEmpty() + ->and($allowedResponse->data()['allowed_services'] ?? [])->not->toContain('MACHINE') + ->and($allowedResponse->data()['machine_available'] ?? null)->toBeFalse() + ->and($allowedResponse->data()['machine_wash_enabled'] ?? null)->toBeFalse() + ->and($allowedResponse->data()['allowed'] ?? null)->toBeFalse(); + + foreach ($allowedResponse->data()['tasks'] ?? [] as $task) { + expect($task['services'] ?? [])->not->toContain('MACHINE'); + } + + $serviceResponse = api_client() + ->post('/modules/self-serve/lane/services/allowed', [ + 'lane_id' => $laneId, + 'task_ids' => [$machineTaskId], + ], $headers) + ->assertStatus(200) + ->assertSuccess(true); + + expect($serviceResponse->data()['allowed_services'] ?? [])->not->toContain('MACHINE'); +}); + it('keeps long generated task descriptions when refreshing vehicle eligibility snapshots', function (): void { $group = api_fixtures()->createGroup([], [ 'list_own_department_selfserve_vehicle_conditions', diff --git a/services/nginx/app/tests/Support/Api/ApiFixtures.php b/services/nginx/app/tests/Support/Api/ApiFixtures.php index 93fbbe6b..1170d336 100644 --- a/services/nginx/app/tests/Support/Api/ApiFixtures.php +++ b/services/nginx/app/tests/Support/Api/ApiFixtures.php @@ -544,6 +544,11 @@ final class ApiFixtures } $this->setModuleConfig('selfserve', 'enabled', 'true'); + $this->setModuleConfig( + 'selfserve', + 'machine_wash_enabled', + (bool)($overrides['machine_wash_enabled'] ?? true) ? 'true' : 'false' + ); return [ 'department' => $department,