From 3aed45a2fee1b3d5cb91a37ec4d841dd1e031934 Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 24 Nov 2026 17:22:05 +0100 Subject: [PATCH] =?UTF-8?q?Ordne=20die=20Navigation=20unter=20Inhalte=20ne?= =?UTF-8?q?u=20und=20f=C3=BChre=20alte=20Adressen=20weiter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Menü: Programme, Module, Übungen, Contentmanager (bisher Medien), dahinter die Fachlichen Kombinationen. Der Arbeitsplatz ist kein Menüpunkt mehr, die gemeinsame Übersicht bleibt über den Filterlink der Stammdaten erreichbar. Dokumente rückt vorläufig hinter die vier Einträge (Position folgt im Dokumentenauftrag). Adressen: programme, module, fachuebungen, contentmanager. Die alten Adressen kurse, uebungen (= Module) und content-elements leiten mit Objektnummer, Unterseite und Filtern per 302 weiter, hinter der Anmeldung des Panels; die Rechte prüft das Ziel. Rücklinks aus der Bearbeitung führen zur Liste der eigenen Art statt zum Arbeitsplatz. Tests: Reihenfolge in UebungNavigationTest bewusst geändert (Übungen standen vor Modulen und Programmen); 'content-elements/' in EditorialEditorTest folgt der neuen Adresse. Neu: VerwaltungNavigationTest. Co-Authored-By: Claude Sonnet 5.5 --- app/Filament/Pages/EditorialDesk.php | 5 +- .../Combinations/CombinationResource.php | 2 +- .../Pages/ListCompositionKind.php | 4 +- .../ContentElementResource.php | 6 +- .../Resources/Courses/CourseResource.php | 4 +- .../Resources/Documents/DocumentResource.php | 2 +- .../Resources/Exercises/ExerciseResource.php | 4 +- .../Resources/Practices/PracticeResource.php | 6 +- app/Filament/Support/LegacyAddresses.php | 51 +++++ app/Providers/Filament/AdminPanelProvider.php | 2 + .../views/filament/editorial/editor.blade.php | 8 +- .../views/filament/media/viewer.blade.php | 2 +- tests/Feature/EditorialEditorTest.php | 6 +- tests/Feature/UebungNavigationTest.php | 6 +- tests/Feature/VerwaltungNavigationTest.php | 203 ++++++++++++++++++ 15 files changed, 289 insertions(+), 22 deletions(-) create mode 100644 app/Filament/Support/LegacyAddresses.php create mode 100644 tests/Feature/VerwaltungNavigationTest.php diff --git a/app/Filament/Pages/EditorialDesk.php b/app/Filament/Pages/EditorialDesk.php index 33e2b69..074c5b0 100644 --- a/app/Filament/Pages/EditorialDesk.php +++ b/app/Filament/Pages/EditorialDesk.php @@ -10,7 +10,7 @@ use Illuminate\Contracts\Support\Htmlable; /** - * Arbeitsplatz: Programme und Module in der gemeinsamen Bestandsliste. Die Listen „Module“ und „Programme“ zeigen + * Gemeinsame Übersicht „Programme und Module“ (kein Menüpunkt; Einstieg über die Stammdaten). Die Listen „Module“ und „Programme“ zeigen * dieselben Zeilen mit festem Typ (ListsCompositions). */ class EditorialDesk extends Page @@ -23,6 +23,9 @@ class EditorialDesk extends Page protected static ?int $navigationSort = 0; + /** Kein Menüpunkt mehr; die gemeinsame Übersicht bleibt über den Filterlink der Stammdaten erreichbar. */ + protected static bool $shouldRegisterNavigation = false; + protected static ?string $slug = 'arbeitsplatz'; protected static ?string $title = 'Arbeitsplatz'; diff --git a/app/Filament/Resources/Combinations/CombinationResource.php b/app/Filament/Resources/Combinations/CombinationResource.php index bbb38e5..baaa333 100644 --- a/app/Filament/Resources/Combinations/CombinationResource.php +++ b/app/Filament/Resources/Combinations/CombinationResource.php @@ -17,7 +17,7 @@ class CombinationResource extends CompositionKindResource protected static ?string $pluralModelLabel = 'Fachliche Kombinationen'; - protected static ?int $navigationSort = 5; + protected static ?int $navigationSort = 6; public static function kind(): CompositionKind { diff --git a/app/Filament/Resources/Compositions/Pages/ListCompositionKind.php b/app/Filament/Resources/Compositions/Pages/ListCompositionKind.php index 3f96d74..d40b420 100644 --- a/app/Filament/Resources/Compositions/Pages/ListCompositionKind.php +++ b/app/Filament/Resources/Compositions/Pages/ListCompositionKind.php @@ -39,9 +39,7 @@ private function onDesk(): bool public function getSubheading(): string|Htmlable|null { - $desk = $this->onDesk() && ! in_array($this->kind(), [CompositionKind::Exercise, CompositionKind::Document], true) ? ' Programme und Module stehen gemeinsam auch auf dem Arbeitsplatz.' : ''; - - return $this->kind()->deskExplanation().$desk; + return $this->kind()->deskExplanation(); } public function getMaxContentWidth(): Width|string|null diff --git a/app/Filament/Resources/ContentElements/ContentElementResource.php b/app/Filament/Resources/ContentElements/ContentElementResource.php index 6789020..704cc5a 100644 --- a/app/Filament/Resources/ContentElements/ContentElementResource.php +++ b/app/Filament/Resources/ContentElements/ContentElementResource.php @@ -24,7 +24,9 @@ class ContentElementResource extends Resource protected static string|\UnitEnum|null $navigationGroup = 'Inhalte'; - protected static ?string $navigationLabel = 'Medien'; + protected static ?string $navigationLabel = 'Contentmanager'; + + protected static ?string $slug = 'contentmanager'; protected static ?string $modelLabel = 'Medium'; @@ -32,7 +34,7 @@ class ContentElementResource extends Resource protected static ?string $recordTitleAttribute = 'working_title'; - protected static ?int $navigationSort = 1; + protected static ?int $navigationSort = 4; public static function canViewAny(): bool { diff --git a/app/Filament/Resources/Courses/CourseResource.php b/app/Filament/Resources/Courses/CourseResource.php index 4e66f11..9a3c492 100644 --- a/app/Filament/Resources/Courses/CourseResource.php +++ b/app/Filament/Resources/Courses/CourseResource.php @@ -9,7 +9,7 @@ class CourseResource extends CompositionKindResource { - protected static ?string $slug = 'kurse'; + protected static ?string $slug = 'programme'; protected static ?string $navigationLabel = 'Programme'; @@ -17,7 +17,7 @@ class CourseResource extends CompositionKindResource protected static ?string $pluralModelLabel = 'Programme'; - protected static ?int $navigationSort = 4; + protected static ?int $navigationSort = 1; public static function kind(): CompositionKind { diff --git a/app/Filament/Resources/Documents/DocumentResource.php b/app/Filament/Resources/Documents/DocumentResource.php index 9e9b3f9..08187a6 100644 --- a/app/Filament/Resources/Documents/DocumentResource.php +++ b/app/Filament/Resources/Documents/DocumentResource.php @@ -21,7 +21,7 @@ class DocumentResource extends CompositionKindResource protected static ?string $pluralModelLabel = 'Dokumente'; - protected static ?int $navigationSort = 4; + protected static ?int $navigationSort = 5; public static function kind(): CompositionKind { diff --git a/app/Filament/Resources/Exercises/ExerciseResource.php b/app/Filament/Resources/Exercises/ExerciseResource.php index adf107c..251c67c 100644 --- a/app/Filament/Resources/Exercises/ExerciseResource.php +++ b/app/Filament/Resources/Exercises/ExerciseResource.php @@ -9,7 +9,7 @@ class ExerciseResource extends CompositionKindResource { - protected static ?string $slug = 'uebungen'; + protected static ?string $slug = 'module'; protected static ?string $navigationLabel = 'Module'; @@ -17,7 +17,7 @@ class ExerciseResource extends CompositionKindResource protected static ?string $pluralModelLabel = 'Module'; - protected static ?int $navigationSort = 3; + protected static ?int $navigationSort = 2; public static function kind(): CompositionKind { diff --git a/app/Filament/Resources/Practices/PracticeResource.php b/app/Filament/Resources/Practices/PracticeResource.php index fbad9fa..9171910 100644 --- a/app/Filament/Resources/Practices/PracticeResource.php +++ b/app/Filament/Resources/Practices/PracticeResource.php @@ -8,8 +8,8 @@ use App\Filament\Resources\Practices\Pages\ListPractices; /** - * Die fachliche Übung. Der ältere Eintrag „Module“ (`ExerciseResource`, Adresse `uebungen`) bleibt unverändert und - * zeigt die Zusammenstellungen der Art `uebung`; hier stehen die Übungen mit Varianten. + * Die fachliche Übung. Der Eintrag „Module“ (`ExerciseResource`, Adresse `module`) zeigt die Zusammenstellungen der Art `uebung`; + * hier stehen die Übungen mit Varianten. */ class PracticeResource extends CompositionKindResource { @@ -21,7 +21,7 @@ class PracticeResource extends CompositionKindResource protected static ?string $pluralModelLabel = 'Übungen'; - protected static ?int $navigationSort = 2; + protected static ?int $navigationSort = 3; public static function kind(): CompositionKind { diff --git a/app/Filament/Support/LegacyAddresses.php b/app/Filament/Support/LegacyAddresses.php new file mode 100644 index 0000000..d2d68e5 --- /dev/null +++ b/app/Filament/Support/LegacyAddresses.php @@ -0,0 +1,51 @@ + alte Adresse => neue Adresse (jeweils unter dem Panelpfad) */ + public const MOVED = [ + 'kurse' => 'programme', + 'uebungen' => 'module', + 'content-elements' => 'contentmanager', + ]; + + public static function routes(): void + { + foreach (self::MOVED as $old => $new) { + Route::get($old.'/{rest?}', fn (Request $request, ?string $rest = null): RedirectResponse => self::redirect($request, $new, $rest)) + ->where('rest', '.*') + ->name('legacy.'.$old); + } + } + + private static function redirect(Request $request, string $new, ?string $rest): RedirectResponse + { + $path = '/'.trim(Filament::getPanel('verwaltung')->getPath(), '/').'/'.$new; + $rest = trim((string) $rest, '/'); + + if ($rest !== '') { + $path .= '/'.$rest; + } + + $query = (string) $request->server->get('QUERY_STRING', ''); + + return redirect()->to(url($path).($query !== '' ? '?'.$query : '')); + } +} diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 4138c79..997c3c2 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -4,6 +4,7 @@ use App\Auth\StaffAuthenticatorName; use App\Filament\Auth\StaffLogin; +use App\Filament\Support\LegacyAddresses; use App\Http\Middleware\SanitizeIntendedUrl; use Filament\Auth\MultiFactor\App\AppAuthentication; use Filament\Http\Middleware\Authenticate; @@ -67,6 +68,7 @@ public function panel(Panel $panel): Panel ->authMiddleware([ Authenticate::class, ]) + ->authenticatedRoutes(LegacyAddresses::routes(...)) // Favicon zur Anfragezeit: ->favicon(asset(...)) würde beim Start der Anwendung berechnet, vor der // Auswertung von Proxy-Kopfzeilen und geöffneter Adresse, und könnte auf einen falschen Host zeigen. ->renderHook( diff --git a/resources/views/filament/editorial/editor.blade.php b/resources/views/filament/editorial/editor.blade.php index 6df4f13..c339d98 100644 --- a/resources/views/filament/editorial/editor.blade.php +++ b/resources/views/filament/editorial/editor.blade.php @@ -30,7 +30,13 @@ @endphp
@include('filament.verwaltung.kopf', [ - 'zurueck' => ['label' => 'Zum Arbeitsplatz', 'href' => \App\Filament\Pages\EditorialDesk::getUrl()], + 'zurueck' => ['label' => match ($this->hostKind()) { + \App\Domain\Catalog\CompositionKind::Kurs => 'Zu den Programmen', + \App\Domain\Catalog\CompositionKind::Uebung => 'Zu den Modulen', + \App\Domain\Catalog\CompositionKind::Exercise => 'Zu den Übungen', + \App\Domain\Catalog\CompositionKind::Document => 'Zu den Dokumenten', + \App\Domain\Catalog\CompositionKind::Kombination => 'Zu den Kombinationen', + }, 'href' => $this::getResource()::getUrl('index')], 'brot' => [['label' => $this->hostKind()->plural() === 'Kurse' ? 'Programme' : $this->hostKind()->plural(), 'href' => $this::getResource()::getUrl('index')], $titel], 'titel' => $titel, 'typ' => $this->hostLabel().' · '.$typ, diff --git a/resources/views/filament/media/viewer.blade.php b/resources/views/filament/media/viewer.blade.php index fd0c110..0a4525b 100644 --- a/resources/views/filament/media/viewer.blade.php +++ b/resources/views/filament/media/viewer.blade.php @@ -39,7 +39,7 @@ @else
@include('filament.verwaltung.kopf', [ - 'brot' => [['label' => 'Medien', 'href' => \App\Filament\Resources\ContentElements\ContentElementResource::getUrl('index')], $titel], + 'brot' => [['label' => 'Contentmanager', 'href' => \App\Filament\Resources\ContentElements\ContentElementResource::getUrl('index')], $titel], 'titel' => $titel, 'typ' => implode(' · ', array_filter(['Medium', \App\Domain\Cms\Catalog\PublicMaterialReader::outputLabel((string) $element->output_class), $element->editorialContentKind?->label])), 'status' => [ diff --git a/tests/Feature/EditorialEditorTest.php b/tests/Feature/EditorialEditorTest.php index 9c95127..d596b01 100644 --- a/tests/Feature/EditorialEditorTest.php +++ b/tests/Feature/EditorialEditorTest.php @@ -181,7 +181,7 @@ public function test_a_new_module_returns_into_the_program(): void $this->assertSame(CompositionKind::Uebung, $module->kind); $this->actingAs($editor, 'staff') - ->get(ExerciseResource::getUrl('edit', ['record' => $module]).'?zurueck='.urlencode('http://example.test/verwaltung/kurse/1')) + ->get(ExerciseResource::getUrl('edit', ['record' => $module]).'?zurueck='.urlencode('http://example.test/verwaltung/programme/1')) ->assertOk() ->assertSee('Zurück und einbinden'); @@ -812,7 +812,7 @@ public function test_release_reviews_the_structure_and_keeps_other_references(): $brokenEditor ->call('armRelease') ->assertSee('deaktiviert') - ->assertSee('content-elements/'.$soonBlocked->content_element_id) + ->assertSee('contentmanager/'.$soonBlocked->content_element_id) ->call('publishRevision') ->assertSet('releaseArmed', true); @@ -831,7 +831,7 @@ public function test_release_reviews_the_structure_and_keeps_other_references(): ->set('learningGoal', 'Der Hinweis bleibt sichtbar') ->call('armRelease') ->assertSee('Diese Fassung ist deaktiviert') - ->assertSee('content-elements/'.$soonBlocked->content_element_id); + ->assertSee('contentmanager/'.$soonBlocked->content_element_id); $this->assertSame(1, $other->composition->fresh()->versions()->count()); } diff --git a/tests/Feature/UebungNavigationTest.php b/tests/Feature/UebungNavigationTest.php index 762cdf0..82ea4f1 100644 --- a/tests/Feature/UebungNavigationTest.php +++ b/tests/Feature/UebungNavigationTest.php @@ -29,18 +29,20 @@ protected function setUp(): void Filament::setCurrentPanel(Filament::getPanel('verwaltung')); } - public function test_exercises_have_one_entry_in_the_content_group_next_to_media_modules_and_programs(): void + public function test_exercises_have_one_entry_in_the_content_group_after_programs_and_modules(): void { $this->assertSame('Inhalte', PracticeResource::getNavigationGroup()); $this->assertSame('Übungen', PracticeResource::getNavigationLabel()); + // Reihenfolge nach der Neuordnung: Programme, Module, Übungen, Contentmanager, dahinter die Kombinationen + // (vorher standen die Übungen vor Modulen und Programmen). $order = collect([PracticeResource::class, ExerciseResource::class, CourseResource::class, CombinationResource::class]) ->sortBy(fn (string $resource): int => $resource::getNavigationSort()) ->map(fn (string $resource): string => $resource::getNavigationLabel()) ->values() ->all(); - $this->assertSame(['Übungen', 'Module', 'Programme', 'Fachliche Kombinationen'], $order); + $this->assertSame(['Programme', 'Module', 'Übungen', 'Fachliche Kombinationen'], $order); } public function test_pillars_and_editorial_master_data_share_the_master_data_group(): void diff --git a/tests/Feature/VerwaltungNavigationTest.php b/tests/Feature/VerwaltungNavigationTest.php new file mode 100644 index 0000000..9d22eca --- /dev/null +++ b/tests/Feature/VerwaltungNavigationTest.php @@ -0,0 +1,203 @@ +actingAs($this->staff('redakteur'), 'staff'); + Filament::setCurrentPanel(Filament::getPanel('verwaltung')); + + $groups = collect(Filament::getNavigation())->keyBy(fn ($group): string => (string) $group->getLabel()); + $labels = collect($groups['Inhalte']->getItems())->map(fn ($item): string => (string) $item->getLabel())->values()->all(); + + $this->assertSame(['Programme', 'Module', 'Übungen', 'Contentmanager'], array_slice($labels, 0, 4)); + $this->assertGreaterThan(array_search('Contentmanager', $labels, true), array_search('Fachliche Kombinationen', $labels, true)); + $this->assertNotContains('Arbeitsplatz', $labels); + $this->assertNotContains('Medien', $labels); + $this->assertFalse(EditorialDesk::shouldRegisterNavigation()); + } + + public function test_the_entries_have_the_new_addresses(): void + { + $this->assertStringEndsWith('/verwaltung/programme', CourseResource::getUrl('index')); + $this->assertStringEndsWith('/verwaltung/module', ExerciseResource::getUrl('index')); + $this->assertStringEndsWith('/verwaltung/fachuebungen', PracticeResource::getUrl('index')); + $this->assertStringEndsWith('/verwaltung/contentmanager', ContentElementResource::getUrl('index')); + $this->assertStringEndsWith('/verwaltung/contentmanager/7/bearbeiten', ContentElementResource::getUrl('edit', ['record' => 7])); + $this->assertStringEndsWith('/verwaltung/arbeitsplatz?pillar=3', EditorialDesk::getUrl(['pillar' => 3])); + } + + public function test_the_shared_overview_stays_reachable_through_the_filter_link(): void + { + $this->actingAs($this->staff('redakteur'), 'staff') + ->get(EditorialDesk::getUrl(['pillar' => 1])) + ->assertOk() + ->assertSee('Programme und Module'); + } + + /** + * @return array + */ + public static function oldAddresses(): array + { + return [ + 'Programmliste' => ['/verwaltung/kurse', '/verwaltung/programme'], + 'Programm bearbeiten' => ['/verwaltung/kurse/12', '/verwaltung/programme/12'], + 'Modulliste' => ['/verwaltung/uebungen', '/verwaltung/module'], + 'Modul bearbeiten' => ['/verwaltung/uebungen/34', '/verwaltung/module/34'], + 'Medienliste' => ['/verwaltung/content-elements', '/verwaltung/contentmanager'], + 'Medium ansehen' => ['/verwaltung/content-elements/5', '/verwaltung/contentmanager/5'], + 'Medium bearbeiten' => ['/verwaltung/content-elements/5/bearbeiten', '/verwaltung/contentmanager/5/bearbeiten'], + ]; + } + + #[DataProvider('oldAddresses')] + public function test_an_old_address_redirects_to_the_new_one(string $old, string $new): void + { + $this->actingAs($this->staff('redakteur'), 'staff') + ->get($old) + ->assertRedirect(url($new)) + ->assertStatus(302); + } + + public function test_filters_and_other_parameters_survive_the_redirect(): void + { + $this->actingAs($this->staff('redakteur'), 'staff') + ->get('/verwaltung/content-elements?inhaltsart=3&suche=Abstand%20halten&einordnung[]=4&einordnung[]=9') + ->assertRedirect(url('/verwaltung/contentmanager?inhaltsart=3&suche=Abstand%20halten&einordnung[]=4&einordnung[]=9')); + + $this->get('/verwaltung/content-elements/5?bereich=inhalt&redaktion=1') + ->assertRedirect(url('/verwaltung/contentmanager/5?bereich=inhalt&redaktion=1')); + + $this->get('/verwaltung/uebungen/34?zurueck=%2Fverwaltung%2Fprogramme%2F1') + ->assertRedirect(url('/verwaltung/module/34?zurueck=%2Fverwaltung%2Fprogramme%2F1')); + } + + public function test_old_links_arrive_at_the_same_objects(): void + { + $content = app(ContentService::class); + $module = $content->createComposition('Modul Altlink', CompositionKind::Uebung); + $program = $content->createComposition('Programm Altlink', CompositionKind::Kurs); + $element = $content->createElement('text', 'text', 'Medium Altlink'); + + $this->actingAs($this->staff('redakteur'), 'staff'); + + $this->through('/verwaltung/uebungen/'.$module->id)->assertOk()->assertSee('Modul Altlink'); + $this->through('/verwaltung/kurse/'.$program->id)->assertOk()->assertSee('Programm Altlink'); + $this->through('/verwaltung/content-elements/'.$element->id)->assertOk()->assertSee('Medium Altlink'); + $this->through('/verwaltung/uebungen')->assertOk()->assertSee('Modul Altlink')->assertDontSee('Programm Altlink'); + $this->through('/verwaltung/kurse')->assertOk()->assertSee('Programm Altlink')->assertDontSee('Modul Altlink'); + } + + public function test_roles_apply_to_old_addresses_as_to_the_new_ones(): void + { + $content = app(ContentService::class); + $module = $content->createComposition('Modul Rechte', CompositionKind::Uebung); + $element = $content->createElement('text', 'text', 'Medium Rechte'); + + // Katalogverwalter: Medien ansehen ja, bearbeiten nein, Module und Programme nein. + $this->actingAs($this->staff('katalogverwalter'), 'staff'); + $this->through('/verwaltung/uebungen')->assertForbidden(); + $this->through('/verwaltung/uebungen/'.$module->id)->assertForbidden(); + $this->through('/verwaltung/kurse')->assertForbidden(); + $this->through('/verwaltung/content-elements')->assertOk(); + $this->through('/verwaltung/content-elements/'.$element->id)->assertOk(); + $this->through('/verwaltung/content-elements/'.$element->id.'/bearbeiten')->assertForbidden(); + + // Dasselbe über die neuen Adressen. + $this->through('/verwaltung/module')->assertForbidden(); + $this->through('/verwaltung/contentmanager/'.$element->id.'/bearbeiten')->assertForbidden(); + + // Systemverwalter: weder Module noch Medien. + $this->actingAs($this->staff('systemverwalter'), 'staff'); + $this->through('/verwaltung/uebungen/'.$module->id)->assertForbidden(); + $this->through('/verwaltung/content-elements')->assertForbidden(); + } + + public function test_a_guest_is_sent_to_the_login_for_an_old_address(): void + { + foreach (['/verwaltung/kurse/1', '/verwaltung/uebungen', '/verwaltung/content-elements/1/bearbeiten'] as $old) { + $this->get($old)->assertRedirect('/verwaltung/login'); + } + } + + public function test_every_moved_address_has_a_redirect_and_a_new_resource(): void + { + $paths = collect(app('router')->getRoutes()->getRoutes())->map(fn ($route): string => $route->uri())->all(); + + foreach (LegacyAddresses::MOVED as $old => $new) { + $this->assertContains('verwaltung/'.$old.'/{rest?}', $paths); + $this->assertContains('verwaltung/'.$new, $paths); + } + } + + public function test_the_edit_pages_link_back_to_their_own_list(): void + { + $content = app(ContentService::class); + $module = $content->createComposition('Modul Rücklink', CompositionKind::Uebung); + $program = $content->createComposition('Programm Rücklink', CompositionKind::Kurs); + + $this->actingAs($this->staff('redakteur'), 'staff') + ->get(CourseResource::getUrl('edit', ['record' => $program])) + ->assertOk() + ->assertSee('Zu den Programmen') + ->assertSee(CourseResource::getUrl('index'), false) + ->assertDontSee('Zum Arbeitsplatz'); + + $this->get(ExerciseResource::getUrl('edit', ['record' => $module])) + ->assertOk() + ->assertSee('Zu den Modulen') + ->assertSee(ExerciseResource::getUrl('index'), false) + ->assertDontSee('Zum Arbeitsplatz'); + } + + public function test_the_lists_no_longer_point_to_the_desk_and_the_media_breadcrumb_uses_the_new_name(): void + { + $element = app(ContentService::class)->createElement('text', 'text', 'Medium Brot'); + + $this->actingAs($this->staff('redakteur'), 'staff') + ->get(CourseResource::getUrl('index'))->assertOk()->assertDontSee('auch auf dem Arbeitsplatz'); + $this->get(CombinationResource::getUrl('index'))->assertOk(); + $this->get(ContentElementResource::getUrl('view', ['record' => $element])) + ->assertOk() + ->assertSee('Contentmanager'); + } + + /** Folgt der Weiterleitung einer alten Adresse bis zum Ziel (Laravel setzt das Folgen nach jeder Anfrage zurück). */ + private function through(string $url): TestResponse + { + return $this->followingRedirects()->get($url); + } + + private function staff(string $role): User + { + $user = User::factory()->{$role}()->create(); + $user->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP'); + + return $user; + } +}