fix: content-create with divi returns the Visual Builder edit_url (review I-1)

DiviPage::builderUrl() is shared by DiviPage::editUrl() and the content
composer, which now returns edit_url; content-create without divi keeps
the wp-admin link. divi-write-smoke checks the builder URL and, new in
section 9, the M1/M2 gates live (raw Divi markup refused; Divi read-only
stops content-create divi and execute-ability lit/divi-insert).

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-26 19:19:04 +02:00
co-authored by Claude Opus 5.5
parent 5f596b8a17
commit 4fe0810049
7 changed files with 74 additions and 9 deletions
@@ -85,13 +85,21 @@ final class ContentCreateDiviTest extends TestCase
]));
Functions\when('get_preview_post_link')->justReturn('https://kunde.test/?page_id=42&preview=true');
Functions\when('get_edit_post_link')->justReturn('https://kunde.test/wp-admin/post.php?post=42&action=edit');
Functions\when('get_permalink')->justReturn('https://kunde.test/?page_id=42');
Functions\when('add_query_arg')->alias(
static fn (string $key, string $value, string $url): string => $url . '&' . $key . '=' . $value
);
}
public function testCreatesADiviDraftWithTreeRevOutlineAndWarnings(): void
{
$composer = $this->composer();
$composer->expects('write')->with(42, 'page', self::SECTIONS)
->andReturn(['warnings' => ['s0: leer (section ohne Inhalt).'], 'outline' => 's0 divi/section']);
->andReturn([
'warnings' => ['s0: leer (section ohne Inhalt).'],
'outline' => 's0 divi/section',
'edit_url' => 'https://kunde.test/?page_id=42&et_fb=1',
]);
// D7: the insert carries only the normal WordPress fields (kses as usual) – never Divi markup;
// the layout is written by the Divi composer through DiviSaver's single kses window.
Functions\expect('wp_insert_post')->once()->with([
@@ -108,6 +116,8 @@ final class ContentCreateDiviTest extends TestCase
self::assertSame(Rev::of(self::MARKUP), $result['tree_rev']);
self::assertSame(['s0: leer (section ohne Inhalt).'], $result['warnings']);
self::assertSame('s0 divi/section', $result['outline']);
// Review I-1: like every Divi write, the builder – not wp-admin – is where to continue.
self::assertSame('https://kunde.test/?page_id=42&et_fb=1', $result['edit_url']);
self::assertStringContainsString('Entwurf', $result['summary'], 'drafts stay drafts');
self::assertArrayHasKey('tree_rev', $this->ability(null)->outputSchema()['properties']);
self::assertArrayHasKey('divi', $this->ability(null)->inputSchema()['properties']);
@@ -165,6 +175,7 @@ final class ContentCreateDiviTest extends TestCase
$result = $this->ability($composer)->execute(['post_type' => 'page', 'title' => 'Start']);
self::assertTrue($result['ok']);
self::assertStringContainsString('/wp-admin/post.php', $result['edit_url'], 'without divi: the editor');
}
public function testEveryValidationErrorComesBackAndNothingIsCreated(): void