TreeEditor (position/insert/move/remove/duplicate on the BlockTree) and Warnings (post-write quality checks), plus S18's outline breadth limit on the 2a Outline/DiviOutlineAbility. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
56 lines
2.4 KiB
PHP
56 lines
2.4 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Compose;
|
||
|
||
use LIT\MCP\Integrations\Divi\BlockTree\Document;
|
||
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
|
||
use LIT\MCP\Integrations\Divi\Compose\Warnings;
|
||
use LIT\MCP\Tests\Unit\Integrations\Divi\Design\DesignSystemTest;
|
||
use PHPUnit\Framework\TestCase;
|
||
|
||
final class WarningsTest extends TestCase
|
||
{
|
||
public function testWarnsAboutTheTouchedNodesOnly(): void
|
||
{
|
||
$composed = ComposeFixture::composer()->compose([
|
||
['type' => 'section', 'label' => 'Test', 'modules' => [
|
||
['type' => 'heading', 'text' => 'Titel', 'level' => 'h1'],
|
||
['type' => 'heading', 'text' => 'Zu tief', 'level' => 'h4'],
|
||
['type' => 'image', 'src' => 'https://kunde.test/a.jpg'],
|
||
['type' => 'text', 'content' => ''],
|
||
['type' => 'code', 'content' => '<div>x</div>'],
|
||
['type' => 'accordion'],
|
||
['type' => 'button', 'text' => 'Los', 'attrs' => [
|
||
'button.decoration.background' => ['desktop' => ['color' => '#2ea3f3']],
|
||
'button.decoration.font.font' => ['desktop' => ['family' => 'Open Sans', 'color' => '#abcdef']],
|
||
]],
|
||
]],
|
||
], null, 'nodes');
|
||
self::assertSame([], $composed['errors']);
|
||
$document = new Document();
|
||
foreach ($composed['blocks'] as $block) {
|
||
$document->append($block);
|
||
}
|
||
|
||
$warnings = (new Warnings(DesignSystemTest::sample()))->collect(NodeIndex::build($document), $composed['blocks']);
|
||
|
||
self::assertSame(
|
||
[
|
||
's0.r0.c0.m2: Bild ohne Alt-Text.',
|
||
's0.r0.c0.m3: text ist leer (content fehlt).',
|
||
's0.r0.c0.m4: Code-Modul verwendet – im Divi-Builder nicht visuell bearbeitbar; nur nutzen, wenn kein '
|
||
. 'natives Modul passt.',
|
||
's0.r0.c0.m5: accordion ohne Einträge.',
|
||
's0.r0.c0.m6: feste Farbe #2ea3f3 – globale Farbe "Primärfarbe" ({{color:primary}}) passt.',
|
||
's0.r0.c0.m6: feste Schrift Open Sans – {{font:heading}} verwenden.',
|
||
's0.r0.c0.m1: Sprung in der Überschriftenhierarchie (h4 nach h1).',
|
||
],
|
||
$warnings
|
||
);
|
||
|
||
self::assertSame([], (new Warnings(DesignSystemTest::sample()))->collect(NodeIndex::build($document), []));
|
||
}
|
||
}
|