test: fix the P9/P14 backup wording of every VisibleEdits caller (ruling Q17 M3)

VisibleEditsTest asserts the exact refusal messages (no unfiltered_html,
trash disabled) and the keepingBackup() hints for rolled-back and partial
failures with each caller's label and entry. The callers' own tests drive
GlobalEdits, ThemeBuilderEdits (through DiviWriter) and make-global with
revisions off and assert the same sentences.

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:
2026-09-27 23:03:05 +02:00
co-authored by Claude Opus 5.5
parent 43dc3fb889
commit 79f2fdbda6
5 changed files with 165 additions and 10 deletions
@@ -5,6 +5,7 @@ declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Library;
use Brain\Monkey\Functions;
use LIT\MCP\Abilities\Errors;
use LIT\MCP\Abilities\Rev;
use LIT\MCP\Abilities\WriteFailed;
use LIT\MCP\Integrations\Divi\BlockTree\LibraryContent;
@@ -23,6 +24,7 @@ use LIT\MCP\Tests\Support\DiviWriterFixture;
use LIT\MCP\Tests\Support\FakeChangeLog;
use LIT\MCP\Tests\Support\LibraryFixtures;
use LIT\MCP\Tests\Support\ThemeBuilderFixtures;
use LIT\MCP\Tests\Unit\Integrations\Divi\Pages\VisibleEditsTest;
use LIT\MCP\Tests\Unit\TestCase;
use Mockery;
use Throwable;
@@ -30,6 +32,8 @@ use WP_Post;
final class LibraryMakeGlobalAbilityTest extends TestCase
{
private const BACKUP_HINT = 'Revisionen aktivieren (WP_POST_REVISIONS) oder die Seite im Divi-Builder bearbeiten.';
private WP_Post $page;
/** @var list<LibraryItemSpec> */
@@ -453,11 +457,49 @@ final class LibraryMakeGlobalAbilityTest extends TestCase
$this->saved = [];
$this->givenCopiesOf1058();
Functions\when('current_user_can')->alias(static fn (string $cap): bool => $cap !== 'unfiltered_html');
self::assertToolError($this->ability()->execute(self::targets(['s0'], ['s1'], true)), 'unsupported');
$refused = $this->ability()->execute(self::targets(['s0'], ['s1'], true));
self::assertToolError($refused, 'unsupported');
self::assertSame(sprintf(VisibleEditsTest::UNFAITHFUL, 'Seite 8'), Errors::clientMessage($refused));
self::assertSame(self::BACKUP_HINT, $refused->get_error_data()['hint']);
self::assertSame([], $this->backups);
self::assertSame([], $this->saved);
}
/** Review I-3 (ruling Q17 M3): the trash refusal and a failure after the backup name the page. */
public function testTheBackupWordingNamesThePage(): void
{
$this->givenCopiesOf1058();
Functions\when('wp_revisions_enabled')->justReturn(false);
$noFailures = [];
$ability = new LibraryMakeGlobalAbility(
LibraryFixtures::access(),
DiviWriterFixture::writer($this->saved, $noFailures, false, LibraryFixtures::loader()),
new NewLibraryEntry(LibraryFixtures::access(), Mockery::mock(DiviSaver::class), DiviWriterFixture::modules()),
$this->log,
null,
new VisibleEdits(static fn (WP_Post $post): int => 1071, static fn (): bool => false)
);
$noTrash = $ability->execute(self::targets(['s0'], ['s1'], true));
self::assertToolError($noTrash, 'unsupported');
self::assertSame(sprintf(VisibleEditsTest::NO_TRASH, 'Seite 8'), Errors::clientMessage($noTrash));
self::assertSame(self::BACKUP_HINT, $noTrash->get_error_data()['hint']);
self::assertSame([], $this->saved);
$this->givenCopiesOf1058();
try {
$this->ability([], true, false, [WriteFailed::rolledBack('Grund.')])
->execute(self::targets(['s0'], ['s1'], true));
self::fail('no WriteFailed');
} catch (WriteFailed $e) {
self::assertSame(1071, $e->details['backup_id']);
self::assertSame(VisibleEditsTest::keptRolledBack(1071, 'der Seite'), $e->toError()->get_error_data()['hint']);
self::assertStringContainsString(
Errors::notSavedKeeping('Sicherung 1071 im Papierkorb'),
Errors::clientMessage($e->toError())
);
}
}
/** A failure on page N: the pages before stay replaced (each with revision), the rest untouched – all named. */
public function testAFailureMidwayReportsEveryPage(): void
{