IT-Service: Baumstruktur, HTML-Antworten, Fehlermeldungen, geschlossene Tickets, Meine IT im Profilkasten
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m31s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 3m39s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 3m57s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 3m46s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 5m9s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 5m13s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 4m30s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 4m27s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m7s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-26 20:30:24 +00:00
parent ab35a67406
commit 50ee85c06b
119 changed files with 611 additions and 463 deletions

View file

@ -186,6 +186,45 @@ class ItServiceTest extends TestCase
Http::assertSent(fn (Request $request) => str_starts_with($request->url(), 'https://itdoku.example.de/api/ex/'));
}
public function test_closed_tickets_html_replies_error_messages_and_tree(): void
{
Http::fake([
'*/tickets/50*' => Http::response([
'ticket' => ['id' => 50, 'subject' => 'Laptop', 'status' => 'solved', 'description' => "Zeile 1\nZeile 2"],
'replies' => [['message' => '<br><br>Viele Grüße<br>Friederich<script>alert(1)</script>', 'from_email' => 'Max.Muster@Example.com']],
]),
'*/loan-requests' => Http::response(['error' => 'Der Zeitraum darf höchstens 14 Tage lang sein.'], 422),
'*/ticket-categories' => Http::response(['categories' => [
['id' => 1, 'name' => 'Hardware', 'parent_id' => null], ['id' => 2, 'name' => 'Drucker', 'parent_id' => 1],
['id' => 3, 'name' => 'Toner', 'parent_id' => 2], ['id' => 9, 'name' => 'Verwaist', 'parent_id' => 77],
]]),
'*/ticket-locations' => Http::response(['locations' => []]),
'*/my-assets*' => Http::response(['assets' => []]),
]);
$this->actingAs($this->user)->get('/it-service/tickets/50')->assertInertia(fn (Assert $page) => $page
->where('ticket.status_label', 'Gelöst')
->where('ticket.open', false)
->where('ticket.description', "Zeile 1<br>\nZeile 2")
->where('ticket.replies.0.message', fn ($html) => str_contains($html, 'Viele Grüße<br') && ! str_contains($html, 'script')));
$this->actingAs($this->user)->post('/it-service/tickets/50/antworten', ['message' => 'Noch da?'])->assertSessionHasErrors('message');
Http::assertNotSent(fn (Request $request) => str_ends_with($request->url(), '/reply'));
$this->actingAs($this->user)->post('/it-service/leihgeraete/anfragen', ['device_id' => 1, 'planned_start' => now()->addDay()->toDateString(), 'planned_end' => now()->addDays(40)->toDateString()])
->assertSessionHasErrors(['planned_start' => 'Der Zeitraum darf höchstens 14 Tage lang sein.']);
$this->actingAs($this->user)->get('/it-service/tickets/neu')->assertInertia(fn (Assert $page) => $page
->where('options.data.categories', fn ($categories) => collect($categories)->pluck('path')->all() === ['Hardware', 'Hardware › Drucker', 'Hardware › Drucker › Toner', 'Verwaist'])
->where('options.data.categories.2.depth', 2));
}
public function test_greeting_box_gets_a_my_it_button(): void
{
$actions = $this->dashboardWidget($this->actingAs($this->user)->get('/'), 'core.greeting')['actions'];
$this->assertSame([['label' => 'Meine IT', 'href' => '/it-service', 'icon' => 'monitor-smartphone']], $actions);
}
public function test_settings_keep_secrets_encrypted_and_only_admins_configure(): void
{
Livewire::actingAs(User::factory()->admin()->create())