Führe Abschnitte mit Raster, gemeinsames Designsystem und globales Website-Gerüst ein.
CI Feature / test (push) Failing after 20s

- Seite → Abschnitte → Plätze → Widgets: sechs Raster mit höchstens vier Einheiten,
  Hintergrund, Breite, Abstand und Trenner als Aufzählungswerte; je Platz ein Widget
  aus dem bestehenden Register. Neue Spalte page_revisions.sections (ergänzend);
  blocks erhält weiterhin alle Widgets in Lesereihenfolge als Rollback-Fassung.
- Widgets erhalten Mindest- und Vorzugsbreite; Darstellung über Container-Abfragen.
- Editor: Abschnitts-Repeater mit grafischer Rasterauswahl, Plätzen im Rasterverhältnis,
  breiter Arbeitsfläche, kompakten Vorschauen ohne Bildlaufleiste, Meldungen mit
  Abschnitt und Platz; Rasterwechsel entfernt nie ein Widget. Seite duplizieren.
- Designsystem: Marken- und Bedeutungs-Tokens (vorläufig), gemeinsame Grundkomponenten,
  Nunito/Source Sans 3 lokal; Mitgliederbereich nutzt dieselben Tokens und die Wortmarke.
- Kopfzeile, mobile Navigation, Untermenü (parent_id, ergänzend), Fußbereichsgruppen,
  vorbereiteter Warenkorbzugang (abgeschaltet). Öffentliche Seiten gleich für alle Besucher.
- cms:revert-published als Wiederherstellungsweg vor einem Code-Rollback.

Die Editor-Tests der ersten Iteration sind bewusst auf den neuen Formularzustand
(sections statt blocks) umgestellt; ihre Prüfungen gelten unverändert für die Widgets.
Der Vorschautest erwartet keine anmeldeabhängige Kopfzeile mehr (ADR-32).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-17 20:34:06 +01:00
1 parent db4bd30319
commit 480d55989b
57 files changed
+4730 -818

No files matched your search

+221 -42
View File
@@ -8,6 +8,7 @@
use App\Filament\Resources\NavigationItems\Pages\ManageNavigationItems;
use App\Filament\Resources\Pages\Pages\CreatePage;
use App\Filament\Resources\Pages\Pages\EditPage;
use App\Filament\Resources\Pages\Pages\ListPages;
use App\Filament\Support\WidgetEditor;
use App\Models\User;
use Filament\Actions\Testing\TestAction;
@@ -19,6 +20,11 @@
use Tests\Support\BuildsCatalog;
use Tests\TestCase;
/**
* Seiteneditor mit Abschnitten und Plätzen. Der Formularzustand ist seit dem Abschnittsraster
* {sections: {uuid: {id, layout, style, slots: {uuid: {widget: {uuid: Builder-Eintrag}}}}}}
* statt einer flachen Bausteinliste; die Prüfungen der ersten Iteration gelten unverändert für die Widgets darin.
*/
class CmsEditorTest extends TestCase
{
use BuildsCatalog;
@@ -31,35 +37,48 @@ protected function setUp(): void
Filament::setCurrentPanel(Filament::getPanel('verwaltung'));
}
public function test_editor_creates_a_page_from_registered_widgets_without_publishing_it(): void
public function test_editor_creates_a_page_with_sections_and_registered_widgets_without_publishing_it(): void
{
$program = $this->composition('Programm Abstand', 'programm');
$editor = $this->editor();
Livewire::actingAs($editor, 'staff')
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm([
'path' => '/themen-test',
'seo_title' => 'Themenseite',
'blocks' => $this->keyed([
['type' => 'hero', 'data' => ['variant' => 'highlight', 'data' => ['heading' => 'Stark im Alltag', 'text' => 'Einstieg']]],
['type' => 'image_text', 'data' => ['variant' => 'image_right', 'data' => ['title' => 'Worum es geht', 'body' => '<p>Text mit <strong>Betonung</strong></p>'], 'refs' => []]],
['type' => 'cards', 'data' => ['variant' => 'compact', 'data' => ['items' => $this->keyed([['title' => 'Prävention', 'url' => '/praevention']])]]],
['type' => 'catalog_cards', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Programme'], 'refs' => ['items' => $this->keyed([['type' => 'composition', 'id' => $program->composition_id]])]]],
]),
'sections' => [
$this->sectionState('u4', [
['type' => 'hero', 'data' => ['variant' => 'highlight', 'data' => ['heading' => 'Stark im Alltag', 'text' => 'Einstieg']]],
], ['background' => 'dark', 'divider' => 'accent']),
$this->sectionState('u1_3', [
['type' => 'cards', 'data' => ['variant' => 'compact', 'data' => ['items' => $this->keyed([['title' => 'Prävention', 'url' => '/praevention']])]]],
['type' => 'image_text', 'data' => ['variant' => 'image_right', 'data' => ['title' => 'Worum es geht', 'body' => '<p>Text mit <strong>Betonung</strong></p>'], 'refs' => []]],
], ['width' => 'wide']),
$this->sectionState('u2_2', [
['type' => 'catalog_cards', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Programme'], 'refs' => ['items' => $this->keyed([['type' => 'composition', 'id' => $program->composition_id]])]]],
null,
]),
],
])
->call('create')
->assertHasNoFormErrors();
$page = Page::query()->where('path', '/themen-test')->firstOrFail();
$blocks = $page->latestRevision->blocks;
$revision = $page->latestRevision;
$sections = $revision->sections;
$blocks = $revision->blocks;
$this->assertNull($page->published_revision_id);
$this->assertSame(['hero', 'image_text', 'cards', 'catalog_cards'], array_column($blocks, 'type'));
$this->assertSame(['highlight', 'image_right', 'compact', 'standard'], array_column($blocks, 'variant'));
$this->assertSame([2], array_values(array_unique([$blocks[1]['v']])));
$this->assertStringContainsString('<strong>Betonung</strong>', $blocks[1]['data']['body']);
$this->assertSame([['title' => 'Prävention', 'text' => null, 'url' => '/praevention', 'image' => null]], $blocks[2]['data']['items']);
$this->assertSame(['u4', 'u1_3', 'u2_2'], array_column($sections, 'layout'));
$this->assertSame('dark', $sections[0]['style']['background']);
$this->assertSame('accent', $sections[0]['style']['divider']);
$this->assertSame('wide', $sections[1]['style']['width']);
$this->assertNull($sections[2]['slots'][1], 'Ein leerer Platz bleibt als Platz erhalten.');
$this->assertSame(['hero', 'cards', 'image_text', 'catalog_cards'], array_column($blocks, 'type'), 'Die Rollback-Spalte enthält alle Widgets in Lesereihenfolge.');
$this->assertSame(['highlight', 'compact', 'image_right', 'standard'], array_column($blocks, 'variant'));
$this->assertSame(2, $blocks[2]['v']);
$this->assertStringContainsString('<strong>Betonung</strong>', $blocks[2]['data']['body']);
$this->assertSame([['title' => 'Prävention', 'text' => null, 'url' => '/praevention', 'image' => null]], $blocks[1]['data']['items']);
$this->assertSame([['type' => 'composition', 'id' => $program->composition_id]], $blocks[3]['refs']['items']);
$this->get('/themen-test')->assertNotFound();
}
@@ -73,8 +92,8 @@ public function test_existing_page_opens_in_the_editor_and_saves_without_changin
$component = Livewire::actingAs($this->editor(), 'staff')
->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.blocks');
$this->assertSame(['heading', 'prose', 'cards', 'call_to_action'], array_column(array_values($state), 'type'));
$this->assertSame(['heading', 'prose', 'cards', 'call_to_action'], $this->widgetTypes($component->get('data.sections')));
$this->assertSame(['u4', 'u4', 'u4', 'u4'], array_column(array_values($component->get('data.sections')), 'layout'), 'Bestand wird als einspaltige Abschnitte geöffnet.');
$component->call('save')->assertHasNoFormErrors();
@@ -82,6 +101,7 @@ public function test_existing_page_opens_in_the_editor_and_saves_without_changin
$this->assertSame($live, $page->published_revision_id);
$this->assertNotSame($live, $page->latestRevision->id);
$this->assertSame(['heading', 'prose', 'cards', 'call_to_action'], array_column($page->latestRevision->blocks, 'type'));
$this->assertCount(4, $page->latestRevision->sections);
$this->assertSame($before, $this->mainText($this->get('/')->getContent()));
Livewire::actingAs($this->editor(), 'staff')
@@ -100,17 +120,76 @@ public function test_editor_reorders_and_duplicates_sections(): void
$page = Page::query()->where('path', '/')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.blocks');
$state = $component->get('data.sections');
$keys = array_keys($state);
$reordered = [$keys[3] => $state[$keys[3]], $keys[0] => $state[$keys[0]], $keys[1] => $state[$keys[1]], $keys[2] => $state[$keys[2]]];
$copy = $state[$keys[1]];
$reordered[(string) Str::uuid()] = $copy;
$reordered[(string) Str::uuid()] = $state[$keys[1]];
$component->set('data.blocks', $reordered)->call('save')->assertHasNoFormErrors();
$component->set('data.sections', $reordered)->call('save')->assertHasNoFormErrors();
$blocks = $page->fresh()->latestRevision->blocks;
$this->assertSame(['call_to_action', 'heading', 'prose', 'cards', 'prose'], array_column($blocks, 'type'));
$this->assertCount(5, array_unique(array_column($blocks, 'id')), 'Ein dupliziertes Widget erhält eine eigene Kennung.');
$revision = $page->fresh()->latestRevision;
$this->assertSame(['call_to_action', 'heading', 'prose', 'cards', 'prose'], array_column($revision->blocks, 'type'));
$this->assertCount(5, array_unique(array_column($revision->blocks, 'id')), 'Ein dupliziertes Widget erhält eine eigene Kennung.');
$this->assertCount(5, array_unique(array_column($revision->sections, 'id')), 'Ein duplizierter Abschnitt erhält eine eigene Kennung.');
}
public function test_layout_change_keeps_widgets_and_rejects_layouts_with_too_few_slots(): void
{
$page = Page::query()->where('path', '/')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.sections');
$keys = array_keys($state);
// Raster wechseln: fehlende Plätze entstehen, das vorhandene Widget bleibt im ersten Platz.
$component->set("data.sections.{$keys[0]}.layout", 'u1_1_1_1');
$slots = $component->get("data.sections.{$keys[0]}.slots");
$this->assertCount(4, $slots);
$this->assertSame(['heading'], $this->widgetTypes([['slots' => $slots]]));
// Zweites Widget in Platz 2 setzen und auf zwei Plätze wechseln: leere Plätze entfallen, Widgets bleiben.
$slotKeys = array_keys($slots);
$secondWidget = $state[$keys[1]]['slots'][array_key_first($state[$keys[1]]['slots'])]['widget'];
$component->set("data.sections.{$keys[0]}.slots.{$slotKeys[1]}.widget", $secondWidget);
$component->set("data.sections.{$keys[0]}.layout", 'u2_2');
$this->assertCount(2, $component->get("data.sections.{$keys[0]}.slots"));
$this->assertSame(['heading', 'prose'], $this->widgetTypes([['slots' => $component->get("data.sections.{$keys[0]}.slots")]]));
// Ein Raster mit nur einem Platz ist gesperrt, solange zwei Widgets eingesetzt sind; kein Widget geht verloren.
$component->set("data.sections.{$keys[0]}.layout", 'u4');
$this->assertCount(2, $component->get("data.sections.{$keys[0]}.slots"));
$component->call('save')->assertHasErrors(["data.sections.{$keys[0]}.layout"]);
$component->set("data.sections.{$keys[0]}.layout", 'u2_2');
$remaining = $component->get('data.sections');
unset($remaining[$keys[1]]);
$component->set('data.sections', $remaining)->call('save')->assertHasNoFormErrors();
$sections = $page->fresh()->latestRevision->sections;
$this->assertCount(3, $sections);
$this->assertSame('u2_2', $sections[0]['layout']);
$this->assertSame(['heading', 'prose'], array_column($sections[0]['slots'], 'type'));
}
public function test_widget_too_wide_for_its_slot_is_reported_at_the_section(): void
{
$component = Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm([
'path' => '/raster-pruefung',
'sections' => [
$this->sectionState('u1_3', [
['type' => 'hero', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Zu schmal']]],
null,
], ['background' => 'accent', 'spacing' => 'large', 'divider' => 'line']),
],
])
->call('create')
->assertNotified('Nicht gespeichert');
$key = array_key_first($component->get('data.sections'));
$component->assertHasErrors(["data.sections.$key.slots"]);
$this->assertNull(Page::query()->where('path', '/raster-pruefung')->first());
}
public function test_unsafe_link_is_reported_at_the_section_and_nothing_is_saved(): void
@@ -119,11 +198,17 @@ public function test_unsafe_link_is_reported_at_the_section_and_nothing_is_saved
$revisions = $page->revisions()->count();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$key = array_keys($component->get('data.blocks'))[3];
$sectionKey = array_keys($component->get('data.sections'))[3];
$slotKey = array_key_first($component->get("data.sections.$sectionKey.slots"));
$widgetKey = array_key_first($component->get("data.sections.$sectionKey.slots.$slotKey.widget"));
$component->set("data.blocks.$key.data.data.url", 'javascript:alert(1)')
$component->set("data.sections.$sectionKey.slots.$slotKey.widget.$widgetKey.data.data.url", 'javascript:alert(1)')
->call('save')
->assertHasErrors(["data.blocks.$key.data.data.url"]);
->assertHasErrors([
"data.sections.$sectionKey.slots.$slotKey.widget.$widgetKey.data.data.url",
"data.sections.$sectionKey.slots",
])
->assertNotified('Nicht gespeichert');
$this->assertSame($revisions, $page->revisions()->count());
}
@@ -136,23 +221,74 @@ public function test_errors_found_only_by_the_registry_are_announced_with_the_se
$page = Page::query()->where('path', '/')->firstOrFail();
$revisions = $page->revisions()->count();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.blocks');
$state[(string) Str::uuid()] = ['type' => 'hero', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Mit Bild'], 'refs' => ['image' => 'cms/bild.jpg']]];
$state = $component->get('data.sections');
$state[(string) Str::uuid()] = $this->sectionState('u4', [
['type' => 'hero', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Mit Bild'], 'refs' => ['image' => 'cms/bild.jpg']]],
]);
$component->set('data.blocks', $state)
$component->set('data.sections', $state)
->call('save')
->assertNotified('Nicht gespeichert');
$this->assertSame($revisions, $page->revisions()->count());
}
public function test_section_background_image_is_saved_and_published_from_the_public_area(): void
{
Storage::fake('media_public');
Storage::fake('cms_incoming');
Storage::disk('media_public')->put('cms/flaeche.jpg', 'bild');
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm([
'path' => '/flaechen',
'sections' => [
$this->sectionState('u2_2', [
['type' => 'heading', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Auf Bild']]],
['type' => 'prose', 'data' => ['variant' => 'standard', 'data' => ['body' => 'Text']]],
], ['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => 'top', 'overlay' => 'dark']),
],
])
->call('create')
->assertHasNoFormErrors();
$style = Page::query()->where('path', '/flaechen')->firstOrFail()->latestRevision->sections[0]['style'];
$this->assertSame(['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => 'top', 'overlay' => 'dark'], array_intersect_key($style, array_flip(['background', 'image', 'focus', 'overlay'])));
}
public function test_page_can_be_duplicated_as_an_unpublished_draft_without_changing_the_source(): void
{
$source = Page::query()->where('path', '/praevention')->firstOrFail();
$sourceRevision = $source->latestRevision->id;
$editor = $this->editor();
Livewire::actingAs($editor, 'staff')
->test(ListPages::class)
->callAction(TestAction::make('duplicate')->table($source), ['path' => '/praevention'])
->assertHasActionErrors(['path']);
Livewire::actingAs($editor, 'staff')
->test(ListPages::class)
->callAction(TestAction::make('duplicate')->table($source), ['path' => '/neue-landingpage'])
->assertHasNoActionErrors();
$copy = Page::query()->where('path', '/neue-landingpage')->firstOrFail();
$this->assertNull($copy->published_revision_id);
$this->assertSame(
array_column($source->latestRevision->widgets(), 'type'),
array_column($copy->latestRevision->widgets(), 'type'),
);
$this->assertSame($sourceRevision, $source->fresh()->latestRevision->id, 'Die Vorlage bleibt unverändert.');
}
public function test_new_page_keeps_the_selected_pillars(): void
{
$pillar = app(PillarService::class)->create('Grenzen');
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm(['path' => '/grenzen-thema', 'pillars' => [$pillar->id], 'blocks' => []])
->fillForm(['path' => '/grenzen-thema', 'pillars' => [$pillar->id], 'sections' => []])
->call('create')
->assertHasNoFormErrors();
@@ -163,29 +299,30 @@ public function test_duplicated_section_keeps_its_new_id_across_saves(): void
{
$page = Page::query()->where('path', '/')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$state = $component->get('data.blocks');
$state = $component->get('data.sections');
$state[(string) Str::uuid()] = $state[array_key_first($state)];
$component->set('data.blocks', $state)->call('save')->assertHasNoFormErrors();
$component->set('data.sections', $state)->call('save')->assertHasNoFormErrors();
$first = array_column($page->fresh()->latestRevision->blocks, 'id');
$firstSections = array_column($page->fresh()->latestRevision->sections, 'id');
$component->call('save')->assertHasNoFormErrors();
$second = array_column($page->fresh()->latestRevision->blocks, 'id');
$this->assertCount(5, array_unique($first));
$this->assertSame($first, $second);
$this->assertSame($first, array_column($page->fresh()->latestRevision->blocks, 'id'));
$this->assertSame($firstSections, array_column($page->fresh()->latestRevision->sections, 'id'));
}
public function test_invalid_or_taken_paths_are_shown_at_the_path_field(): void
{
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm(['path' => '/praevention', 'blocks' => []])
->fillForm(['path' => '/praevention', 'sections' => []])
->call('create')
->assertHasErrors(['data.path']);
Livewire::actingAs($this->editor(), 'staff')
->test(CreatePage::class)
->fillForm(['path' => 'C:/Program Files/x', 'blocks' => []])
->fillForm(['path' => 'C:/Program Files/x', 'sections' => []])
->call('create')
->assertHasErrors(['data.path']);
@@ -215,15 +352,21 @@ public function test_block_preview_uses_the_public_widget_view_with_unsaved_stat
$this->assertStringContainsString('Karte B', $cards);
}
public function test_editor_offers_every_registered_widget_with_description(): void
public function test_editor_offers_every_registered_widget_layouts_and_section_design(): void
{
$page = Page::query()->where('path', '/')->firstOrFail();
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
$first = array_key_first($component->get('data.sections'));
Livewire::actingAs($this->editor(), 'staff')
->test(EditPage::class, ['record' => $page->id])
// Die Widget-Auswahl erscheint an jedem freien Platz.
$component->set("data.sections.$first.layout", 'u2_2')
->assertSee('Einstieg (Hero)')
->assertSee('Programm- und Modulkarten')
->assertSee('Titel und Beschreibung kommen automatisch aus den Fachdaten')
->assertSee('Braucht einen Platz ab 2 Rastereinheiten')
->assertSee('Gestaltung des Abschnitts')
->assertSee('1 + 2 + 1')
->assertSee('Widget einsetzen')
->assertSee('Entwurf speichern');
}
@@ -248,8 +391,9 @@ public function test_preview_with_device_widths_is_only_available_to_staff(): vo
->get(route('pages.preview', $revision))
->assertOk()
->assertSee('Vorschau einer unveröffentlichten Revision')
->assertSee('Registrieren')
->assertDontSee('Mitgliederbereich</a>', false);
->assertSee('<meta name="robots" content="noindex, nofollow">', false)
->assertSee('class="site-header"', false)
->assertSee('class="site-footer scope-dark"', false);
}
public function test_navigation_items_can_be_edited_hidden_reordered_and_removed(): void
@@ -299,6 +443,41 @@ private function editor(): User
return $editor;
}
/**
* Formularzustand eines Abschnitts; null steht für einen leeren Platz.
*
* @param list<array<string, mixed>|null> $widgets
* @param array<string, mixed> $style
* @return array<string, mixed>
*/
private function sectionState(string $layout, array $widgets, array $style = []): array
{
$slots = [];
foreach ($widgets as $widget) {
$slots[(string) Str::uuid()] = ['widget' => $widget === null ? [] : $this->keyed([$widget])];
}
return ['id' => null, 'layout' => $layout, 'style' => $style, 'slots' => $slots];
}
/**
* @param array<int|string, mixed> $sections
* @return list<string>
*/
private function widgetTypes(array $sections): array
{
$types = [];
foreach ($sections as $section) {
foreach ($section['slots'] ?? [] as $slot) {
foreach ($slot['widget'] ?? [] as $item) {
$types[] = $item['type'];
}
}
}
return $types;
}
/**
* @param list<array<string, mixed>> $items
* @return array<string, array<string, mixed>>