Repository navigation
test(block): add PHPUnit, Jest and Playwright suites - #30
Merged
Merged
Conversation
Release 1.2.2
The security fixes of 1.2.1 and 1.2.2 were only checked by hand. Cover the renderer filtering in PHP, the editor helpers in Jest and the block in the editor and on the front end with Playwright, on an isolated wp-env site, and run the three suites on pull requests. Closes #26 Co-Authored-By: Claude Fable 5.2 <[email protected]>
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
The plugin had no automated tests: the security fixes of 1.2.1 (stored XSS) and 1.2.2 (
allowpolicy) were only checked by hand. This adds three suites, each at its own level, and runs them on pull requests.Closes #26
tests/php/BlockRendererthroughdo_blocks(): attribute allowlist, escaping, source protocols,allowpolicy and theblockparty_iframe_allowed_featuresfiltertests/js/src/blockparty-iframe/utils.jstests/playwright/No production file (
src/,includes/,blockparty-iframe.php) is modified.What changed
.wp-env.test.json, port 8889), separate from the development site.@wordpress/env12.1 (needed for--configandtestsEnvironment) and@wordpress/scripts31.8 (same major, accepts wp-env 12) replace thelatestranges. PHPUnit 9.6.38 andyoast/phpunit-polyfills1.1.5 are added; the WordPress test library comes from wp-env.env:start/env:stoppointed at a missing./wp-env.jsonand are fixed. Newtest:php,test:unit:js,test:e2e(plus debug and UI variants) and test-site lifecycle scripts. The unusablecomposer phpunitscript is removed.tests-php.yml,tests-js.ymlandtests-e2e.yml. PHPUnit and Playwright run on WordPress 6.7 (declared minimum) and the latest release, with PHP 8.1.tests/,.wp-env.test.jsonandphpunit.xml.distare excluded from the release archive (.distignore,.gitattributes).Notes for reviewers
@wordpress/scriptsbump,build/blockparty-iframe/index.asset.phplists the same dependencies as before.composer check-platform-reqsfails on PHP 8.1 for dev packages, becausewp-clipullssymfony/finder, which needs PHP 8.2 under the simulatedconfig.platform.php8.3.36. This predates this PR; the workflow checks--no-dev, which passes..eslintrc: adds the WordPress Jest and Playwright presets for the test folders.Test plan
npm run test:unit:js: 53 tests passnpm run test:php: 50 tests pass on WordPress 7.1.4 and 6.7, PHP 8.1npm run test:e2e: 9 tests pass on WordPress 7.1.4 and 6.7, PHP 8.1allowfilter disabled: 6 PHPUnit and 2 Playwright failures; protocol check disabled: 3 Jest failures)BlockRendererlinesnpm run lint:js,composer csand PHPCS ontests/passPHP Tests,JavaScript TestsandE2E Testsworkflows are green on this PR🤖 Generated with Claude Code
Note
Low Risk
Changes are limited to tests, dev dependencies, CI, and documentation; production plugin behavior is unchanged.
Overview
Adds three automated test suites and runs them in CI, without changing plugin runtime code (
src/,includes/,blockparty-iframe.php).PHPUnit (
tests/php/, wp-env on port 8889) exercisesBlockRendererviado_blocks()—URL protocols, attribute allowlists, escaping,allowpolicy, andblockparty_iframe_allowed_features. Jest (tests/js/) coversutils.jshelpers. Playwright (tests/playwright/) covers editor flows (form, server-side preview, lazyload, legacy static markup) and front-end output.Tooling: Pins
@wordpress/scripts31.8 and@wordpress/env12.1; adds PHPUnit 9.6 and polyfills; fixesenv:start/env:stop; addstest:php,test:unit:js,test:e2eand test-site npm scripts; dropscomposer phpunit. New.wp-env.test.jsonisolates the test WordPress site from dev (8888).CI: Three workflows—
tests-php.yml(matrix WP 6.7 + latest, PHP 8.1, coverage artifact),tests-js.yml,tests-e2e.yml(Chromium artifact cache). Packaging excludestests/, test configs from release via.distignore/.gitattributes. README, CHANGELOG, and ESLint overrides for test folders are updated.Reviewed by Cursor Bugbot for commit ea13e79. Bugbot is set up for automated code reviews on this repo. Configure here.