Farbfeld im Abschnittskopf und die eingestellte Fläche (Markenfläche, Palettenfarbe, Hintergrundbild) als Rahmen hinter den Plätzen. Reine Anzeige im Editor; Speicherformat und Ausgabe bleiben unverändert. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
99 lines
4.4 KiB
PHP
99 lines
4.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Domain\Cms\Page;
|
|
use App\Domain\Cms\PageService;
|
|
use App\Domain\Design\DesignPalette;
|
|
use App\Filament\Resources\Pages\Pages\EditPage;
|
|
use App\Filament\Support\SectionSurface;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Livewire\Features\SupportTesting\Testable;
|
|
use Livewire\Livewire;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Hintergrund des Abschnitts in der Seitenübersicht (Seitenaufbau im Editor): Die eingestellte Fläche steht hinter den
|
|
* Plätzen und als Farbfeld im Abschnittskopf. Abschnitte ohne eigene Fläche bleiben unverändert.
|
|
*/
|
|
class CmsSectionSurfaceTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
DesignPalette::flush();
|
|
parent::tearDown();
|
|
}
|
|
|
|
/**
|
|
* @param list<array<string, mixed>> $styles
|
|
*/
|
|
private function editor(array $styles): Testable
|
|
{
|
|
$user = User::factory()->redakteur()->create();
|
|
$user->saveAppAuthenticationSecret('JBSWY3DPEHPK3PXP');
|
|
$page = Page::query()->create(['path' => '/flaechen']);
|
|
$sections = array_map(fn (array $style): array => [
|
|
'layout' => 'u4',
|
|
'style' => $style,
|
|
'slots' => [['type' => 'cards', 'v' => 2, 'variant' => 'standard', 'settings' => ['link_style' => 'text'], 'data' => ['items' => [['title' => 'Eins', 'url' => '/a']]]]],
|
|
], $styles);
|
|
app(PageService::class)->saveRevision($page, $sections, null, null, null);
|
|
|
|
return Livewire::actingAs($user, 'staff')->test(EditPage::class, ['record' => $page->id]);
|
|
}
|
|
|
|
public function test_the_brand_surfaces_are_described_with_their_colours(): void
|
|
{
|
|
$dark = SectionSurface::of(['background' => 'dark']);
|
|
$this->assertSame(['brand', '#032551', true], [$dark['kind'], $dark['bg'], $dark['dark']]);
|
|
|
|
$light = SectionSurface::of(['background' => 'light']);
|
|
$this->assertSame(['brand', '#f7f6f2', false], [$light['kind'], $light['bg'], $light['dark']]);
|
|
|
|
$this->assertSame('', SectionSurface::css([]), 'Ohne eigene Fläche gibt es keine Eigenschaften.');
|
|
$this->assertSame('', SectionSurface::swatch(['background' => 'default']));
|
|
$this->assertSame('--luf-fl-bg: #3b7b09', SectionSurface::css(['background' => 'accent']));
|
|
}
|
|
|
|
public function test_a_palette_colour_and_a_missing_palette_colour(): void
|
|
{
|
|
$this->assertSame([], DesignPalette::save(null, 'Sand', '#f3e9d2', '#15243a'));
|
|
$id = DesignPalette::slots()[0]['id'];
|
|
|
|
$surface = SectionSurface::of(['background' => 'palette', 'palette_slot' => $id]);
|
|
$this->assertSame(['palette', 'Sand', '#f3e9d2'], [$surface['kind'], $surface['label'], $surface['bg']]);
|
|
$this->assertStringContainsString('--luf-fl-bg: #f3e9d2', SectionSurface::css(['background' => 'palette', 'palette_slot' => $id]));
|
|
|
|
// Wie auf der Website: eine Farbe, die es nicht mehr gibt, erscheint als Abschnitt ohne eigene Fläche.
|
|
$this->assertSame('', SectionSurface::css(['background' => 'palette', 'palette_slot' => 'c99']));
|
|
}
|
|
|
|
public function test_an_image_without_a_usable_address_gets_a_neutral_surface_and_never_leaks_markup(): void
|
|
{
|
|
$this->assertSame('--luf-fl-bg: #d9dee5', SectionSurface::css(['background' => 'image']));
|
|
$this->assertStringContainsString('Hintergrundbild', SectionSurface::swatch(['background' => 'image']));
|
|
}
|
|
|
|
public function test_the_editor_shows_the_surface_behind_the_slots_and_in_the_header(): void
|
|
{
|
|
$this->assertSame([], DesignPalette::save(null, 'Sand', '#f3e9d2', '#15243a'));
|
|
$component = $this->editor([
|
|
[],
|
|
['background' => 'dark'],
|
|
['background' => 'palette', 'palette_slot' => DesignPalette::slots()[0]['id']],
|
|
]);
|
|
|
|
$html = $component->html();
|
|
|
|
$this->assertSame(2, substr_count($html, 'luf-slots luf-flaeche'), 'Nur die beiden Abschnitte mit eigener Fläche erhalten den Rahmen.');
|
|
$this->assertStringContainsString('--luf-fl-bg: #032551', $html);
|
|
$this->assertStringContainsString('--luf-fl-bg: #f3e9d2', $html);
|
|
$this->assertSame(2, substr_count($html, 'luf-abschnitt-flaeche" aria-hidden'), 'Je Abschnitt mit Fläche ein Farbfeld im Kopf.');
|
|
$this->assertStringContainsString('Hintergrund: Dunkle Markenfläche', $html);
|
|
$this->assertStringContainsString('Hintergrund: Sand', $html);
|
|
}
|
|
}
|