feat: Outline und Knoten zeigen Gruppen-Presets mit Namen

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
Jan-Niclas Loosen
2026-10-18 16:41:42 +02:00
co-authored by Claude Haiku 5.5
parent ca3bbf5ad1
commit c3f08e2d33
7 changed files with 308 additions and 21 deletions
@@ -6,6 +6,7 @@ namespace LIT\MCP\Tests\Unit\Integrations\Divi\BlockTree;
use LIT\MCP\Integrations\Divi\BlockTree\AttrMap;
use LIT\MCP\Integrations\Divi\BlockTree\Block;
use LIT\MCP\Integrations\Divi\BlockTree\Document;
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
use LIT\MCP\Integrations\Divi\BlockTree\NodeSummary;
use LIT\MCP\Integrations\Divi\BlockTree\Outline;
@@ -26,7 +27,8 @@ final class OutlineTest extends TestCase
self::assertSame(
['id' => 's0.r0.c1.m0', 'type' => 'heading', 'label' => '', 'excerpt' => 'Willkommen bei Müller & Söhne',
'info' => '', 'presets' => ['Hero-Titel'], 'children' => 0, 'editable' => true, 'depth' => 3,
'info' => '', 'presets' => ['Hero-Titel'], 'group_presets' => [], 'children' => 0,
'editable' => true, 'depth' => 3,
'truncated' => false, 'global_id' => null],
$rows[5]
);
@@ -41,6 +43,56 @@ final class OutlineTest extends TestCase
);
}
public function testGroupPresetsAreShownWithNamesInRowAndText(): void
{
$content = DiviFixtures::markup('stage4/page--designsystem.html');
$outline = new Outline([
'vdcl6msnuo' => '[Fixture] Blurb Leistung',
'ja6o54jtlc' => '[Fixture] Fließtext',
'apzj7e17ok' => '[Fixture] Abstand Karte',
]);
$rows = $outline->rows(NodeIndex::build((new Parser())->parse($content)));
$byId = array_column($rows, null, 'id');
self::assertSame([], $byId['s0.r0.c0.m1']['group_presets']);
self::assertSame(['font-body: [Fixture] Fließtext'], $byId['s0.r0.c0.m2']['group_presets']);
self::assertSame(['spacing: [Fixture] Abstand Karte'], $byId['s0.r0.c0.m5']['group_presets']);
self::assertSame(['[Fixture] Blurb Leistung'], $byId['s0.r0.c0.m5']['presets']);
$lines = explode("\n", $outline->text($rows));
self::assertStringContainsString(
's0.r0.c0.m2 text "Text mit Gruppen-Preset" {Gruppen-Presets: font-body: [Fixture] Fließtext} – ',
$lines[5]
);
self::assertStringContainsString(
's0.r0.c0.m5 blurb "Blurb mit Modul- und Gruppen-Preset" {Preset: [Fixture] Blurb Leistung} '
. '{Gruppen-Presets: spacing: [Fixture] Abstand Karte} – Möbel nach Maß',
$lines[8]
);
self::assertStringNotContainsString('Gruppen-Presets', $lines[3]);
}
public function testUnknownGroupPresetFallsBackToTheIdAndStacksAreListed(): void
{
$block = Block::create('divi/blurb', ['groupPreset' => [
'module.decoration.spacing' => ['presetId' => ['a1', 'b2'], 'groupName' => 'divi/spacing'],
'title.decoration.font' => ['presetId' => ['c3'], 'groupName' => 'divi/font'],
]]);
$document = new Document();
$document->append($block);
$index = NodeIndex::build($document);
$outline = new Outline(['a1' => 'Abstand Karte']);
$rows = $outline->rows($index);
self::assertSame(['spacing: Abstand Karte, b2', 'font: c3'], $rows[0]['group_presets']);
self::assertStringContainsString(
'{Gruppen-Presets: spacing: Abstand Karte, b2; font: c3}',
$outline->text($rows)
);
}
public function testGlobalInstancesShowTheirLibraryIdAndRootType(): void
{
$content = DiviFixtures::markup('stage3/page--globale-instanzen.html');