Skip to content

test: Gutenberg block regression harness - #111

Draft
vic322 wants to merge 9 commits into
masterfrom
test/gutenberg-block-regression-harness
Draft

vic322 wants to merge 9 commits into
masterfrom
test/gutenberg-block-regression-harness

Conversation

@vic322

@vic322 vic322 commented Jul 13, 2026

Copy link
Copy Markdown
Owner

ブロック回帰テスト網の骨格 + integrationレーン実働化。CI検証用のdraft(マージしない)

  • L1/L2: balloon の fixture ラウンドトリップ(jest)
  • L3(案B): new-list の render golden master
  • integrationレーンを PHPUnit 9.6 で実働化(従来は全skipのfalse green)

このPRの目的は、integrationテストがCIで実際に実行される(skipされない)ことの確認

vic322 added 9 commits July 13, 2026 23:20
Establish a WordPress-core full-content style regression net for
Gutenberg blocks, verifying block validity and save-output stability
before the planned TypeScript/ESM refactor. balloon is the first
covered block: each fixture is parsed, asserted valid, and re-serialized
to confirm a clean round-trip.

Run via @wordpress/scripts test-unit-js. Cocoon-specific global stubs
are required because transforms.js and edit.js reference wp.* and
gbSettings at module load time; removing that global coupling in the
refactor will let the stubs go away.
The integration bootstrap called tests_add_filter() before requiring
the WordPress test suite's functions.php that defines it, so it fatally
errored the moment it was actually used. The bug stayed hidden because
phpunit.xml still wires every suite to the unit bootstrap, leaving this
file dead. Require functions.php first so the file works once wired in.
Add the regression matrix ceiling environment for local integration and
render testing. Ports, network subnet, and volumes are isolated from the
existing 6.x combos so it can run alongside them. A dedicated
wordpress_test database is created on init because the WP test suite
drops all tables in its target database. Also ignore .phpunit.result.cache.
Add a WordPress-core style render regression test for the dynamic
new-list block. Deterministic posts are seeded via the test factory,
rendered through do_blocks(), and the volatile parts (ids, dates, urls,
version query) are normalized before comparing against a committed
golden. Run with UPDATE_GOLDEN=1 to regenerate the golden files.
The integration testsuite silently skipped in CI because phpunit.xml
wires every suite to the Brain\Monkey unit bootstrap, which never loads
WP_UnitTestCase. Real WordPress integration tests must run on PHPUnit 9.x
+ yoast/phpunit-polyfills ^1.1, since the WordPress 7.0 test suite calls
parseTestMethodAnnotations(), removed in PHPUnit 10; the theme root stays
on PHPUnit ^11 for the unit lane.

Give the integration lane its own isolated toolchain (a dedicated
composer manifest with a tracked lock for reproducibility), a PHPUnit 9.6
config that loads the WP-aware bootstrap, and a docker-based local runner
that mirrors the CI path. The bootstrap loads the tooling autoloader
rather than the theme's PHPUnit 11 vendor to avoid class-version clashes.
Point the CI integration job at the isolated PHPUnit 9.6 toolchain and
the dedicated integration config, and pass the polyfills path to the WP
test suite. The job now actually executes the integration tests instead
of silently skipping them all.
GitHub is deprecating Node.js 20 on Actions runners, so checkout, cache,
and upload-artifact were being force-run on Node 24 with a warning. Bump
each to the lowest major that natively targets Node 24 (checkout v5,
cache v5, upload-artifact v6 — v5 still ships Node 20) to clear the
warning with minimal change; dependabot can advance them further.
phpunit.yml covers only the PHP side; the block JavaScript fixture tests
(block.json + edit/save parse-serialize round-trip) had no CI job and ran
locally only. Add a Block Regression workflow that installs the blocks
toolchain and runs the jest fixture suite, so the JS safety net actually
gates on pull requests.
Generalize the balloon proof-of-concept into a block.json discovery
harness that registers every structured block (37: block, block-universal,
micro) via its index.js metadata instead of the unstable blocks.js path,
then runs the WordPress-core full-content round-trip (parse, assert valid,
re-serialize) against a captured fixture per block. Fixtures are generated
from each block's example via createBlock/getBlockFromExample + serialize,
not hand-guessed.

Add @wordpress/block-library as a dev dependency (version-matched to the
installed @WordPress packages, no drift) so InnerBlocks serialize through
the real core blocks. A single console.error suppression is scoped to the
core/list unique-key dev warning; every other error still fails the suite.
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