fix: library IDs stay hidden without library access (ruling P13)

Outline, node-get, write outlines, the render summary and replace-text's
opaque-node match name no library ID unless the library group is visible
and the user has divi_library; read-only still names them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 15:00:39 +02:00
co-authored by Claude Opus 5.5
parent 06f13799de
commit c7ce924e5a
19 changed files with 351 additions and 28 deletions
@@ -160,6 +160,44 @@ final class PageRenderSummaryAbilityTest extends TestCase
self::assertStringContainsString('lit-divi-outline mit post_id 1059', $globals[1]);
}
/** Ruling P13: without library access the note counts global modules instead of naming them. */
public function testWithoutLibraryAccessGlobalModulesAreOnlyCounted(): 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, static fn (): bool => false);
$result = $ability->execute(['post_id' => 7]);
$joined = implode("\n", $result['notes']);
self::assertStringContainsString('2 globale Module sind im Auszug nicht enthalten', $joined);
self::assertStringNotContainsString('1058', $joined);
self::assertStringNotContainsString('1059', $joined);
self::assertStringNotContainsString('1058', (string) json_encode($result));
}
/** Ruling P13: with library access the notes name each entry. */
public function testWithLibraryAccessGlobalModulesAreNamed(): 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, static fn (): bool => true);
$joined = implode("\n", $ability->execute(['post_id' => 7])['notes']);
self::assertStringContainsString('Globales Modul 1058', $joined);
}
public function testLibraryEntriesAreNoManagedContent(): void
{
Functions\when('get_post')->justReturn(new WP_Post(['ID' => 1058, 'post_type' => 'et_pb_layout']));