feat: render summary notes global modules it cannot show (F8)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -8,6 +8,8 @@ use Brain\Monkey\Functions;
|
||||
use LIT\MCP\Integrations\WordPress\Render\PageRenderer;
|
||||
use LIT\MCP\Integrations\WordPress\Render\PageRenderSummaryAbility;
|
||||
use LIT\MCP\Integrations\WordPress\Render\RenderSummary;
|
||||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||||
use LIT\MCP\Tests\Support\DiviFixtures;
|
||||
use LIT\MCP\Tests\Support\SchemaFixture;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
@@ -138,4 +140,33 @@ final class PageRenderSummaryAbilityTest extends TestCase
|
||||
self::assertTrue($ability->isDirect());
|
||||
self::assertTrue($ability->annotations()['readonly']);
|
||||
}
|
||||
|
||||
public function testNotesEveryGlobalModuleTheSummaryCannotShow(): void
|
||||
{
|
||||
$content = DiviFixtures::markup('stage3/page--globale-instanzen.html');
|
||||
$post = new WP_Post(['ID' => 7, 'post_type' => 'page', 'post_status' => 'draft', 'post_content' => $content]);
|
||||
Functions\when('get_post')->justReturn($post);
|
||||
Functions\when('current_user_can')->justReturn(true);
|
||||
Functions\when('get_permalink')->justReturn('https://kunde.test/?page_id=7');
|
||||
$renderer = Mockery::mock(PageRenderer::class);
|
||||
$renderer->allows('render')->andReturn('<p>Text</p>');
|
||||
$ability = new PageRenderSummaryAbility(SchemaFixture::managed(), $renderer);
|
||||
|
||||
$notes = $ability->execute(['post_id' => 7])['notes'];
|
||||
|
||||
$globals = array_values(array_filter($notes, static fn (string $note): bool => str_starts_with($note, 'Globales Modul')));
|
||||
self::assertCount(2, $globals);
|
||||
self::assertStringContainsString('Globales Modul 1058 ist im Auszug nicht enthalten', $globals[0]);
|
||||
self::assertStringContainsString('lit-divi-outline mit post_id 1059', $globals[1]);
|
||||
}
|
||||
|
||||
public function testLibraryEntriesAreNoManagedContent(): void
|
||||
{
|
||||
Functions\when('get_post')->justReturn(new WP_Post(['ID' => 1058, 'post_type' => 'et_pb_layout']));
|
||||
$schema = Mockery::mock(ContentSchema::class);
|
||||
$schema->allows('isManaged')->with('et_pb_layout')->andReturn(false);
|
||||
$ability = new PageRenderSummaryAbility($schema, Mockery::mock(PageRenderer::class));
|
||||
|
||||
self::assertToolError($ability->permission(['post_id' => 1058]), 'not_found');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user