fix: Preset-Änderungen ohne unfiltered_html ablehnen, wenn Divi HTML/CSS anderer Presets entfernen würde
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
048cd9353d
commit
75714429be
@@ -25,12 +25,17 @@ final class DiviPresetsDeleteAbilityTest extends TestCase
|
||||
Functions\when('delete_option')->justReturn(true);
|
||||
}
|
||||
|
||||
private function ability(UsageReport $report, ?DesignSystemWriter $writer = null, ?SnapshotStore $snapshots = null): DiviPresetsDeleteAbility
|
||||
{
|
||||
private function ability(
|
||||
UsageReport $report,
|
||||
?DesignSystemWriter $writer = null,
|
||||
?SnapshotStore $snapshots = null,
|
||||
bool $unfiltered = true,
|
||||
array $stored = []
|
||||
): DiviPresetsDeleteAbility {
|
||||
Functions\when('current_user_can')->justReturn(true);
|
||||
if ($writer === null) {
|
||||
$writer = Mockery::mock(DesignSystemWriter::class);
|
||||
$writer->allows('presets')->andReturn(PresetBookTest::stored());
|
||||
$writer->allows('presets')->andReturn($stored === [] ? PresetBookTest::stored() : $stored);
|
||||
$writer->allows('canUseVisualBuilder')->andReturn(true);
|
||||
}
|
||||
$usages = Mockery::mock(GlobalUsages::class);
|
||||
@@ -39,7 +44,8 @@ final class DiviPresetsDeleteAbilityTest extends TestCase
|
||||
return new DiviPresetsDeleteAbility(
|
||||
$writer,
|
||||
new DesignChange($snapshots ?? Mockery::mock(SnapshotStore::class), new FakeChangeLog(3)),
|
||||
$usages
|
||||
$usages,
|
||||
static fn (): bool => $unfiltered
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,6 +119,22 @@ final class DiviPresetsDeleteAbilityTest extends TestCase
|
||||
self::assertSame(['removed', 'default_cleared'], array_column($dry['diff'], 'action'));
|
||||
}
|
||||
|
||||
/** Final review I-2: deleting saves the whole inventory – other presets' HTML/CSS would be stripped. */
|
||||
public function testEditorIsRefusedWhenOtherPresetsCarryMarkup(): void
|
||||
{
|
||||
$input = ['items' => [['module' => 'button', 'preset' => 'cccccccccc']]];
|
||||
$markup = PresetBookTest::storedWithMarkup();
|
||||
|
||||
$editor = self::assertToolError(
|
||||
$this->ability(self::unused(), null, null, false, $markup)->execute($input),
|
||||
'forbidden'
|
||||
);
|
||||
self::assertStringContainsString('unfiltered_html', $editor['message']);
|
||||
|
||||
self::assertToolError($this->ability(self::unused(), null, null, true, $markup)->execute($input), 'confirm_required');
|
||||
self::assertToolError($this->ability(self::unused(), null, null, false)->execute($input), 'confirm_required');
|
||||
}
|
||||
|
||||
public function testUnknownPreset(): void
|
||||
{
|
||||
self::assertToolError(
|
||||
|
||||
Reference in New Issue
Block a user