Füge die zentrale Farbpalette und die Hintergrundbreite für Abschnitte hinzu (ADR-67)
- DesignPalette: bis zu zehn benannte Farben (Hintergrund und Schrift) in site_settings, stabile Kennungen, Kontrastprüfung 4,5:1 auf dem Server, Verwendungssuche - Seite Website → Design → Farben (Systemverwalter): Kacheln, Dialog mit Live-Vorschau, Kontrastwarnung mit Empfehlung, Bestätigung mit betroffenen Seiten, Entfernen gesperrt bei Verwendung - Hintergrund „Farbe aus der Palette“ als Verweis im bestehenden Feld background; farbige Kacheln im Editor - Renderer leitet Bedeutungswerte aus Hintergrund und Schrift ab; scope-dark bei heller Schrift - Hintergrundbreite: volle Browserbreite (Vorgabe) oder auf Abschnittsbreite begrenzt - Test sichert die Ausgabe aller bisherigen Varianten byte-gleich; Abnahme mit Screenshots Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
62f3a33541
commit
87de5a62d4
41 files changed
+2372
-14
No files matched your search
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Jobs\PublishPublicMedia;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Schutz bestehender Seiten (ADR-67): Die Ausgabe aller bisherigen Gestaltungsvarianten (Flächen, Bilder mit Überlagerung
|
||||
* und Fokus, Breiten, Abstände, Trenner, Kartenoptionen) bleibt Byte für Byte gleich. Die Farbpalette und die
|
||||
* Hintergrundbreite dürfen daran nichts ändern, solange ein Abschnitt sie nicht ausdrücklich verwendet.
|
||||
*
|
||||
* Die Vorlage tests/Fixtures/section-legacy-render.html wurde vor der Erweiterung aus dem damaligen Stand erzeugt.
|
||||
* Neu erzeugen nur bewusst und mit Begründung: UPDATE_SNAPSHOT=1 php artisan test --filter=CmsSectionLegacyRenderTest
|
||||
*/
|
||||
class CmsSectionLegacyRenderTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private const FIXTURE = __DIR__.'/../Fixtures/section-legacy-render.html';
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function prose(string $text): array
|
||||
{
|
||||
return ['type' => 'prose', 'v' => 1, 'data' => ['body' => $text]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
private function heading(string $text): array
|
||||
{
|
||||
return ['type' => 'heading', 'v' => 1, 'data' => ['heading' => $text]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<array<string, mixed>>
|
||||
*/
|
||||
private function matrix(): array
|
||||
{
|
||||
$sections = [];
|
||||
|
||||
foreach (['default' => ['narrow', 'standard', 'wide', 'full'], 'light' => ['wide'], 'dark' => ['narrow', 'standard', 'wide', 'full'], 'accent' => ['wide']] as $background => $widths) {
|
||||
foreach ($widths as $width) {
|
||||
$sections[] = [
|
||||
'layout' => 'u2_2',
|
||||
'style' => ['background' => $background, 'width' => $width],
|
||||
'slots' => [$this->heading("$background $width"), $this->prose("Text $background $width")],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
foreach (['light', 'dark', 'none'] as $overlay) {
|
||||
foreach (['center', 'top_left'] as $focus) {
|
||||
$sections[] = [
|
||||
'layout' => 'u4',
|
||||
'style' => ['background' => 'image', 'image' => 'cms/flaeche.jpg', 'focus' => $focus, 'overlay' => $overlay],
|
||||
'slots' => [$this->prose("Bild $overlay $focus")],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
foreach (['none', 'compact', 'normal', 'large'] as $spacing) {
|
||||
$sections[] = [
|
||||
'layout' => 'u1_3',
|
||||
'style' => ['background' => 'light', 'spacing_top' => $spacing, 'spacing_bottom' => $spacing, 'gap' => $spacing, 'divider' => 'line'],
|
||||
'slots' => [$this->prose("Abstand $spacing"), $this->prose('Rechts')],
|
||||
];
|
||||
}
|
||||
|
||||
$sections[] = ['layout' => 'u4', 'style' => ['background' => 'dark', 'divider' => 'accent'], 'slots' => [$this->heading('Trenner Akzent')]];
|
||||
$sections[] = ['layout' => 'u4', 'style' => ['cards_height' => 'equal', 'cards_links' => 'bottom'], 'slots' => [$this->prose('Karten gleich hoch')]];
|
||||
$sections[] = ['layout' => 'u1_1_1_1', 'style' => ['background' => 'accent'], 'slots' => [$this->prose('Eins'), null, $this->prose('Drei'), null]];
|
||||
|
||||
return $sections;
|
||||
}
|
||||
|
||||
/**
|
||||
* Zufällige Kennungen (Abschnitt, Widget) werden für den Vergleich vereinheitlicht.
|
||||
*/
|
||||
private function sectionsMarkup(string $html): string
|
||||
{
|
||||
$start = strpos($html, '<div class="page-section ');
|
||||
$end = strpos($html, '</main>');
|
||||
$markup = substr($html, $start, $end - $start);
|
||||
$markup = (string) preg_replace('/\b(id|aria-labelledby|aria-describedby|for)="([^"]*[0-9a-f]{8}-[0-9a-f]{4}-[^"]*)"/', '$1="#"', $markup);
|
||||
$markup = (string) preg_replace('/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/', 'UUID', $markup);
|
||||
|
||||
return trim($markup)."\n";
|
||||
}
|
||||
|
||||
public function test_existing_section_styles_render_exactly_as_before(): void
|
||||
{
|
||||
Queue::fake([PublishPublicMedia::class]);
|
||||
|
||||
$service = app(PageService::class);
|
||||
$page = Page::query()->create(['path' => '/legacy']);
|
||||
$service->publish($page, $service->saveRevision($page, $this->matrix(), null, null, null));
|
||||
|
||||
$markup = $this->sectionsMarkup($this->get('/legacy')->assertOk()->getContent());
|
||||
|
||||
if (getenv('UPDATE_SNAPSHOT') === '1') {
|
||||
file_put_contents(self::FIXTURE, $markup);
|
||||
}
|
||||
|
||||
$this->assertFileExists(self::FIXTURE);
|
||||
$this->assertSame(file_get_contents(self::FIXTURE), $markup, 'Die Ausgabe bestehender Abschnittsvarianten hat sich geändert.');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user