feat: Outline und Knoten zeigen Gruppen-Presets mit Namen
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 5.5
parent
ca3bbf5ad1
commit
c3f08e2d33
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\BlockTree;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\Block;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\NodeSummary;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class NodeSummaryTest extends TestCase
|
||||
{
|
||||
public function testGroupPresetsByGroupId(): void
|
||||
{
|
||||
$block = Block::create('divi/blurb', ['groupPreset' => [
|
||||
'content.decoration.bodyFont' => ['presetId' => ['ja6o54jtlc'], 'groupName' => 'divi/font-body'],
|
||||
'module.decoration.spacing' => ['presetId' => ['apzj7e17ok', 'b2b2b2b2b2'], 'groupName' => 'divi/spacing'],
|
||||
]]);
|
||||
|
||||
self::assertSame(
|
||||
[
|
||||
'content.decoration.bodyFont' => ['groupName' => 'divi/font-body', 'presetIds' => ['ja6o54jtlc']],
|
||||
'module.decoration.spacing' => [
|
||||
'groupName' => 'divi/spacing',
|
||||
'presetIds' => ['apzj7e17ok', 'b2b2b2b2b2'],
|
||||
],
|
||||
],
|
||||
NodeSummary::groupPresets($block)
|
||||
);
|
||||
}
|
||||
|
||||
public function testPresetIdAsStringIsAccepted(): void
|
||||
{
|
||||
$block = Block::create('divi/text', ['groupPreset' => [
|
||||
'content.decoration.bodyFont' => ['presetId' => 'ja6o54jtlc', 'groupName' => 'divi/font-body'],
|
||||
]]);
|
||||
|
||||
self::assertSame(
|
||||
['content.decoration.bodyFont' => ['groupName' => 'divi/font-body', 'presetIds' => ['ja6o54jtlc']]],
|
||||
NodeSummary::groupPresets($block)
|
||||
);
|
||||
}
|
||||
|
||||
public function testEmptyIdsAreFilteredAndBrokenEntriesLeftOut(): void
|
||||
{
|
||||
$block = Block::create('divi/text', ['groupPreset' => [
|
||||
'a.one' => ['presetId' => ['', 'x1', 7, null], 'groupName' => 'divi/font'],
|
||||
'a.two' => ['presetId' => [''], 'groupName' => 'divi/font'],
|
||||
'a.three' => ['presetId' => ['x2']],
|
||||
'a.four' => ['presetId' => ['x3'], 'groupName' => ''],
|
||||
'a.five' => ['presetId' => ['x4'], 'groupName' => ['divi/font']],
|
||||
'a.six' => 'kein Eintrag',
|
||||
]]);
|
||||
|
||||
self::assertSame(
|
||||
['a.one' => ['groupName' => 'divi/font', 'presetIds' => ['x1']]],
|
||||
NodeSummary::groupPresets($block)
|
||||
);
|
||||
}
|
||||
|
||||
public function testBlockWithoutOrWithBrokenGroupPreset(): void
|
||||
{
|
||||
self::assertSame([], NodeSummary::groupPresets(Block::create('divi/text')));
|
||||
self::assertSame([], NodeSummary::groupPresets(Block::create('divi/text', ['groupPreset' => 'x'])));
|
||||
self::assertSame([], NodeSummary::groupPresets(Block::create('divi/text', ['groupPreset' => []])));
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user