Loheide-eu-mitarbeiterplatt.../tests/Feature/HubsTest.php
Friederich Loheide 4d0a2984ec
Some checks failed
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 9m9s
CI / PHP 8.3 / mariadb:10.6 (pull_request) Failing after 9m19s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Failing after 10m30s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Failing after 11m5s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 13m15s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 13m54s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 10m57s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 45s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 11m44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m20s
Wissen, Service, Gremien-Baustein und Menü-Vorschlag (0.56.0)
Übersichtsseiten /wissen und /service (Hubs, im Admin pflegbar), Baustein
„Mitglieder mit Rolle“, Menü-Vorschlag für die Mitarbeiter-App.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-30 16:03:08 +00:00

66 lines
2.8 KiB
PHP

<?php
namespace Tests\Feature;
use App\Filament\Pages\HubsSettings;
use App\Filament\Pages\MenuSettings;
use App\Models\Role;
use App\Models\User;
use App\Plugins\PluginAccess;
use App\Support\Hubs;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Inertia\Testing\AssertableInertia as Assert;
use Livewire\Livewire;
use Tests\TestCase;
class HubsTest extends TestCase
{
use RefreshDatabase;
public function test_suggestion_fills_wissen_and_blocked_areas_disappear(): void
{
$user = User::factory()->create();
$this->actingAs($user)->get('/wissen')->assertInertia(fn (Assert $page) => $page->component('Hubs/Wissen')
->where('entries', fn ($entries) => collect($entries)->contains('title', 'Downloads') && collect($entries)->contains('title', 'Qualität')));
$clients = Role::query()->create(['name' => 'Klienten']);
app(PluginAccess::class)->exclude('qm', [$clients->id]);
$client = User::factory()->withRoles([$clients])->create();
$this->assertNotContains('Qualität', array_column(app(Hubs::class)->forUser('wissen', $client), 'title'));
}
public function test_service_shows_it_actions_and_own_entries_with_person_and_roles(): void
{
$admin = User::factory()->admin()->create();
$staff = Role::query()->create(['name' => 'Verwaltung']);
$person = User::factory()->create(['first_name' => 'Helga', 'last_name' => 'Marquardt']);
$this->actingAs($admin);
Livewire::test(HubsSettings::class)
->fillForm([
'wissen' => [],
'service' => [
['title' => 'Haustechnik', 'url' => '/seiten/haustechnik', 'icon' => 'wrench', 'text' => 'Defekt melden', 'action' => 'Schaden melden', 'person' => $person->id, 'roles' => []],
['title' => 'Nur Verwaltung', 'url' => '/x', 'icon' => 'link', 'roles' => [(string) $staff->id]],
],
])
->call('save')
->assertHasNoFormErrors();
$this->actingAs(User::factory()->create())->get('/service')->assertInertia(fn (Assert $page) => $page->component('Hubs/Service')
->has('entries', 1)
->where('entries.0.title', 'Haustechnik')
->where('entries.0.person.name', 'Helga Marquardt')
->where('it.0.label', 'Problem melden'));
}
public function test_menu_suggestion_for_the_app(): void
{
$this->actingAs(User::factory()->admin()->create());
$items = Livewire::test(MenuSettings::class)->callAction('suggestApp')->get('data.items');
$labels = collect($items)->map(fn ($item) => $item['label'] ?? $item['module'] ?? null)->values()->all();
$this->assertSame(['Start', 'Menschen', 'Wissen', 'Qualität', 'Service'], array_slice($labels, 0, 5));
}
}