fix: note the library-list scan cap; preset-cap note only with presets (M-11, M-12)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -75,5 +75,9 @@ final class DiviDesignSystemAbilityTest extends TestCase
|
||||
|
||||
self::assertCount(DiviDesignSystemAbility::PRESET_LIMIT, $result['presets']);
|
||||
self::assertContains('200 von 250 Presets gezeigt; mit module auf ein Modul eingrenzen.', $result['notes']);
|
||||
|
||||
$colors = (new DiviDesignSystemAbility($reader))->execute(['only' => ['colors']]);
|
||||
self::assertSame([], $colors['presets']);
|
||||
self::assertStringNotContainsString('Presets gezeigt', implode(' ', $colors['notes']), 'not requested');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ use LIT\MCP\Tests\Support\LibraryFixtures;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use Mockery;
|
||||
use WP_Error;
|
||||
use WP_Post;
|
||||
|
||||
final class LibraryListAbilityTest extends TestCase
|
||||
{
|
||||
@@ -171,6 +172,39 @@ final class LibraryListAbilityTest extends TestCase
|
||||
self::assertSame(['items' => [], 'next_cursor' => null], $ability->execute(['search' => 'Geheim']));
|
||||
}
|
||||
|
||||
/** Review M-12: when the scan cap stops a page, the answer says so. */
|
||||
public function testSaysWhenTheScanCapIsReached(): void
|
||||
{
|
||||
LibraryFixtures::given([]);
|
||||
Functions\when('current_user_can')->alias(
|
||||
static fn (string $cap, mixed ...$args): bool => ! ($cap === 'edit_post' && ($args[0] ?? 0) >= 5000)
|
||||
);
|
||||
Functions\when('get_post_meta')->justReturn('');
|
||||
Functions\when('wp_get_object_terms')->justReturn([]);
|
||||
$hidden = array_map(
|
||||
static fn (int $id): WP_Post => new WP_Post(['ID' => $id, 'post_type' => 'et_pb_layout', 'post_title' => 'x']),
|
||||
range(5000, 5000 + LibraryListAbility::MAX_SCAN + 10)
|
||||
);
|
||||
$posts = array_merge([LibraryFixtures::item(1055)], $hidden, [LibraryFixtures::item(1056)]);
|
||||
$store = LibraryFixtures::store();
|
||||
$store->allows('find')->andReturnUsing(
|
||||
static fn (array $filters, int $limit, int $offset): array => array_slice($posts, $offset, $limit + 1)
|
||||
);
|
||||
$access = LibraryFixtures::access([], true, $store);
|
||||
$ability = new LibraryListAbility(
|
||||
$access,
|
||||
LibraryFixtures::loader($access),
|
||||
DiviWriterFixture::designReader(),
|
||||
LibraryFixtures::usages([])
|
||||
);
|
||||
|
||||
$result = $ability->execute(['limit' => 5]);
|
||||
|
||||
self::assertSame([1055], array_column($result['items'], 'id'));
|
||||
self::assertSame(Cursor::encode(1), $result['next_cursor']);
|
||||
self::assertStringContainsString('500', $result['notes'][0]);
|
||||
}
|
||||
|
||||
public function testNoNextCursorWhenOnlyHiddenEntriesFollow(): void
|
||||
{
|
||||
LibraryFixtures::given([]);
|
||||
|
||||
Reference in New Issue
Block a user