feat: lit-site-status, Admin-Tab und Admin-Hinweis zeigen Divi-Fähigkeiten mit Zustand, Quelle, Problemen und betroffenen Werkzeugen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
b92545a8fe
commit
2aef6e1154
@@ -8,6 +8,13 @@ use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Integrations\Core\EnvironmentComponent;
|
||||
use LIT\MCP\Integrations\Divi\DiviCompatibility;
|
||||
use LIT\MCP\Integrations\Divi\DiviEnvironmentComponent;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||||
use LIT\MCP\Integrations\Divi\Release\FeatureOverview;
|
||||
use LIT\MCP\Integrations\Divi\Release\ReleaseGate;
|
||||
use LIT\MCP\Integrations\Divi\Release\ReleaseState;
|
||||
use LIT\MCP\Integrations\Divi\Release\ReleaseStatus;
|
||||
use LIT\MCP\Tests\Support\FeatureFakeTool;
|
||||
use LIT\MCP\Tests\Support\MatrixFixtures;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
|
||||
@@ -61,8 +68,78 @@ final class DiviEnvironmentComponentTest extends TestCase
|
||||
))->describe();
|
||||
|
||||
self::assertSame(
|
||||
['id' => 'divi', 'active' => false, 'version' => null, 'problems' => [], 'release' => null],
|
||||
['id' => 'divi', 'active' => false, 'version' => null, 'problems' => [], 'release' => null,
|
||||
'features' => []],
|
||||
$described
|
||||
);
|
||||
}
|
||||
|
||||
public function testListsEveryFeatureWithStateSourceProblemsAndTools(): void
|
||||
{
|
||||
$this->theme('Divi', '5.3.0');
|
||||
$matrix = MatrixFixtures::with(
|
||||
DiviFeature::PageWrite,
|
||||
ReleaseState::Incompatible,
|
||||
'auto',
|
||||
'Seiten: Signatur von et_pb_x() geändert'
|
||||
);
|
||||
ReleaseGate::useResolver(static fn (): ReleaseStatus => new ReleaseStatus(
|
||||
ReleaseState::Incompatible,
|
||||
'5.3.0',
|
||||
null,
|
||||
[],
|
||||
null,
|
||||
matrix: $matrix
|
||||
));
|
||||
$overview = new FeatureOverview(static fn (): array => [
|
||||
new FeatureFakeTool('lit/divi-outline', true, [DiviFeature::PageRead]),
|
||||
new FeatureFakeTool('lit/divi-insert', true, [DiviFeature::PageRead, DiviFeature::PageWrite]),
|
||||
]);
|
||||
|
||||
$component = (new DiviEnvironmentComponent(new DiviCompatibility([]), $overview))->describe();
|
||||
$features = array_column($component['features'], null, 'id');
|
||||
|
||||
self::assertSame('divi', $component['id']);
|
||||
self::assertCount(count(DiviFeature::cases()), $features);
|
||||
self::assertSame('incompatible', $features['page-write']['state']);
|
||||
self::assertNull($features['page-write']['source']);
|
||||
self::assertSame(['Seiten: Signatur von et_pb_x() geändert'], $features['page-write']['problems']);
|
||||
self::assertSame(['lit-divi-insert'], $features['page-write']['tools']);
|
||||
self::assertSame('Seiten schreiben', $features['page-write']['label']);
|
||||
self::assertSame('released', $features['page-read']['state']);
|
||||
self::assertSame('auto', $features['page-read']['source']);
|
||||
self::assertSame(['lit-divi-outline', 'lit-divi-insert'], $features['page-read']['tools']);
|
||||
self::assertSame('incompatible', $component['release']['state']);
|
||||
}
|
||||
|
||||
public function testTheMatrixComesFromTheGateAndIsNotComputedAgain(): void
|
||||
{
|
||||
$this->theme('Divi', '5.3.0');
|
||||
$calls = 0;
|
||||
ReleaseGate::useResolver(static function () use (&$calls): ReleaseStatus {
|
||||
++$calls;
|
||||
|
||||
return ReleaseStatus::released('5.3.0');
|
||||
});
|
||||
$component = new DiviEnvironmentComponent(new DiviCompatibility([]));
|
||||
|
||||
$component->describe();
|
||||
$component->describe();
|
||||
|
||||
self::assertSame(1, $calls);
|
||||
}
|
||||
|
||||
public function testWithoutDiviThereAreNoFeaturesAndNoGateCall(): void
|
||||
{
|
||||
$this->theme('twentytwentyfive', '1.0');
|
||||
ReleaseGate::useResolver(static function (): ReleaseStatus {
|
||||
self::fail('the gate must not be asked without Divi');
|
||||
});
|
||||
|
||||
$component = (new DiviEnvironmentComponent(new DiviCompatibility([])))->describe();
|
||||
|
||||
self::assertFalse($component['active']);
|
||||
self::assertSame([], $component['features']);
|
||||
self::assertNull($component['release']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user