main übernehmen

This commit is contained in:
Friederich Loheide 2026-09-26 20:17:56 +00:00
commit 2a11d8a47a
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())