Führe einen gemeinsamen Layoutvertrag ein und integriere die Premium-Widgets.
Layoutvertrag (ADR-38) in der bestehenden Registry: Jede Widget-Art erklärt zulässige Rasterbreiten (supportedUnits), Höhen aus einem gemeinsamen Vokabular (heights, gespeichert als settings.height), Darstellungsmodi und Verhalten bei wenig Platz. Unzulässige Breiten werden beim Speichern verständlich abgewiesen; Höhe „fill“ streckt den Handlungsaufruf auf die Abschnittszeile. Premium-Widgets nach Brand-UI-Kit v1.6: - hero Version 2: photo_split/editorial_solid, Höhen compact/normal/ large, Label, Überschriftenebene, Akzent, Bildfokus in Prozent, zwei Schaltflächen; nur 3 oder 4 Einheiten. Upgrade aus Version 1. - image_text Version 3: Fläche cream/clear/navy, Höhen compact/normal/ spacious, Label, zwei Schaltflächen, Bildfokus; 1 bis 4 Einheiten. Upgrade aus Version 2 (format entfällt, Fokus in Prozent). - Kit-CSS ersetzt das bisherige Hero- und Bild-und-Text-CSS; der Randlos-Mechanismus der Designiteration 1 entfällt. Editor: Reiter Inhalt/Medien/Darstellung aus der Registry, Auswahl- knöpfe mit Symbolen, Schieberegler für den Bildfokus und eine Live- Vorschau im Dialog mit demselben Renderer in wählbarer Platzbreite. Tests bewusst angepasst: Einstieg braucht jetzt 3 oder 4 Einheiten (vorher Mindestbreite 2), image_text ist Version 3, Klassen der neuen Ansichten; die Hero-/Bild-Tests der Designiteration 1 sind durch CmsPremiumWidgetsTest ersetzt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3cdb36e7a3
commit
0bfb53463a
38 files changed
+1755
-856
No files matched your search
@@ -14,6 +14,8 @@
|
||||
use App\Models\User;
|
||||
use Filament\Actions\Testing\TestAction;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\Slider;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -49,7 +51,7 @@ public function test_editor_creates_a_page_with_sections_and_registered_widgets_
|
||||
'seo_title' => 'Themenseite',
|
||||
'sections' => [
|
||||
$this->sectionState('u4', [
|
||||
['type' => 'hero', 'data' => ['variant' => 'highlight', 'data' => ['heading' => 'Stark im Alltag', 'text' => 'Einstieg']]],
|
||||
['type' => 'hero', 'data' => ['variant' => 'editorial_solid', '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']])]]],
|
||||
@@ -76,8 +78,8 @@ public function test_editor_creates_a_page_with_sections_and_registered_widgets_
|
||||
$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->assertSame(['editorial_solid', 'compact', 'image_right', 'standard'], array_column($blocks, 'variant'));
|
||||
$this->assertSame(3, $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']);
|
||||
@@ -164,7 +166,7 @@ public function test_publishing_with_an_invalid_draft_publishes_nothing(): void
|
||||
$component->set("data.sections.$sectionKey.layout", 'u1_3');
|
||||
$slotKeys = array_keys($component->get("data.sections.$sectionKey.slots"));
|
||||
$component->set("data.sections.$sectionKey.slots.{$slotKeys[0]}.widget", [
|
||||
(string) Str::uuid() => ['type' => 'hero', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Zu schmal']]],
|
||||
(string) Str::uuid() => ['type' => 'hero', 'data' => ['variant' => 'photo_split', 'data' => ['heading' => 'Zu schmal']]],
|
||||
]);
|
||||
|
||||
$component->callAction('publish')->assertNotified('Nicht gespeichert');
|
||||
@@ -231,7 +233,7 @@ public function test_widget_too_wide_for_its_slot_is_reported_at_the_section():
|
||||
'path' => '/raster-pruefung',
|
||||
'sections' => [
|
||||
$this->sectionState('u1_3', [
|
||||
['type' => 'hero', 'data' => ['variant' => 'standard', 'data' => ['heading' => 'Zu schmal']]],
|
||||
['type' => 'hero', 'data' => ['variant' => 'photo_split', 'data' => ['heading' => 'Zu schmal']]],
|
||||
null,
|
||||
], ['background' => 'accent', 'spacing' => 'large', 'divider' => 'line']),
|
||||
],
|
||||
@@ -275,7 +277,7 @@ public function test_errors_found_only_by_the_registry_are_announced_with_the_se
|
||||
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||
$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']]],
|
||||
['type' => 'hero', 'data' => ['variant' => 'photo_split', 'data' => ['heading' => 'Mit Bild'], 'refs' => ['image' => 'cms/bild.jpg']]],
|
||||
]);
|
||||
|
||||
$component->set('data.sections', $state)
|
||||
@@ -392,8 +394,8 @@ public function test_block_preview_uses_the_public_widget_view_with_unsaved_stat
|
||||
'refs' => ['image' => null, '_upload' => []],
|
||||
]);
|
||||
|
||||
$this->assertStringContainsString('image-text image-text-right', $html);
|
||||
$this->assertStringContainsString('<h2>Ungespeichert</h2>', $html);
|
||||
$this->assertStringContainsString('lf-bt lf-bt--cream lf-bt--image-right', $html);
|
||||
$this->assertStringContainsString('<h2 class="lf-bt__headline">Ungespeichert</h2>', $html);
|
||||
$this->assertStringContainsString('Vorschautext', $html);
|
||||
|
||||
$cards = WidgetEditor::renderPreview('cards', [
|
||||
@@ -415,7 +417,7 @@ public function test_editor_offers_every_registered_widget_layouts_and_section_d
|
||||
->assertSee('Einstieg (Hero)')
|
||||
->assertSee('Programm- und Modulkarten')
|
||||
->assertSee('Titel und Beschreibung kommen automatisch aus den Fachdaten')
|
||||
->assertSee('Braucht einen Platz ab 2 Rastereinheiten')
|
||||
->assertSee('Für Plätze mit 3 oder 4 Rastereinheiten')
|
||||
->assertSee('Gestaltung des Abschnitts')
|
||||
->assertSee('1 + 2 + 1')
|
||||
->assertSee('Widget einsetzen')
|
||||
@@ -487,42 +489,89 @@ public function test_navigation_rejects_script_addresses(): void
|
||||
$this->get('/praevention')->assertDontSee('javascript:alert(1)', false);
|
||||
}
|
||||
|
||||
public function test_editor_saves_brand_stage_with_settings_and_second_action(): void
|
||||
/**
|
||||
* Premium-Einstieg (Kit v1.6) über den Editor: Variante, Höhe, Überschriftenebene, Akzent, Label, Fokus und zwei
|
||||
* Schaltflächen werden gespeichert und öffentlich mit derselben Ansicht dargestellt.
|
||||
*/
|
||||
public function test_editor_saves_premium_hero_with_layout_settings(): void
|
||||
{
|
||||
Storage::fake('media_public');
|
||||
Storage::fake('cms_incoming');
|
||||
Storage::disk('media_public')->put('cms/buehne.jpg', 'bild');
|
||||
Storage::disk('media_public')->put('cms/park.jpg', 'bild');
|
||||
|
||||
Livewire::actingAs($this->editor(), 'staff')
|
||||
->test(CreatePage::class)
|
||||
->fillForm([
|
||||
'path' => '/markenbuehne',
|
||||
'path' => '/premium-einstieg',
|
||||
'sections' => [
|
||||
$this->sectionState('u4', [
|
||||
$this->sectionState('u3_1', [
|
||||
['type' => 'hero', 'data' => [
|
||||
'variant' => 'stage',
|
||||
'settings' => ['focus' => 'left', 'text_side' => 'left'],
|
||||
'data' => ['heading' => 'Bühne', 'cta_label' => 'Programme', 'cta_url' => '/programme', 'cta2_label' => 'Mitgliederbereich', 'cta2_url' => '/bereich', 'alt' => 'Motiv'],
|
||||
'refs' => ['image' => 'cms/buehne.jpg'],
|
||||
'variant' => 'photo_split',
|
||||
'settings' => ['height' => 'large', 'heading_level' => 'h3', 'accent' => 'rays'],
|
||||
'data' => ['eyebrow' => 'Stark im Alltag', 'heading' => 'Kinder stark im Alltag', 'text' => 'Beschreibung', 'cta_label' => 'Programme', 'cta_url' => '/programme', 'cta2_label' => 'Mitgliederbereich', 'cta2_url' => '/bereich', 'alt' => 'Lara und Felix', 'focus_x' => 72, 'focus_y' => 40],
|
||||
'refs' => ['image' => 'cms/park.jpg'],
|
||||
]],
|
||||
], ['width' => 'full']),
|
||||
['type' => 'call_to_action', 'data' => ['settings' => ['height' => 'fill'], 'data' => ['heading' => 'Daneben', 'label' => 'Los', 'url' => '/bereich']]],
|
||||
], ['width' => 'wide']),
|
||||
],
|
||||
])
|
||||
->call('create')
|
||||
->assertHasNoFormErrors();
|
||||
|
||||
$page = Page::query()->where('path', '/markenbuehne')->firstOrFail();
|
||||
$widget = $page->latestRevision->sections[0]['slots'][0];
|
||||
$this->assertSame('stage', $widget['variant']);
|
||||
$this->assertSame(['focus' => 'left', 'text_side' => 'left'], $widget['settings']);
|
||||
$this->assertSame('/bereich', $widget['data']['cta2_url']);
|
||||
$page = Page::query()->where('path', '/premium-einstieg')->firstOrFail();
|
||||
$hero = $page->latestRevision->sections[0]['slots'][0];
|
||||
$this->assertSame(2, $hero['v']);
|
||||
$this->assertSame('photo_split', $hero['variant']);
|
||||
$this->assertSame(['height' => 'large', 'heading_level' => 'h3', 'accent' => 'rays'], $hero['settings']);
|
||||
$this->assertSame([72, 40], [$hero['data']['focus_x'], $hero['data']['focus_y']]);
|
||||
$this->assertSame('fill', $page->latestRevision->sections[0]['slots'][1]['settings']['height']);
|
||||
|
||||
app(PageService::class)->publish($page, $page->latestRevision);
|
||||
$this->get('/markenbuehne')
|
||||
$this->get('/premium-einstieg')
|
||||
->assertOk()
|
||||
->assertSee('section-bleed', false)
|
||||
->assertSee('hero hero-stage hero-with-image hero-text-left', false)
|
||||
->assertSee('<a class="button button-secondary" href="/bereich">Mitgliederbereich</a>', false);
|
||||
->assertSee('lf-hero lf-hero--photo-split lf-hero--height-large lf-hero--accent-rays', false)
|
||||
->assertSee('--lf-hero-focus-x: 72%; --lf-hero-focus-y: 40%', false)
|
||||
->assertSee('<h1 class="lf-hero__title">Kinder stark im Alltag</h1>', false)
|
||||
->assertSee('<p class="lf-hero__eyebrow">Stark im Alltag</p>', false)
|
||||
->assertSee('<a class="lf-hero__button lf-hero__button--secondary" href="/bereich">Mitgliederbereich</a>', false)
|
||||
->assertSee('widget-call-to-action widget-variant-standard widget-height-fill', false);
|
||||
}
|
||||
|
||||
public function test_widget_dialog_groups_content_media_and_display_with_live_preview(): void
|
||||
{
|
||||
$page = Page::query()->where('path', '/')->firstOrFail();
|
||||
$component = Livewire::actingAs($this->editor(), 'staff')->test(EditPage::class, ['record' => $page->id]);
|
||||
$state = $component->get('data.sections');
|
||||
$state[(string) Str::uuid()] = $this->sectionState('u4', [
|
||||
['type' => 'image_text', 'data' => ['variant' => 'image_left', 'settings' => ['height' => 'spacious', 'surface' => 'navy'], 'data' => ['title' => 'Vorschau im Dialog', 'body' => '<p>Text</p>'], 'refs' => []]],
|
||||
]);
|
||||
$component->set('data.sections', $state);
|
||||
|
||||
$sectionKey = array_key_last($component->get('data.sections'));
|
||||
$slotKey = array_key_first($component->get("data.sections.$sectionKey.slots"));
|
||||
$itemKey = array_key_first($component->get("data.sections.$sectionKey.slots.$slotKey.widget"));
|
||||
|
||||
// Modalinhalte rendert Livewire im Test nicht als HTML; geprüft werden die Felder des geöffneten Dialogs.
|
||||
$component->mountAction(TestAction::make('edit')->schemaComponent("sections.$sectionKey.slots.$slotKey.widget")->arguments(['item' => $itemKey]))
|
||||
->assertFormFieldExists('variant', fn ($field) => $field instanceof ToggleButtons && array_keys($field->getOptions()) === ['image_left', 'image_right'])
|
||||
->assertFormFieldExists('settings.height', fn ($field) => $field instanceof ToggleButtons && array_keys($field->getOptions()) === ['compact', 'normal', 'spacious'])
|
||||
->assertFormFieldExists('settings.surface')
|
||||
->assertFormFieldExists('settings.heading_level')
|
||||
->assertFormFieldExists('data.eyebrow')
|
||||
->assertFormFieldExists('data.cta2_url')
|
||||
->assertFormFieldExists('refs.image')
|
||||
->assertFormFieldExists('data.focus_x', fn ($field) => $field instanceof Slider)
|
||||
->assertFormFieldExists('data.focus_y', fn ($field) => $field instanceof Slider)
|
||||
->assertFormFieldExists('_preview_width', fn ($field) => array_keys($field->getOptions()) === [390, 310, 640, 960, 1300]);
|
||||
|
||||
// Die Live-Vorschau des Dialogs rendert den ungespeicherten Zustand mit der öffentlichen Ansicht.
|
||||
$html = view('filament.cms.widget-live-preview', [
|
||||
'html' => WidgetEditor::renderPreview('image_text', $component->get("data.sections.$sectionKey.slots.$slotKey.widget.$itemKey.data")),
|
||||
'stylesheets' => '',
|
||||
'width' => 1300,
|
||||
])->render();
|
||||
$this->assertStringContainsString('Vorschau bei 1300 px Platzbreite', $html);
|
||||
$this->assertStringContainsString('lf-bt lf-bt--navy lf-bt--image-left lf-bt--height-spacious', htmlspecialchars_decode($html));
|
||||
}
|
||||
|
||||
private function editor(): User
|
||||
|
||||
Reference in new issue
Block a user