Skip to content

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

Merged
Soare-Robert-Daniel merged 6 commits into
developmentfrom
test/mock-publish-now-e2e
Aug 3, 2026
Merged

test: add mocked E2E coverage for the publish-now flow#1094
Soare-Robert-Daniel merged 6 commits into
developmentfrom
test/mock-publish-now-e2e

Conversation

@Alexia-Soare

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

Copy link
Copy Markdown
Contributor

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 97f90f2 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 4 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>
- Upgrade actions/checkout and actions/setup-node to v7 (keep master refs)
- Update @wordpress/env to 11.12.0, @playwright/test to 1.62.1,
  @wordpress/e2e-test-utils-playwright to 1.52.0
- Point Playwright webServer at the wp-env override port
- Fix e2e specs: wait for Vue binding, assert free-plan upsell and
  permalink-based share link
- Ignore test-results, playwright-report, flaky-tests

Co-authored-by: Cursor <cursoragent@cursor.com>
@Soare-Robert-Daniel
Soare-Robert-Daniel merged commit 4b6ab57 into development Aug 3, 2026
7 checks passed
lucadobrescu added a commit that referenced this pull request Aug 3, 2026
The e2e utils that came in with #1094 enable pretty permalinks in the
test site, so `rest_url()` — and therefore `ropApiSettings.root` — no
longer carries a query string. Appending `&req=...` to it produced
`/wp-json/tweet-old-post/v8/api/&req=add_account_li`, which the REST
server resolved to nothing: all 10 LinkedIn tests failed with
`rest_no_route` / 404 after merging development.

Let URL/searchParams place `?` or `&`, the way the plugin's own
`fetchAJAX` passes `req` through vue-resource's `params` option. Works
under either permalink mode.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
lucadobrescu added a commit that referenced this pull request Aug 3, 2026
Copilot review feedback on #1100.

`is_set_not_empty()` deliberately accepts array values — `is_valid_serialize_data()`
maps over them — so a payload of `{ id: [<valid>], pages: [<valid>] }` cleared
the guard and reached `base64_decode()`, which raises a PHP 8 TypeError. That is
the same critical-error response this PR set out to remove; verified locally,
the request returned HTTP 500 "There has been a critical error on this website"
without the new check.

Guard both encoded fields as strings before decoding, and cover the payload with
an e2e test that fails without it.

Also reset the services store in `beforeEach`. The happy-path test registers a
LinkedIn account and only cleans up on success, so with CI retries enabled a
failed run left that account behind and assertions like `not.toContain('linkedin')`
could pass or fail depending on order. Uses the `ropUtils` fixture that came in
with #1094 rather than a second bespoke helper.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@pirate-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 9.4.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Aug 4, 2026
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. released Indicate that an issue has been resolved and released in a particular version of the product.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants