Designiteration 1 auf Grundlage des Brand-UI-Kits (vorläufige Werte): - Kopfzeile mit konstanter Box und zwei Zuständen (großzügig, kompakt beim Scrollen) ohne Layoutsprung; Navigation bricht nie um, sondern verkürzt erst den Kontozugang und schaltet dann in den Menümodus. Scrollbalken-Reserve, gemeinsames Breitenmodell (Lesebereich, Standard, Breit, Vollbreite), Wortmarke und Inhalt fluchten. - Fokusfalle im Mobilmenü schließt auch den Weg von der Menü-Schaltfläche in den Inhalt. - Fußbereich mit Grundzeile für rechtliche Links und grünem Bogen. - Markenakzente (Unterstreichung, Strahlen, Bogen) als Komponenten. - Hero: Varianten Markenbühne (randlos) und Editorial, zweite Schaltfläche, Bildausschnitt. Bild und Text: Bildformat und Ausschnitt. Karten: hervorgehobene erste Karte, ganze Karte klickbar. Programmkarten mit Markentafel. Alles additiv, ohne neue Version. Testanpassungen: Die Website-Wortmarke trägt jetzt brand-lockup, die erste Hero-Schaltfläche button-brand (beabsichtigte Gestaltung). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
177 lines
8.8 KiB
PHP
177 lines
8.8 KiB
PHP
<?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 Illuminate\Validation\ValidationException;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Designiteration 1: stabiler Website-Rahmen, Markenakzente und neue Widget-Varianten.
|
|
* Alle Erweiterungen sind additiv: gespeicherte Widgets bleiben gültig und werden wie bisher dargestellt.
|
|
*/
|
|
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-lockup"', $html);
|
|
$this->assertStringContainsString('class="site-icon-link site-account-link" href="'.route('member.dashboard').'"', $html);
|
|
// Menümodus wird direkt nach der Kopfzeile gesetzt, nicht erst durch das Modul-Skript.
|
|
$this->assertMatchesRegularExpression('#</header>\s*<script>\(function \(h\) \{ if \(window\.matchMedia\(\'\(max-width: 74\.99rem\)\'\)\.matches\)#', $html);
|
|
}
|
|
|
|
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_hero_stored_before_this_iteration_renders_unchanged_content(): void
|
|
{
|
|
$html = $this->publish('/alt', [[
|
|
'type' => 'hero', 'v' => 1, 'variant' => 'standard',
|
|
'data' => ['heading' => 'Stark im Alltag', 'text' => 'Einstieg', 'cta_label' => 'Mehr', 'cta_url' => '/praevention', 'alt' => 'Bild'],
|
|
'refs' => ['image' => 'cms/alt.jpg'],
|
|
]]);
|
|
|
|
$this->assertStringContainsString('class="hero hero-standard hero-with-image"', $html);
|
|
$this->assertStringContainsString('<h1>Stark im Alltag</h1>', $html);
|
|
$this->assertStringContainsString('<p class="lede">Einstieg</p>', $html);
|
|
$this->assertSame(1, substr_count($html, 'class="button button-brand"'));
|
|
$this->assertStringNotContainsString('button-secondary', $html);
|
|
$this->assertStringContainsString('alt="Bild" loading="eager" fetchpriority="high" decoding="async"', $html);
|
|
$this->assertStringNotContainsString('section-bleed', $html);
|
|
}
|
|
|
|
public function test_brand_stage_bleeds_only_when_it_is_alone_in_its_section_and_has_an_image(): void
|
|
{
|
|
$stage = fn (?string $image) => [
|
|
'type' => 'hero', 'v' => 1, 'variant' => 'stage',
|
|
'settings' => ['focus' => 'left', 'text_side' => 'left'],
|
|
'data' => ['heading' => 'Bühne', 'alt' => $image ? 'Motiv' : null],
|
|
'refs' => ['image' => $image],
|
|
];
|
|
|
|
$html = $this->publish('/buehne', [
|
|
$this->section('u4', [$stage('cms/buehne.jpg')], ['width' => 'full']),
|
|
$this->section('u2_2', [$stage('cms/buehne.jpg'), ['type' => 'prose', 'v' => 1, 'data' => ['body' => '<p>Text</p>']]]),
|
|
$this->section('u4', [$stage(null)]),
|
|
]);
|
|
|
|
$this->assertSame(1, substr_count($html, 'section-bleed'));
|
|
$this->assertMatchesRegularExpression('#class="page-section [^"]*section-bleed"#', $html);
|
|
$this->assertStringContainsString('class="hero hero-stage hero-with-image hero-text-left" style="--hero-focus: 0% 50%"', $html);
|
|
$this->assertStringContainsString('<div class="hero-media">', $html);
|
|
// Nur das erste Bild der Seite wird sofort geladen.
|
|
$this->assertSame(1, substr_count($html, 'fetchpriority="high"'));
|
|
}
|
|
|
|
public function test_hero_renders_a_second_action_and_rejects_unsafe_targets(): void
|
|
{
|
|
$html = $this->publish('/zwei', [[
|
|
'type' => 'hero', 'v' => 1, 'variant' => 'editorial',
|
|
'data' => ['heading' => 'Konzept', 'cta_label' => 'Programme', 'cta_url' => '/programme', 'cta2_label' => 'Mitgliederbereich', 'cta2_url' => '/bereich'],
|
|
]]);
|
|
|
|
$this->assertStringContainsString('class="hero hero-editorial"', $html);
|
|
$this->assertStringContainsString('<a class="button button-brand" href="/programme">Programme</a>', $html);
|
|
$this->assertStringContainsString('<a class="button button-secondary" href="/bereich">Mitgliederbereich</a>', $html);
|
|
|
|
try {
|
|
app(WidgetRegistry::class)->normalize([[
|
|
'type' => 'hero', 'v' => 1, 'variant' => 'stage',
|
|
'data' => ['heading' => 'X', 'cta2_label' => 'Böse', 'cta2_url' => 'javascript:alert(1)'],
|
|
]]);
|
|
$this->fail('Unsicheres zweites Linkziel wurde angenommen.');
|
|
} catch (ValidationException $exception) {
|
|
$this->assertArrayHasKey('blocks.0.data.cta2_url', $exception->errors());
|
|
}
|
|
}
|
|
|
|
public function test_image_settings_are_enumerations_only(): void
|
|
{
|
|
$html = $this->publish('/format', [[
|
|
'type' => 'image_text', 'v' => 2, 'variant' => 'image_left',
|
|
'settings' => ['format' => 'portrait', 'focus' => 'top_right'],
|
|
'data' => ['title' => 'Hochformat', 'body' => '<p>Text</p>', 'alt' => 'Motiv'],
|
|
'refs' => ['image' => 'cms/hoch.jpg'],
|
|
]]);
|
|
|
|
$this->assertStringContainsString('class="image-text image-text-left image-format-portrait" style="--image-focus: 100% 0%"', $html);
|
|
|
|
try {
|
|
app(WidgetRegistry::class)->normalize([[
|
|
'type' => 'image_text', 'v' => 2, 'variant' => 'image_left',
|
|
'settings' => ['format' => 'panorama; color: red'],
|
|
'data' => ['body' => '<p>Text</p>'],
|
|
]]);
|
|
$this->fail('Freier Einstellungswert wurde angenommen.');
|
|
} catch (ValidationException $exception) {
|
|
$this->assertArrayHasKey('blocks.0.settings.format', $exception->errors());
|
|
}
|
|
}
|
|
|
|
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']);
|
|
}
|
|
}
|