Skip to content

chore: incorporate the e2e Playwright suite into the monorepo (NPPM-2919) - #409

Merged
adekbadek merged 88 commits into
mainfrom
nppm-2919-incorporate-e2e-into-workspace
Jul 8, 2026
Merged

chore: incorporate the e2e Playwright suite into the monorepo (NPPM-2919)#409
adekbadek merged 88 commits into
mainfrom
nppm-2919-incorporate-e2e-into-workspace

Conversation

@adekbadek

@adekbadek adekbadek commented Jun 24, 2026

Copy link
Copy Markdown
Member

All Submissions:

  • Have you followed the Newspack Contributing guidelines?
  • Does your code follow the WordPress / VIP Go coding standards?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes proposed in this Pull Request:

Brings the standalone newspack-e2e-tests Playwright suite into the monorepo under e2e/, so the end-to-end tests live alongside the product code they exercise. This is step 1 of NPPM-2919 (the port). Enabling on-demand per-PR runs is step 2 and is designed separately.

  • Imports the suite into e2e/ with full git history preserved. Paths were rewritten (git filter-repo --to-subdirectory-filter e2e) before an unrelated-histories merge, so git blame e2e/… traverses the original commits rather than dead-ending at the import.
  • Keeps e2e/ as a self-contained npm project, deliberately outside the pnpm workspace. The per-package CI matrix selects jobs by pnpm workspace membership, so e2e/ is invisible to it — the suite must not run in the lint/build/test matrix; it needs a live site.
  • Rewires the n env e2e-setup local helper (bin/setup-local-e2e.sh) for the from-scratch provisioning model: the suite now provisions the site itself each run, so the helper no longer resets the DB, loads snapshots, or seeds content — it stands up the env, installs the single-file e2e-plugin, and points .env at the site (newspack-manager and the WooCommerce stack come from the env's ./repos/./plugins mounts). Also fixes a stale build-marker check that force-rebuilt every plugin on every run.
  • Docs: adds an End-to-end section to the root AGENTS.md pointing at e2e/, and ignores the suite's local-only artifacts.

The suite provisions the site from scratch each run (site-setup.sh / e2e-setup.sh) rather than restoring a DB fixture, so there is nothing to drift out of date.

Nightly CI continues to run on TeamCity; pointing its VCS root at this repo (working directory e2e/, build steps unchanged) is a one-time infra step tracked in the issue, not part of this diff.

Part of NPPM-2919.

How to test the changes in this Pull Request:

  1. git blame e2e/tests/donations.spec.ts — history traces into the original newspack-e2e-tests commits, not a single import commit.
  2. Local run: n env e2e-setup <name>, then cd e2e && npm ci && npx playwright install && USE_SETUP=true npx playwright test --project="Vanilla in Desktop Chrome". The setup project provisions the env via e2e-setup.sh; the @vanilla specs pass.
  3. Against a live/staging site (set .env per e2e/.env-sample): npm run test:setup provisions and runs; npm t runs against the current site state.
  4. Confirm the per-package CI matrix on this PR does not spin up any JS/PHP job for e2e/ (it is outside the pnpm workspace).

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Does this pull request include a screenshot or a video showing the intended behavior?
  • Have you written new tests for your changes, as applicable?

chickenn00dle and others added 11 commits February 27, 2026 14:07
This updates reader registration tests to match the new my account experience.
* fix: account for mobile my account links

* fix: copilot feedback
The post editor canvas is rendered inside iframe[name="editor-canvas"]
in modern Gutenberg, so the top-level #editor selector doesn't reach
the homepage-articles block. Also harden a couple of fragile bits:
click the title link (not the block wrapper) so navigation is reliable,
and read h1.entry-title (not any h1) for the captured title.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
WordPress permalinks end with /, so checking for the absence of a
trailing slash never matched and waitForURL hung the test. Wait for
pathname !== '/' (i.e. not the homepage) instead.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The snapshot setup phase (USE_SNAPSHOTS) could not complete on a local
isolated env, for two reasons, both fixed in e2e-reset.sh:

1. The snapshots admin UI is gated by newspack-manager's
   can_do_something_very_serious(), which on a non-proxied env reduces to
   NEWSPACK_MANAGER_ADMIN_USERNAME === current user. The suite logs in as
   admin, so pin the constant to match. On Atomic/staging the a8c-proxy /
   domain-allowlist branch overrides this, so it is a no-op there.

2. Snapshots store site_url() at creation and the load handler refuses to
   ingest a snapshot whose stored URL doesn't match the running site. WP-CLI
   has is_ssl()===false, so site_url() downgrades to http:// even on an https
   env, while the browser-driven load runs over https — a scheme mismatch that
   blocked the load (and silently left the test logged in, hanging the setup).
   Pass --url so WP-CLI reports the site's real scheme. On https staging this
   equals the live value, so it is a no-op there.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Stripe Elements now renders an extra aria-hidden "Secure payment input frame"
(the ACH bank-search results frame) alongside the card input frame, so the
selector matched two elements and failed in strict mode. Exclude hidden frames.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
After staging was updated to WP 7.0, `npm run test:snapshots` failed in
`loadSnapshot`. The snapshots themselves were intact, but two version-mismatch
effects broke the flow:

1. WordPress core was bumped without the schema upgrade running, so
   `wp-admin/admin.php` redirected every admin request to `upgrade.php`. The
   snapshots admin page rendered empty and the test threw "Snapshot not found".
2. Each snapshot's DB dump is captured at the core version it was created on.
   Loading one (created on 6.9) rolls `db_version` back below the running core,
   re-arming the same upgrade redirect. After the load the browser landed on
   `upgrade.php` instead of the login page, so the existing
   `waitForSelector('label:text("Username or Email Address")')` timed out.

Clear any pending DB schema upgrade via `upgrade.php?step=1` (no auth/nonce
required, and a no-op when nothing is pending) both before login and right
after loading a snapshot. The brittle post-load login-label wait is replaced
with a `waitForURL` that accepts either landing page (login or upgrade.php).

Verified end to end: reproduced the failure locally with old-schema snapshots,
then 10/10 desktop+mobile specs pass both locally and against
e2e.newspackstaging.com (WP 7.0).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 24, 2026 13:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@adekbadek
adekbadek force-pushed the nppm-2919-incorporate-e2e-into-workspace branch from 6187468 to 2ce8396 Compare June 24, 2026 13:24
adekbadek and others added 6 commits July 2, 2026 11:06
The CI testing section still described the retired CircleCI setup and its
`SSH_*` variables. The suite now runs on TeamCity against the Atomic
staging site, parameterised by `E2E_*` variables (`E2E_SITE_URL`,
`E2E_WP_USERNAME`/`E2E_WP_PASSWORD`, and `E2E_SSH_HOST`/`E2E_SSH_USER`/
`E2E_SSH_USER_PASS`/`E2E_SSH_KNOWN_HOST`). Document the current variables,
the build steps, and the snapshot/admin-password coupling.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WxF7NnBU1VTBtLGjtC7ewE
The Donations test asserted the modal checkout summary read exactly
"Donate: $15.00 / month". A Newspack update now renders it as
"Donate: Monthly: $15.00 / month" (the cadence label moved into the
summary), so the `has-text` substring no longer matched and the test
timed out waiting for the summary.

Assert on the stable "$15.00 / month" part instead. That label prefix has
already churned once before (see #21), and the amount + cadence is the bit
actually worth checking. Verified end to end against the staging site: the
full donation flow, including "Transaction successful", passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WxF7NnBU1VTBtLGjtC7ewE
setupSite read E2E_SSH_PASS, but the TeamCity build supplies the SSH password as
E2E_SSH_USER_PASS; with it unset, provisioning fell back to key auth and failed.
Standardise on the name TeamCity already uses. Docs note sshpass must be on the
agent PATH.
Point the root AGENTS.md at e2e/ and ignore the suite's local-only
artifacts (test-videos/, .playwright-mcp/).
@adekbadek
adekbadek force-pushed the nppm-2919-incorporate-e2e-into-workspace branch from 2ce8396 to 0cc7f78 Compare July 7, 2026 19:51
adekbadek added 2 commits July 8, 2026 12:05
…NPPM-2919)

The e2e suite now provisions the site itself each run (its setup projects run
e2e-setup.sh / site-setup.sh via npm run test:setup) instead of loading DB
snapshots, so the helper no longer resets the DB or seeds content — it only
stands up the env, installs the e2e helper plugin, and configures .env.

- Default --e2e-repo to the in-repo e2e/ (was a sibling newspack-e2e-tests).
- Drop the e2e-reset.sh run, the snapshot/manager/premium-Woo tolerance, and
  the post-reset permalink re-assertion (provisioning handles all of that now).
- Rely on the env's ./repos and ./plugins mounts for newspack-manager and the
  WooCommerce stack; install only the single-file e2e-plugin here.
- Fix the build-marker check: worktrees are served from /newspack-plugins
  (themes: /newspack-themes), not /newspack-repos, so the old path never matched
  and force-rebuilt every plugin every run. Also point newspack-plugin's marker
  at dist/commons.asset.php (dist/editor.asset.php is no longer emitted).
- Use the correct STRIPE_SECRET_KEY var name the suite reads.
@adekbadek
adekbadek marked this pull request as ready for review July 8, 2026 11:15
@adekbadek
adekbadek requested a review from a team as a code owner July 8, 2026 11:15
@adekbadek
adekbadek merged commit a122acb into main Jul 8, 2026
10 checks passed
@adekbadek
adekbadek deleted the nppm-2919-incorporate-e2e-into-workspace branch July 8, 2026 11:54
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Hey @adekbadek, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label.

If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label.

Thank you! ❤️

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.

7 participants