IT-Service: /api/ex ergänzen, HTML-Antworten als Fehler, Kategorie und Standort Pflicht
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m35s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m32s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m54s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m53s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m1s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m17s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m31s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m11s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m33s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 20:17:39 +00:00
parent df7ebfa6cd
commit 7969a7ac83
108 changed files with 525 additions and 445 deletions

View file

@ -77,18 +77,30 @@ class ItServiceTest extends TestCase
public function test_ticket_is_created_with_the_own_address_and_optional_device(): void
{
Http::fake(['*/tickets' => Http::response(['id' => 42, 'status' => 'open'])]);
Http::fake([
'*/tickets' => Http::response(['id' => 42, 'status' => 'open']),
'*/ticket-categories' => Http::response(['categories' => [['id' => 3, 'name' => 'Hardware', 'parent_id' => null]]]),
'*/ticket-locations' => Http::response(['locations' => [['id' => 1, 'name' => 'Hauptgebäude', 'parent_id' => null]]]),
]);
// Kategorie und Standort sind Pflicht, wenn OpenNIT welche anbietet
$this->actingAs($this->user)->post('/it-service/tickets', ['subject' => 'X', 'description' => 'Y'])->assertSessionHasErrors(['category_id', 'location_id']);
$this->actingAs($this->user)->post('/it-service/tickets', [
'subject' => 'Bildschirm flackert',
'description' => 'Seit heute Morgen.',
'asset_id' => 5,
'category_id' => 3,
'location_id' => 1,
])->assertRedirect('/it-service/tickets/42');
Http::assertSent(function (Request $request) {
if ($request->method() !== 'POST') {
return false;
}
$body = json_decode($request->body(), true);
$this->assertSame(['subject' => 'Bildschirm flackert', 'from_email' => 'Max.Muster@Example.com', 'from_name' => 'Max Muster', 'description' => 'Seit heute Morgen.', 'category_id' => 3, 'asset_id' => 5], $body);
$this->assertSame(['subject' => 'Bildschirm flackert', 'from_email' => 'Max.Muster@Example.com', 'from_name' => 'Max Muster', 'description' => 'Seit heute Morgen.', 'category_id' => 3, 'location_id' => 1, 'asset_id' => 5], $body);
$this->assertSigned($request, ''); // „from_email“ ist nicht „email“ – E-Mail-Zeile leer
return $request->method() === 'POST';
@ -162,6 +174,18 @@ class ItServiceTest extends TestCase
$this->assertNull($this->dashboardWidget($this->actingAs($this->user)->get('/'), 'it-service.summary'));
}
public function test_server_address_without_api_path_and_html_answers(): void
{
app(Settings::class)->save(['url' => 'https://itdoku.example.de/', 'auto_reserve' => 'default', 'intro' => null]);
$this->assertSame('https://itdoku.example.de/api/ex', app(Settings::class)->url(), '„/api/ex“ wird ergänzt');
Http::fake(['*' => Http::response('<!DOCTYPE html><html>Anmeldung</html>', 200, ['Content-Type' => 'text/html'])]);
$this->actingAs($this->user)->get('/it-service/leihgeraete')->assertInertia(fn (Assert $page) => $page
->where('devices.ok', false)
->where('devices.error', fn ($error) => str_contains($error, '/api/ex')));
Http::assertSent(fn (Request $request) => str_starts_with($request->url(), 'https://itdoku.example.de/api/ex/'));
}
public function test_settings_keep_secrets_encrypted_and_only_admins_configure(): void
{
Livewire::actingAs(User::factory()->admin()->create())