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
@@ -66,18 +66,56 @@ public function test_registration_rejects_keys_that_are_not_stable_identifiers()
|
||||
new WidgetRegistry([$this->customWidget('Teaser Box')]);
|
||||
}
|
||||
|
||||
public function test_every_widget_declares_a_minimum_width_within_four_units(): void
|
||||
/** Gemeinsamer Layoutvertrag (ADR-38) für jede registrierte Art. */
|
||||
public function test_every_widget_declares_the_shared_layout_contract(): void
|
||||
{
|
||||
foreach ($this->registry()->all() as $key => $type) {
|
||||
$this->assertGreaterThanOrEqual(1, $type->minUnits(), $key);
|
||||
$this->assertLessThanOrEqual($type->preferredUnits(), $type->minUnits(), $key);
|
||||
$this->assertLessThanOrEqual(4, $type->preferredUnits(), $key);
|
||||
$units = $type->supportedUnits();
|
||||
$this->assertNotEmpty($units, $key);
|
||||
$this->assertSame([], array_diff($units, [1, 2, 3, 4]), $key);
|
||||
$this->assertSame(min($units), $type->minUnits(), $key);
|
||||
$this->assertTrue($type->supportsUnits($type->preferredUnits()), $key);
|
||||
$this->assertNotEmpty($type->stages(), $key);
|
||||
$this->assertNotSame('', $type->narrowBehavior(), $key);
|
||||
$this->assertSame([], array_diff(array_keys($type->heights()), array_keys(WidgetType::HEIGHTS)), $key);
|
||||
|
||||
if ($type->heights() !== []) {
|
||||
$this->assertArrayHasKey($type->defaultHeight(), $type->heights(), $key);
|
||||
$this->assertSame($type->heights(), $type->settingOptions()['height'], $key);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertSame(2, $this->registry()->get('hero')->minUnits());
|
||||
$this->assertSame(2, $this->registry()->get('image_text')->minUnits());
|
||||
$this->assertSame(1, $this->registry()->get('catalog_cards')->minUnits());
|
||||
$this->assertSame([3, 4], $this->registry()->get('hero')->supportedUnits());
|
||||
$this->assertSame(['compact', 'normal', 'large'], array_keys($this->registry()->get('hero')->heights()));
|
||||
$this->assertSame([1, 2, 3, 4], $this->registry()->get('image_text')->supportedUnits());
|
||||
$this->assertSame(['compact', 'normal', 'spacious'], array_keys($this->registry()->get('image_text')->heights()));
|
||||
$this->assertSame(['auto', 'fill'], array_keys($this->registry()->get('call_to_action')->heights()));
|
||||
$this->assertSame([2, 3, 4], $this->registry()->get('faq')->supportedUnits());
|
||||
$this->assertSame('3 oder 4', $this->registry()->get('hero')->unitsLabel());
|
||||
$this->assertSame('1 bis 4', $this->registry()->get('cards')->unitsLabel());
|
||||
}
|
||||
|
||||
public function test_height_is_an_enumerated_setting_with_a_default(): void
|
||||
{
|
||||
$widget = $this->registry()->normalize([
|
||||
['type' => 'hero', 'v' => 2, 'settings' => ['height' => 'large'], 'data' => ['heading' => 'X']],
|
||||
])[0];
|
||||
$this->assertSame('large', $widget['settings']['height']);
|
||||
$this->assertSame('normal', $this->registry()->get('hero')->height(['settings' => []]));
|
||||
|
||||
try {
|
||||
$this->registry()->normalize([['type' => 'hero', 'v' => 2, 'settings' => ['height' => '900px'], 'data' => ['heading' => 'X']]]);
|
||||
$this->fail('Freie Höhe wurde angenommen.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertArrayHasKey('blocks.0.settings.height', $exception->errors());
|
||||
}
|
||||
|
||||
try {
|
||||
$this->registry()->normalize([['type' => 'prose', 'v' => 1, 'settings' => ['height' => 'compact'], 'data' => ['body' => 'Text']]]);
|
||||
$this->fail('Höhe für eine Art ohne Höhenwahl wurde angenommen.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertArrayHasKey('blocks.0.settings.height', $exception->errors());
|
||||
}
|
||||
}
|
||||
|
||||
public function test_a_new_widget_type_works_through_the_contract_alone(): void
|
||||
@@ -112,7 +150,7 @@ public function test_unknown_type_and_unregistered_variant_are_rejected(): void
|
||||
}
|
||||
|
||||
try {
|
||||
$this->registry()->normalize([['type' => 'hero', 'v' => 1, 'variant' => 'gross-und-bunt', 'data' => ['heading' => 'X']]]);
|
||||
$this->registry()->normalize([['type' => 'hero', 'v' => 2, 'variant' => 'gross-und-bunt', 'data' => ['heading' => 'X']]]);
|
||||
$this->fail('Unbekannte Variante wurde angenommen.');
|
||||
} catch (ValidationException $exception) {
|
||||
$this->assertArrayHasKey('blocks.0.variant', $exception->errors());
|
||||
@@ -204,13 +242,13 @@ public function test_legacy_blocks_are_read_as_version_one_envelopes(): void
|
||||
], $widget);
|
||||
}
|
||||
|
||||
public function test_legacy_image_text_is_upgraded_to_version_two_on_read(): void
|
||||
public function test_legacy_image_text_is_upgraded_to_the_current_version_on_read(): void
|
||||
{
|
||||
$legacy = ['type' => 'image_text', 'image' => 'cms/alt.jpg', 'alt' => 'Kinder im Kreis', 'body' => "Erster Absatz & mehr.\n\nZweiter <Absatz>."];
|
||||
|
||||
$widget = $this->registry()->upcast($legacy);
|
||||
|
||||
$this->assertSame(2, $widget['v']);
|
||||
$this->assertSame(3, $widget['v']);
|
||||
$this->assertSame('image_left', $widget['variant']);
|
||||
$this->assertSame(['image' => 'cms/alt.jpg'], $widget['refs']);
|
||||
$this->assertSame('Kinder im Kreis', $widget['data']['alt']);
|
||||
@@ -225,7 +263,7 @@ public function test_stored_version_one_envelope_is_upgraded_as_well(): void
|
||||
'data' => ['image' => null, 'alt' => 'x', 'body' => 'Nur Text'], 'refs' => [],
|
||||
]);
|
||||
|
||||
$this->assertSame(2, $widget['v']);
|
||||
$this->assertSame(3, $widget['v']);
|
||||
$this->assertSame('abc', $widget['id']);
|
||||
$this->assertSame('image_left', $widget['variant']);
|
||||
$this->assertSame('<p>Nur Text</p>', $widget['data']['body']);
|
||||
|
||||
Reference in new issue
Block a user