Files
api/services/nginx/app/tests/Api/SelfserveLaneWashInProgressApiTest.php
T
Jeppe Bundgaard 5875371d13 Add attachment payload handling and tests for self-serve tasks
- Introduced `selfserve_task_attachment_payloads` class for managing task attachments, including formatting and download URL generation.
- Added unit and API tests to validate attachment handling in self-serve tasks and customer-scoped workflows.
- Enhanced wash start simulation and studio graph projections to integrate task attachment data.
2026-04-29 16:03:03 +02:00

77 lines
2.5 KiB
PHP

<?php
usesApiSuite();
it('requires authentication before checking in-progress wash permissions', function (): void {
$response = api_client()->get('/modules/self-serve/lane/wash/in-progress?lane_id=1');
$response
->assertStatus(401)
->assertMessage('Authentication failed. Invalid or missing token.');
});
it('reports both elevated and customer self-serve permissions when lane polling is not allowed', function (): void {
$session = api_fixtures()->createUserSession([]);
$response = api_client()->get(
'/modules/self-serve/lane/wash/in-progress?lane_id=1',
$session['headers']
);
$response
->assertStatus(403)
->assertMissingPermissions([
'modules_selfserve_lane_wash_in_progress_view',
'list_own_department_selfserve_vehicle_conditions',
]);
});
it('allows customer self-serve permission to view their own in-progress wash details', function (): void {
$group = api_fixtures()->createGroup([], [
'list_own_department_selfserve_vehicle_conditions',
]);
$scenario = api_fixtures()->createSelfServeScenario([
'customer' => [
'group_id' => $group['id'],
],
]);
$token = api_fixtures()->createAuthToken((int)$scenario['customer']['id']);
$response = api_client()->get(
'/modules/self-serve/lane/wash/in-progress?lane_id=' . (int)$scenario['lane']['id'],
api_fixtures()->bearerHeaders($token)
);
$response
->assertStatus(200)
->assertSuccess(true);
expect($response->data()['in_progress'] ?? null)->toBeTrue()
->and($response->data()['session']['customer_number'] ?? null)->toBe((int)$scenario['customer']['customer_number'])
->and($response->data()['vehicle']['reg'] ?? null)->toBe($scenario['vehicle']['reg']);
});
it('redacts another customers in-progress wash from customer self-serve lane polling', function (): void {
$scenario = api_fixtures()->createSelfServeScenario();
$otherSession = api_fixtures()->createUserSession([
'list_own_department_selfserve_vehicle_conditions',
]);
$response = api_client()->get(
'/modules/self-serve/lane/wash/in-progress?lane_id=' . (int)$scenario['lane']['id'],
$otherSession['headers']
);
$response
->assertStatus(200)
->assertSuccess(true);
expect($response->data())->toMatchArray([
'lane_id' => (int)$scenario['lane']['id'],
'in_progress' => true,
'session' => null,
'customer' => null,
'vehicle' => null,
]);
});