Files
laraundfelix/tests/Feature/CmsDesignIterationTest.php
T
LarsandClaude Sonnet 5.5 cf50d341f5
CI Feature / test (push) Successful in 2m24s
Zeige auf dem Desktop die offene Navigation und nutze den Burger nur als letzte Stufe
Die Messung der Kopfzeile verglich die Breite des Navigationsbereichs, der sich
auf den freien Platz dehnt, und schaltete bei acht Einträgen auf jeder Breite in
den Menümodus. Jetzt wird der echte Platzbedarf der Einträge gemessen und vor
dem Menümodus eine enge Stufe (kleinerer Abstand und Schrift) eingeschoben.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 18:00:52 +01:00

107 lines
5.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Tests\Feature;
use App\Domain\Cms\NavigationItem;
use App\Domain\Cms\Page;
use App\Domain\Cms\PageService;
use App\Domain\Cms\Widgets\WidgetRegistry;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
/**
* Designiteration 1: stabiler Website-Rahmen, Markenakzente und Karten-Varianten.
* Einstieg und Bild und Text sind seit Kit v1.6 Premium-Widgets (Tests in CmsPremiumWidgetsTest).
*/
class CmsDesignIterationTest extends TestCase
{
use RefreshDatabase;
/**
* @param list<array<string, mixed>> $content Abschnitte oder Widgets
*/
private function publish(string $path, array $content): string
{
$page = Page::query()->create(['path' => $path]);
$service = app(PageService::class);
$service->publish($page, $service->saveRevision($page, $content, null, null, null));
return $this->get($path)->assertOk()->getContent();
}
/**
* @param list<array<string, mixed>|null> $slots
* @param array<string, string> $style
* @return array<string, mixed>
*/
private function section(string $layout, array $slots, array $style = []): array
{
return ['layout' => $layout, 'style' => $style, 'slots' => $slots];
}
public function test_header_keeps_one_box_with_compact_bar_and_sets_the_menu_mode_before_painting(): void
{
$html = $this->publish('/rahmen', [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Rahmen']]]);
$this->assertStringContainsString('data-site-header-sentinel', $html);
$this->assertMatchesRegularExpression('#<header class="site-header" data-site-header>\s*<div class="site-header-bar">\s*<div class="site-header-inner ui-container">#', $html);
$this->assertStringContainsString('class="brand brand-logo"', $html);
$this->assertStringContainsString('width="242" height="128"', $html, 'Logo mit festen Maßen: keine Layoutverschiebung beim Laden.');
$this->assertStringContainsString('alt="Lara &amp; Felix – Stark im Alltag"', $html);
$this->assertStringContainsString('class="site-icon-link site-account-link" href="'.route('member.dashboard').'"', $html);
// Breitenstufen werden direkt nach der Kopfzeile gesetzt, vor dem ersten Zeichnen, nicht erst durch das Modul-Skript.
$this->assertMatchesRegularExpression('#</header>\s*<script>\s*window\.lufHeaderMode = function \(h\)#', $html);
$this->assertStringContainsString("window.lufHeaderMode(document.querySelector('[data-site-header]'));", $html);
}
public function test_header_prefers_an_open_navigation_on_desktop_and_uses_the_menu_only_as_last_stage(): void
{
$html = $this->publish('/rahmen-desktop', [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Rahmen']]]);
// Stufen: voll, Symbole, enge Navigation, erst zuletzt Menümodus. Gemessen wird der Platzbedarf der Einträge.
$this->assertStringContainsString("['is-account-compact', 'is-nav-tight']", $html);
$this->assertStringContainsString('last.getBoundingClientRect().right - items[0].getBoundingClientRect().left', $html);
$this->assertStringNotContainsString('list.scrollWidth', $html, 'scrollWidth dehnt sich auf den freien Platz und liefert nie den echten Bedarf.');
$css = file_get_contents(resource_path('css/site.css'));
$this->assertStringContainsString('.site-header.is-nav-tight .site-nav a', $css);
}
public function test_footer_shows_legal_links_in_the_base_row_and_a_decorative_arc(): void
{
$legal = Page::query()->create(['path' => '/impressum-test']);
NavigationItem::query()->create(['label' => 'Impressum', 'page_id' => $legal->id, 'placement' => 'footer_legal', 'sort_order' => 1, 'is_visible' => true]);
$html = $this->publish('/fuss', [['type' => 'heading', 'v' => 1, 'data' => ['heading' => 'Fuß']]]);
$this->assertMatchesRegularExpression('#<div class="site-footer-base ui-container">\s*<nav aria-labelledby="fuss-footer_legal">\s*<h2 id="fuss-footer_legal" class="visually-hidden">Rechtliches</h2>#', $html);
$this->assertStringContainsString('Impressum', $html);
$this->assertMatchesRegularExpression('#<svg class="brand-arc site-footer-arc"[^>]*aria-hidden="true"#', $html);
}
public function test_featured_cards_lead_with_the_first_card_and_link_the_whole_card(): void
{
$html = $this->publish('/karten', [[
'type' => 'cards', 'v' => 1, 'variant' => 'featured',
'data' => ['items' => [
['title' => 'Erste', 'text' => 'Hervorgehoben', 'url' => '/a', 'image' => 'cms/a.jpg'],
['title' => 'Zweite', 'url' => '/b'],
['title' => 'Dritte'],
]],
]]);
$this->assertStringContainsString('<ul class="cards cards-featured">', $html);
$this->assertMatchesRegularExpression('#<li class="card card-with-image card-linked card-lead">#', $html);
$this->assertSame(1, substr_count($html, 'card-lead'));
$this->assertMatchesRegularExpression('#<h3 class="card-title">\s*<a href="/a">Erste</a>#', $html);
$this->assertMatchesRegularExpression('#<h3 class="card-title">\s*Dritte\s*</h3>#', $html, 'Karten ohne Linkziel bleiben ohne Link.');
}
public function test_unknown_variant_from_a_newer_version_falls_back_to_the_default(): void
{
$widget = app(WidgetRegistry::class)->upcast(['type' => 'cards', 'v' => 1, 'variant' => 'masonry', 'data' => ['items' => [['title' => 'Eins']]]]);
$this->assertSame('standard', $widget['variant']);
}
}