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
@@ -90,7 +90,8 @@ final class DiviPresetsSetAbilityTest extends TestCase
|
||||
new DesignChange($this->snapshots, new FakeChangeLog(5)),
|
||||
$usages,
|
||||
$loader ?? new DiviPageLoader(DiviFixtures::schema()),
|
||||
$composer
|
||||
$composer,
|
||||
static fn (): bool => $unfiltered
|
||||
);
|
||||
}
|
||||
|
||||
@@ -164,6 +165,45 @@ final class DiviPresetsSetAbilityTest extends TestCase
|
||||
self::assertToolError($this->ability(true)->execute($input), 'confirm_required');
|
||||
}
|
||||
|
||||
/** Final review I-2: Divi would strip other presets' HTML/CSS when an editor saves – refused instead. */
|
||||
public function testEditorIsRefusedWhenOtherPresetsCarryMarkup(): void
|
||||
{
|
||||
$this->stored = PresetBookTest::storedWithMarkup();
|
||||
$input = ['items' => [[
|
||||
'module' => 'button', 'preset' => 'CTA primär',
|
||||
'attrs' => ['button.decoration.background' => ['desktop' => ['color' => '#222222']]],
|
||||
]]];
|
||||
|
||||
$editor = self::assertToolError($this->ability(false)->execute($input), 'forbidden');
|
||||
self::assertStringContainsString('unfiltered_html', $editor['message']);
|
||||
self::assertStringContainsString('nichts wurde gespeichert', $editor['message']);
|
||||
self::assertStringContainsString('Administrator', $editor['hint']);
|
||||
|
||||
self::assertToolError($this->ability(true)->execute($input), 'confirm_required');
|
||||
}
|
||||
|
||||
/** The changed preset's own HTML/CSS would be stripped as well (closest safe variant of I-2). */
|
||||
public function testEditorIsRefusedWhenTheChangedPresetCarriesMarkup(): void
|
||||
{
|
||||
$this->stored = PresetBookTest::storedWithMarkup();
|
||||
unset($this->stored['group']['divi/font-body']['items']['gggggggggg']['styleAttrs']);
|
||||
|
||||
$editor = self::assertToolError($this->ability(false)->execute(['items' => [[
|
||||
'module' => 'button', 'preset' => 'bbbbbbbbbb',
|
||||
'attrs' => ['button.decoration.background' => ['desktop' => ['color' => '#222222']]],
|
||||
]]]), 'forbidden');
|
||||
self::assertStringContainsString('unfiltered_html', $editor['message']);
|
||||
}
|
||||
|
||||
public function testEditorMayChangePresetsWhenNoneCarriesMarkup(): void
|
||||
{
|
||||
self::assertToolError($this->ability(false)->execute(['items' => [[
|
||||
'module' => 'button', 'preset' => 'CTA primär',
|
||||
'attrs' => ['button.decoration.background' => ['desktop' => ['color' => '#222222']]],
|
||||
]]]), 'confirm_required');
|
||||
self::assertToolError($this->ability(false)->execute(self::newButton()), 'confirm_required');
|
||||
}
|
||||
|
||||
public function testFromNodeReadsThePage(): void
|
||||
{
|
||||
$content = '<!-- wp:divi/section --><!-- wp:divi/row --><!-- wp:divi/column -->'
|
||||
|
||||
Reference in New Issue
Block a user