Skip to content

test: add mocked E2E coverage for the publish-now flow#1094

Open
Alexia-Soare wants to merge 4 commits into
developmentfrom
test/mock-publish-now-e2e
Open

test: add mocked E2E coverage for the publish-now flow#1094
Alexia-Soare wants to merge 4 commits into
developmentfrom
test/mock-publish-now-e2e

Conversation

@Alexia-Soare

@Alexia-Soare Alexia-Soare commented Jul 13, 2026

Copy link
Copy Markdown

Summary

Adds deterministic, fully mocked E2E coverage for the instant-share (publish now) flow, modeled on the e2e setups in Otter and WooCommerce. No test talks to real social APIs.

Mock infrastructure

  • tests/e2e/mu-plugins/rop-e2e-bootstrap.php — mapped into wp-env as an mu-plugin. Intercepts ROP_POST_ON_X_API / ROP_POST_LOGS_API requests via pre_http_request, records their payloads, and exposes rop-e2e/v1 REST endpoints: /reset, /account, /publish-now, /requests (all manage_options-gated).
  • tests/e2e/fixtures/index.jsropUtils Playwright fixture wrapping those endpoints; specs use it for seeding and for asserting on captured request payloads instead of driving setup through the UI.

Determinism fixes

  • DISABLE_WP_CRON in wp-env — the manual /publish-now trigger is the only share path, eliminating a double-fire race with the event scheduled at publish time (time() + 10).
  • /reset purges leftover rop_publish_now* post meta, so a failed attempt can't leak queued posts into a retry's share run.
  • Scheduled hook is cleared before firing the publish-now action.

Tests

  • publish-now: publish with Share Immediately → trigger → assert both captured requests (post-on-x payload incl. sharing_type, auth token, post text; logs payload incl. network/handle/content/link). Captured requests attached to the test report.
  • post-format: migrated to the fixture (reset + seed per test); asserts default content options and the custom-content editor UI when Custom Content (Pro) is selected.
  • Dropped the now-unused UI-driven addFakeTwitterAccount helper.

CI / tooling

  • Playwright: retries + trace/screenshot/video on CI, flaky-tests reporter (renamed from flasky-), PLAYWRIGHT_CHANNEL override for local runs where the bundled Chromium crashes on newer macOS.
  • e2e workflow: setup-node with built-in npm cache, richer failure artifacts.
  • New copilot-setup-steps.yml preparing a ready-to-use wp-env for the Copilot coding agent.
  • Docs: mock architecture + test-writing practices in AGENTS.md and tests/e2e/README.md.

Test plan

  • PLAYWRIGHT_CHANNEL=chrome npm run test:e2e:playwright — 4/4 passed locally against a fresh wp-env
  • Verified DISABLE_WP_CRON and the mu-plugin are active in the tests container
  • php -l on the mu-plugin; workflow YAMLs validated
  • E2E workflow green on this PR

- Add rop-e2e-bootstrap mu-plugin: mocks the Revive Social server
  (post-on-x/logs) via pre_http_request, records payloads, and exposes
  rop-e2e/v1 REST endpoints (reset, account, publish-now, requests)
- Add ropUtils Playwright fixture wrapping those endpoints; migrate
  post-format and publish-now specs to it and drop the UI-driven
  addFakeTwitterAccount helper
- Make runs deterministic: DISABLE_WP_CRON in wp-env, purge leftover
  publish-now queue meta on reset, clear the scheduled hook before
  firing the publish-now action
- Harden Playwright config: retries + trace/screenshot/video on CI,
  flaky-tests reporter (renamed from flasky), PLAYWRIGHT_CHANNEL
  override for local runs on newer macOS
- CI: setup-node with npm cache, richer failure artifacts; add
  copilot-setup-steps workflow that prepares wp-env
- Docs: mock architecture + TDD practices in AGENTS.md and e2e README
- Bump version to 9.4.0

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@pirate-bot pirate-bot added the pr-checklist-incomplete The Pull Request checklist is incomplete. (automatic label) label Jul 13, 2026
@Alexia-Soare Alexia-Soare added the pr-checklist-skip Allow this Pull Request to skip checklist. label Jul 13, 2026
@pirate-bot pirate-bot added pr-checklist-complete The Pull Request checklist is complete. (automatic label) and removed pr-checklist-incomplete The Pull Request checklist is incomplete. (automatic label) labels Jul 13, 2026
@pirate-bot

pirate-bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Plugin build for bda24b1 is ready 🛎️!

Playwright 1.40 requests libasound2, renamed to libasound2t64 on
Ubuntu 24.04, so apt fails; the runner image already ships the
required libraries. Matches the e2e workflow's install step.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Soare-Robert-Daniel and others added 2 commits July 15, 2026 14:54
Revert the 9.4.0 version bump and readme changelog entry that were
accidentally included with the publish-now E2E work.

Co-authored-by: Cursor <cursoragent@cursor.com>
Restore custom-content post-format coverage, use a resilient @testaccount
locator, and align publish-now bootstrap with reset/seed. Read testsPort
from .wp-env.override.json in Playwright (Otter pattern) and document
port conflicts in AGENTS.md and the e2e README.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants