Skip to content

Add WordPress integration suite, editor smoke test, and fix shortcode class bug - #11

Merged
jashjacob merged 2 commits into
masterfrom
test/wordpress-integration-suite
Sep 29, 2026
Merged

jashjacob merged 2 commits into
masterfrom
test/wordpress-integration-suite

Conversation

@jashjacob

Copy link
Copy Markdown
Owner

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_class parameter added in #9 swallowed the tag, so every [credits] shortcode rendered with a stray extra credits class (and any alias tag would have become a CSS class). The shortcode callback is two-argument again and the block path uses a new credits_render_credit(). The stub-based unit tests could not see this because their add_shortcode stub 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 by 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, including site defaults reaching the editor
  • do_shortcode(), do_blocks() and the_content rendering
  • site defaults and explicit overrides, and hostile URL, name, color and class input
  • saving and reloading posts as administrator, editor, author and contributor (WordPress core's kses rewrites & in block JSON for the last two, so the test asserts the plugin's settings and rendered output survive instead of byte-identical attributes)
  • settings sanitization and uninstall

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 apiVersion 1, block.json apiVersion 2, block_api_version localized 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

  • Removes tests/bootstrap.php from composer autoload-dev. It loaded the WordPress stubs (and defined ABSPATH) into every PHPUnit run, which collides with real WordPress.
  • The integration bootstrap rebinds file-scope WordPress variables to their live globals. PHPUnit includes bootstraps inside a function, which otherwise wipes every registered shortcode.
  • ci-local.sh gains --integration and --e2e; --full checks for MySQL first.

Test plan

  • composer ci passes (53 unit tests)
  • composer ci:integration passes (42 tests, 246 assertions) on WordPress 7.1.2 and 6.3
  • composer ci:e2e passes (11 editor checks)
  • Each regression above makes the relevant test fail when reintroduced
  • The MySQL smoke stage of --full is unchanged and still unverified here (no MySQL installed)
  • The e2e does not set the accent colors (color picker), and no run covers a block theme versus a classic theme

🤖 Generated with Claude Code

jashjacob and others added 2 commits September 29, 2026 11:58
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>
@jashjacob
jashjacob merged commit b994f19 into master Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant