Repository navigation
Add WordPress integration suite, editor smoke test, and fix shortcode class bug - #11
Merged
Merged
Conversation
Adds tests/integration, a PHPUnit suite that runs against a real WordPress backed by SQLite (scripts/setup-wordpress-integration.sh), so it needs no MySQL or Docker. It covers block registration and API-version agreement between PHP, block.json and the editor script, script localization, do_shortcode/do_blocks/the_content rendering, site defaults and overrides, hostile input, saving and reloading posts for kses-filtered roles, settings sanitization and uninstall. Run it with composer ci:integration; pick a version with WP_VERSION (verified on 6.3 and 7.1.2). The suite immediately caught a bug from the custom-class change: WordPress passes the shortcode tag as a third callback argument, which the new wrapper-class parameter swallowed, adding a stray "credits" class to every shortcode. The shortcode callback is two-argument again and the block path uses credits_render_credit(); a unit regression test covers it. Also removes tests/bootstrap.php from composer autoload-dev: it loaded the WordPress stubs into every PHPUnit run and would collide with real WordPress. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Extends the Playwright block-editor test to edit name, URL, type, spacing and custom class through the real editor, publish, reload the editor and open the front end, asserting every value survives. scripts/run-editor-e2e.sh runs it against the SQLite integration WordPress so it needs no MySQL; composer ci:e2e and ci-local.sh --e2e wire it into local CI, and --full now checks for MySQL before doing any other work. The test dismisses the first-run welcome guide that blocks clicks, and takes its base URL and artifact directory from the environment instead of hardcoded Cloud Agent values. Reverting the custom-class fix makes it fail. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements IMPROVEMENT_PLAN.md item 2, tests that run against actual WordPress, and fixes a bug those tests found in what I merged in #9.
Bug fixed. WordPress calls shortcode callbacks as
( $atts, $content, $tag ). The$wrapper_classparameter added in #9 swallowed the tag, so every[credits]shortcode rendered with a stray extracreditsclass (and any alias tag would have become a CSS class). The shortcode callback is two-argument again and the block path uses a newcredits_render_credit(). The stub-based unit tests could not see this because theiradd_shortcodestub never passes a tag; a unit regression test now does.Integration suite (
tests/integration/,composer ci:integration). Runs against a disposable real WordPress backed by SQLite, installed byscripts/setup-wordpress-integration.sh, so it needs no MySQL or Docker. It covers:block.jsonand the editor scriptdo_shortcode(),do_blocks()andthe_contentrendering&in block JSON for the last two, so the test asserts the plugin's settings and rendered output survive instead of byte-identical attributes)Verified on WordPress 7.1.2 and 6.3 (the plugin's minimum) with PHP 8.5:
WP_VERSION=6.3 composer ci:integration.Editor smoke test (
composer ci:e2e). Extends the Playwright test to edit name, URL, type, spacing and custom class in the real editor, publish, reload, and check the published page. It runs on the same SQLite install.Mutation checks. I reverted each fix and confirmed a test fails: JS
apiVersion1,block.jsonapiVersion2,block_api_versionlocalized again, custom class dropped (both suites), the shortcode tag leak, and a wrong built-in default type (the last one was missed at first, so I added a test).Other changes
tests/bootstrap.phpfrom composerautoload-dev. It loaded the WordPress stubs (and definedABSPATH) into every PHPUnit run, which collides with real WordPress.ci-local.shgains--integrationand--e2e;--fullchecks for MySQL first.Test plan
composer cipasses (53 unit tests)composer ci:integrationpasses (42 tests, 246 assertions) on WordPress 7.1.2 and 6.3composer ci:e2epasses (11 editor checks)--fullis unchanged and still unverified here (no MySQL installed)🤖 Generated with Claude Code