*/ private function heading(string $text): array { return ['type' => 'heading', 'v' => 1, 'data' => ['heading' => $text]]; } /** * @return array */ private function prose(string $text): array { return ['type' => 'prose', 'v' => 1, 'data' => ['body' => $text]]; } /** * @param list> $sections */ private function publish(string $path, array $sections): Page { $service = app(PageService::class); $page = Page::query()->create(['path' => $path]); $service->publish($page, $service->saveRevision($page, $sections, null, null, null)); return $page->fresh(); } public function test_sections_render_grid_ratios_backgrounds_and_dividers(): void { $this->publish('/raster', [ ['layout' => 'u4', 'style' => ['background' => 'dark', 'divider' => 'accent'], 'slots' => [$this->heading('Einstieg')]], ['layout' => 'u1_3', 'style' => ['background' => 'light', 'width' => 'wide', 'divider' => 'line'], 'slots' => [$this->prose('Schmal'), $this->prose('Breit')]], ['layout' => 'u1_1_1_1', 'style' => ['background' => 'accent', 'spacing' => 'large'], 'slots' => [$this->prose('A'), $this->prose('B'), $this->prose('C'), $this->prose('D')]], ['layout' => 'u2_2', 'style' => ['divider' => 'line'], 'slots' => [$this->prose('Letzter')]], ]); $html = $this->get('/raster')->assertOk()->getContent(); $this->assertStringContainsString('page-section section-bg-dark section-width-standard section-space-top-compact section-space-bottom-compact section-gap-normal section-layout-u4 scope-dark', $html); $this->assertStringContainsString('section-bg-light section-width-wide', $html); $this->assertStringContainsString('--section-cols-lg: minmax(0, 1fr) minmax(0, 3fr); --section-cols-md: minmax(0, 1fr)', $html); $this->assertStringContainsString('--section-cols-md: repeat(2, minmax(0, 1fr))', $html, 'Vier gleiche Plätze stehen auf dem Tablet als 2 × 2.'); // Eingabe im Format der Version 1 („spacing“): oben und unten großzügig, Widget-Abstand wie bisher normal. $this->assertStringContainsString('section-bg-accent section-width-standard section-space-top-large section-space-bottom-large section-gap-normal section-layout-u1-1-1-1 scope-accent', $html); $this->assertStringContainsString('section-divider section-divider-accent', $html); $this->assertSame(1, substr_count($html, 'section-divider section-divider-line'), 'Nach dem letzten Abschnitt steht kein Trenner.'); $this->assertSame(1, substr_count($html, '

'), 'Nur das erste Widget der Seite ist Überschrift erster Ordnung.'); $this->assertLessThan(strpos($html, 'Breit'), strpos($html, 'Schmal'), 'Lese- und Fokusreihenfolge folgt den Plätzen.'); } public function test_empty_slots_and_empty_sections_leave_no_gaps(): void { $this->publish('/luecken', [ ['layout' => 'u1_2_1', 'style' => [], 'slots' => [$this->prose('Links'), null, $this->prose('Rechts')]], ['layout' => 'u2_2', 'style' => ['background' => 'dark'], 'slots' => [null, null]], ['layout' => 'u1_3', 'style' => [], 'slots' => [null, $this->prose('Allein')]], ]); $html = $this->get('/luecken')->assertOk()->getContent(); $this->assertStringContainsString('data-slots="2" style="--section-cols-lg: minmax(0, 1fr) minmax(0, 1fr)', $html, 'Die übrigen Plätze teilen sich die Breite im Verhältnis ihrer Einheiten.'); $this->assertStringContainsString('data-slots="1" style="--section-cols-lg: minmax(0, 1fr)', $html); $this->assertStringNotContainsString('section-bg-dark', $html, 'Ein Abschnitt ohne Inhalt entfällt samt Fläche.'); } public function test_background_image_comes_from_the_public_area_with_focus_and_overlay(): void { Queue::fake(); $this->publish('/bild', [ ['layout' => 'u4', 'style' => ['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => 'top_left', 'overlay' => 'dark'], 'slots' => [$this->heading('Auf Bild')]], ['layout' => 'u4', 'style' => ['background' => 'image', 'image' => 'cms/zweites.jpg', 'overlay' => 'light'], 'slots' => [$this->prose('Hell')]], ]); $html = $this->get('/bild')->assertOk()->getContent(); $this->assertStringContainsString('section-bg-image', $html); $this->assertStringContainsString('section-overlay-dark scope-dark', $html); $this->assertStringContainsString('section-overlay-light scope-light', $html); $this->assertMatchesRegularExpression('#]*object-position: 0% 0%#', $html); $this->assertMatchesRegularExpression('#publish('/gleich', [ ['layout' => 'u2_2', 'style' => ['background' => 'light'], 'slots' => [$this->heading('Links'), $this->prose('Rechts')]], ]); $editor = User::factory()->redakteur()->create(); $public = $this->get('/gleich')->getContent(); $preview = $this->actingAs($editor, 'staff')->get(route('pages.preview', $page->published_revision_id))->getContent(); $this->assertSame($this->sectionsMarkup($public), $this->sectionsMarkup($preview)); $this->assertStringContainsString('Vorschau einer unveröffentlichten Revision', $preview); } public function test_public_page_is_identical_for_guests_and_members(): void { // Schrift-Vorabladehinweise gibt der Rahmen je Prozess nur einmal aus; sie hängen nicht vom Besucher ab. $withoutPreload = fn (string $html): string => preg_replace('#]*>\s*#', '', $html); $guest = $withoutPreload($this->get('/praevention')->assertOk()->getContent()); $member = $withoutPreload($this->actingAs(User::factory()->create())->get('/praevention')->assertOk()->getContent()); $this->assertSame($guest, $member, 'Öffentliche Seiten hängen nicht vom Anmeldestatus ab (ADR-32).'); $this->assertStringContainsString('href="'.route('member.dashboard').'"', $guest); $this->assertStringContainsString('Mitgliederbereich', $guest); } public function test_global_layout_has_header_navigation_mobile_menu_and_footer(): void { $html = $this->get('/praevention')->assertOk()->getContent(); $this->assertStringContainsString('Prävention#', $html); $this->assertStringContainsString('data-site-menu-button', $html); $this->assertStringContainsString('aria-controls="site-nav"', $html); $this->assertStringContainsString('class="site-footer scope-dark"', $html); $this->assertStringContainsString('

', $html); $this->assertStringContainsString('Impressum', $html); $this->assertStringNotContainsString('Warenkorb', $html, 'Ohne Warenkorb erscheint kein funktionsloser Kaufknopf.'); $this->assertStringNotContainsString('fonts.bunny.net', $html); $this->assertStringNotContainsString('fonts.googleapis.com', $html); } public function test_cart_entry_appears_only_when_enabled(): void { config(['cms.cart.enabled' => true, 'cms.cart.url' => '/warenkorb']); $this->get('/praevention')->assertSee('Warenkorb')->assertSee('href="/warenkorb"', false); } public function test_submenus_footer_groups_and_hidden_parents(): void { $parent = NavigationItem::query()->where('label', 'Prävention')->firstOrFail(); NavigationItem::query()->create(['label' => 'Grenzen', 'url' => '/themen/grenzen', 'placement' => 'header', 'parent_id' => $parent->id, 'sort_order' => 1]); NavigationItem::query()->create(['label' => 'Kontaktformular', 'url' => '/kontakt', 'placement' => 'footer_contact', 'sort_order' => 1]); NavigationItem::query()->create(['label' => 'Fußkind', 'url' => '/x', 'placement' => 'footer', 'parent_id' => $parent->id, 'sort_order' => 2]); $html = $this->get('/praevention')->getContent(); $this->assertStringContainsString('site-nav-item has-children is-active-trail', $html); $this->assertStringContainsString('aria-controls="untermenue-'.$parent->id.'"', $html); $this->assertStringContainsString('Untermenü Prävention', $html); $this->assertMatchesRegularExpression('#