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:
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Pages;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\Design\DesignSystemReader;
|
||||
use LIT\MCP\Integrations\Divi\Library\LibraryAccess;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviNodeGetAbility;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviOutlineAbility;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviPageLoader;
|
||||
@@ -128,7 +129,7 @@ final class DiviReadAbilitiesTest extends TestCase
|
||||
public function testNodeGetNamesTheLibraryEntryOfAGlobalModule(): void
|
||||
{
|
||||
DiviFixtures::givenPost(DiviFixtures::markup('stage3/page--globale-instanzen.html'));
|
||||
$ability = new DiviNodeGetAbility(new DiviPageLoader(DiviFixtures::schema()), $this->design());
|
||||
$ability = new DiviNodeGetAbility(LibraryFixtures::loader(), $this->design());
|
||||
|
||||
$global = $ability->execute(['post_id' => 7, 'id' => 'g0']);
|
||||
$plain = $ability->execute(['post_id' => 7, 'id' => 's0']);
|
||||
@@ -140,6 +141,56 @@ final class DiviReadAbilitiesTest extends TestCase
|
||||
self::assertNull($plain['global']);
|
||||
}
|
||||
|
||||
/** Ruling P13: without the library right node-get and outline name no library ID. */
|
||||
public function testWithoutLibraryAccessNoLibraryIdIsNamed(): void
|
||||
{
|
||||
DiviFixtures::givenPost(DiviFixtures::markup('stage3/page--globale-instanzen.html'));
|
||||
$loaders = [
|
||||
'no divi_library right' => LibraryFixtures::loader(LibraryFixtures::access(['divi_library'])),
|
||||
'group disabled' => LibraryFixtures::loader(new LibraryAccess(
|
||||
LibraryFixtures::store(),
|
||||
LibraryFixtures::roles(),
|
||||
null,
|
||||
static fn (): bool => false
|
||||
)),
|
||||
'no library access at all' => new DiviPageLoader(DiviFixtures::schema()),
|
||||
];
|
||||
|
||||
foreach ($loaders as $case => $loader) {
|
||||
$nodeGet = new DiviNodeGetAbility($loader, $this->design());
|
||||
$global = $nodeGet->execute(['post_id' => 7, 'id' => 'g0']);
|
||||
$outline = (new DiviOutlineAbility($loader, $this->design()))->execute(['post_id' => 7]);
|
||||
|
||||
self::assertNull($global['global']['id'], $case);
|
||||
self::assertSame('divi/section', $global['global']['block_name'], $case);
|
||||
self::assertStringContainsString('Divi-Bibliothek', $global['global']['hint'], $case);
|
||||
self::assertArrayNotHasKey('globalModule', $global['attrs'], $case);
|
||||
self::assertFalse($global['editable'], $case);
|
||||
self::assertStringNotContainsString('1058', (string) json_encode($global), $case);
|
||||
self::assertStringNotContainsString('1058', (string) json_encode($outline), $case);
|
||||
self::assertStringNotContainsString('1059', (string) json_encode($outline), $case);
|
||||
self::assertStringNotContainsString('[global', (string) json_encode($outline), $case);
|
||||
foreach (array_column($outline['nodes'], 'id') as $id) {
|
||||
$node = $nodeGet->execute(['post_id' => 7, 'id' => $id]);
|
||||
self::assertStringNotContainsString('1058', (string) json_encode($node), $case . ' ' . $id);
|
||||
self::assertStringNotContainsString('1059', (string) json_encode($node), $case . ' ' . $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Ruling P13: "nur lesen" (group read-only) does not hide library IDs. */
|
||||
public function testAReadOnlyLibraryStillNamesLibraryIds(): void
|
||||
{
|
||||
DiviFixtures::givenPost(DiviFixtures::markup('stage3/page--globale-instanzen.html'));
|
||||
$loader = LibraryFixtures::loader(LibraryFixtures::access([], false));
|
||||
|
||||
$global = (new DiviNodeGetAbility($loader, $this->design()))->execute(['post_id' => 7, 'id' => 'g0']);
|
||||
$outline = (new DiviOutlineAbility($loader, $this->design()))->execute(['post_id' => 7]);
|
||||
|
||||
self::assertSame('1058', $global['global']['id']);
|
||||
self::assertStringContainsString('[global 1058]', $outline['outline']);
|
||||
}
|
||||
|
||||
public function testOutlineOfALibraryItem(): void
|
||||
{
|
||||
LibraryFixtures::given([LibraryFixtures::item(1059)]);
|
||||
|
||||
Reference in New Issue
Block a user