feat: Gutenberg 22.8 V2 encoding compatibility and e2e test suite#25
feat: Gutenberg 22.8 V2 encoding compatibility and e2e test suite#25
Conversation
Gutenberg 22.8 (PR #76304) switched Yjs update encoding from V1 to V2,
breaking collaborative editing with external clients. This adapts the
sync protocol to match Gutenberg's mixed V1/V2 approach:
- Step1/step2 handshake: V1 via y-protocols (Gutenberg still uses
syncProtocol.readSyncMessage which hardcodes V1)
- Regular updates and compactions: V2 (doc.on('updateV2'),
applyUpdateV2, encodeStateAsUpdateV2)
Also increases sync wait timeout from 5s to 15s to accommodate
Gutenberg 22.8's slower polling intervals (4s solo), and adds a
minimum WordPress version check (7.0+) during setup and connect.
Adds a Playwright e2e test suite covering block insert, edit, attribute
change, remove, browser-to-MCP sync, and multi-step workflows against
a live wp-env Gutenberg instance.
✅ Coverage Report
Changed Files
|
There was a problem hiding this comment.
Pull request overview
Updates the server’s Yjs sync protocol and tooling to interoperate with Gutenberg 22.8’s mixed V1/V2 encoding, and adds Playwright e2e coverage for collaborative block sync against a live wp-env WordPress instance.
Changes:
- Switch sync UPDATE/COMPACTION handling to Yjs V2 (
updateV2/applyUpdateV2/encodeStateAsUpdateV2) while keeping sync step1/step2 via y-protocols (V1). - Add minimum WordPress version check during connection/setup and increase initial sync wait timeout to 15s.
- Add Playwright-based e2e suite + helpers and include tests/config in TypeScript project for strict checking.
Reviewed changes
Copilot reviewed 19 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/yjs/sync-protocol.ts |
Implements mixed V1 (handshake) / V2 (updates+compaction) encoding behavior. |
src/session/session-manager.ts |
Uses updateV2, increases sync wait timeout, and enforces minimum WP version on connect. |
src/wordpress/api-client.ts |
Adds checkMinimumVersion() and associated error messaging. |
src/cli/setup.ts |
Runs minimum version check during setup credential validation and logs version. |
tests/unit/sync-protocol.test.ts |
Updates unit tests to use V2 events/decoding where appropriate. |
tests/integration/two-client-sync.test.ts |
Updates integration tests to capture V2 updates. |
tests/unit/session-manager.test.ts |
Mocks new API client method + fixes strict typing in fs mock. |
tests/unit/server.test.ts |
Fixes strict nullability for handler registries. |
tests/unit/cli/setup.test.ts |
Adjusts mocked REST validation sequence to include version check. |
tests/unit/cli/auth-server.test.ts |
Adjusts execFile mock signature for strict typing. |
tests/e2e/helpers/wp-env.ts |
Adds wp-env lifecycle and WP CLI helpers for e2e. |
tests/e2e/helpers/mcp.ts |
Adds MCP stdio client helper utilities for e2e. |
tests/e2e/global-setup.ts / tests/e2e/global-teardown.ts |
Starts/stops wp-env for Playwright runs. |
tests/e2e/block-sync.spec.ts |
Adds browser↔MCP collaborative block sync e2e scenarios. |
playwright.config.ts |
Introduces Playwright test configuration. |
tsconfig.json |
Includes tests/config files; removes rootDir. |
package.json / package-lock.json |
Adds Playwright dependency and e2e scripts. |
CLAUDE.md |
Documents mixed encoding + minimum version behavior. |
.markdownlint-cli2.jsonc / .gitignore |
Ignores Playwright output and adds minor formatting/ignore updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Covers: version >= 7.0, version < 7.0, endpoint unavailable, missing version field, empty version, unparseable version, and the setup wizard exit path for old WordPress versions.
- STATE_FILE collision: include repo root hash in temp filename to prevent concurrent e2e runs from different checkouts interfering. - Version check logic: rename checkMinimumVersion() to getWordPressVersion() — now purely informational (never throws). The sync endpoint check remains the real gate. If the endpoint returns 404, the error message includes the detected WP version and mentions both upgrade paths (WP 7.0+ or Gutenberg 22.8+). This fixes a bug where WP 6.x + Gutenberg 22.8+ users were incorrectly blocked.
Replace wp-cli commands (npx wp-env run cli) with REST API calls for post creation, deletion, and app password creation. This eliminates concurrent wp-cli execution issues that caused "Environment not initialized" errors when running tests in parallel. Also always run wp-env start in global setup (idempotent) to ensure wp-env's internal state file is valid regardless of how the environment was started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 23 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use shared app password (created once in global setup via wp-cli) for all REST API calls, eliminating per-test app password creation race conditions. - Replace wp-cli post CRUD with REST API calls, safe for concurrent execution across workers. - Revert unconditional wp-env start (afterStart script is too slow). - Add e2e job to CI workflow (Node 22, Playwright + wp-env). - Enable fullyParallel with 2 workers.
Add a Playwright setup project that logs in once and saves storage state. All test workers reuse the saved session, eliminating concurrent login race conditions. Bumps workers to 4.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 25 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fetch the latest Gutenberg release ZIP via GitHub API at CI time instead of cloning and building trunk. This avoids the slow afterStart build step and the directory layout issues in CI.
- CLAUDE.md: Update stale version check docs to match the current informational getWordPressVersion() approach. - session-manager.test.ts: Replace hacky `as []` cast with properly typed variadic mock signature for mockReadFile.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 25 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- ensureWpEnvRunning() checks state file for existing app password before creating a new one, preventing accumulation. - teardownWpEnv() preserves state file when CLAUDABORATIVE_E2E_REUSE_ENV=1 so the next run can reuse the password.
Summary
tsconfig.jsonProtocol changes
Gutenberg 22.8 switched regular updates and compactions to V2 encoding but kept the sync handshake (step1/step2) on V1 via y-protocols. We now match this:
syncProtocol.readSyncMessagewhich hardcodes V1doc.on('updateV2'), applies withapplyUpdateV2encodeStateAsUpdateV2E2e tests
6 Playwright tests against a live wp-env + Gutenberg instance:
Test plan
npm run typecheck— passesnpm test— 834 unit/integration tests passnpm run lint— cleannpm run test:e2e— 6 e2e tests pass