From 7465438d1e12010f623dd6ba8b28b6502577a847 Mon Sep 17 00:00:00 2001 From: fahimreza-dev Date: Mon, 7 Sep 2026 03:23:56 +0600 Subject: [PATCH] test(skills): switch to a classic fixture theme instead of assuming one The classic-theme playbook test read the host install's theme as a fixture. CI's fresh core ships only block themes, so it failed on every leg since 2026-08-21 while green locally. Both step-2 branches now switch to the fixture they mean. Closes #145 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01ApYKEKcBnpuz8w6BX2agfH --- .../themes/saddle-classic-fixture/index.php | 13 +++ .../themes/saddle-classic-fixture/style.css | 13 +++ tests/skills-test.php | 89 ++++++++++++++++--- 3 files changed, 104 insertions(+), 11 deletions(-) create mode 100644 tests/fixtures/themes/saddle-classic-fixture/index.php create mode 100644 tests/fixtures/themes/saddle-classic-fixture/style.css diff --git a/tests/fixtures/themes/saddle-classic-fixture/index.php b/tests/fixtures/themes/saddle-classic-fixture/index.php new file mode 100644 index 0000000..66eec14 --- /dev/null +++ b/tests/fixtures/themes/saddle-classic-fixture/index.php @@ -0,0 +1,13 @@ +assertTrue( wp_get_theme( $slug )->exists(), "Fixture theme {$slug} is missing from tests/fixtures/themes." ); + switch_theme( $slug ); + + try { + $fn(); + } finally { + if ( get_stylesheet() !== $previous ) { + switch_theme( $previous ); + } + } + } + + /** + * A classic theme is exactly the case the old wp_is_block_theme() gate + * excluded — so a classic site with no builder, the one with no site editor + * to fall back on, got no playbook at all. */ public function test_the_playbooks_ship_on_a_classic_theme_with_no_builder() { - $this->with_no_foreign_builder( + $this->with_theme( + 'saddle-classic-fixture', function () { - $names = $this->builtin_names(); + $this->with_no_foreign_builder( + function () { + $names = $this->builtin_names(); - $this->assertContains( 'build-page', $names ); - $this->assertContains( 'fix-page', $names ); + $this->assertContains( 'build-page', $names ); + $this->assertContains( 'fix-page', $names ); + } + ); } ); } @@ -381,12 +419,41 @@ function () { * not send the agent after get-template — it would be refused. */ public function test_the_playbook_adapts_step_two_to_a_classic_theme() { - $this->with_no_foreign_builder( + $this->with_theme( + 'saddle-classic-fixture', + function () { + $this->assertFalse( wp_is_block_theme(), 'The classic fixture must not read as a block theme.' ); + + $this->with_no_foreign_builder( + function () { + $body = Saddle_Skills::find( 'build-page' )['body']; + + $this->assertStringContainsString( 'classic theme', $body ); + $this->assertStringNotContainsString( 'saddle/get-template on the header', $body ); + } + ); + } + ); + } + + /** + * The other branch, pinned for the same reason: a block theme has header + * and footer parts Saddle CAN read, so step 2 sends the agent to them. + */ + public function test_the_playbook_sends_step_two_to_the_template_parts_on_a_block_theme() { + $this->with_theme( + 'saddle-block-fixture', function () { - $body = Saddle_Skills::find( 'build-page' )['body']; + $this->assertTrue( wp_is_block_theme(), 'The block fixture must read as a block theme.' ); + + $this->with_no_foreign_builder( + function () { + $body = Saddle_Skills::find( 'build-page' )['body']; - $this->assertStringContainsString( 'classic theme', $body ); - $this->assertStringNotContainsString( 'saddle/get-template on the header', $body ); + $this->assertStringContainsString( 'saddle/get-template on the header', $body ); + $this->assertStringNotContainsString( 'this is a classic theme', $body ); + } + ); } ); }