Skip to content

test: add a playwright suite for the account and subscription flows - #12

Merged
vitormattos merged 8 commits into
refactor/decision-logic-in-srcfrom
test/e2e-playwright
Sep 18, 2026
Merged

vitormattos merged 8 commits into
refactor/decision-logic-in-srcfrom
test/e2e-playwright

Conversation

@YvesCesar

Copy link
Copy Markdown
Member

The plugin had no browser tests. This adds a Playwright suite over the flows the PHPUnit suite cannot reach, on top of the refactor from #11 (hence the base branch; it retargets to main once #9, #10 and #11 are merged).

The suite

tests/E2E/ mirrors src/ the way tests/Unit/ already does, with .spec.ts in place of Test.php. Fifteen tests in three files, one per class whose behaviour only appears with WooCommerce loaded, the rewrite rules in place and a browser driving them:

  • Account/Navigation.spec.ts — the five entries and their order, the three renamed labels, the endpoint title, the payment methods and the addresses merged into the billing screen, the redirect from the standalone addresses list, the highlighting while an address is edited, and the Nextcloud CTA.
  • Account/RootEndpoint.spec.ts — /orders/, /payment-methods/ and /lost-password/ answering from the site root instead of being collapsed back to the front page by a canonical redirect, and /my-account/ still working as an alias.
  • Subscription/StatusChange.spec.ts — cancelling from the account: the prompt instead of the cancellation, backing out, and confirming.

The site under test

The suite drives a WordPress that is already up, named by WP_BASE_URL and WP_CLI. The defaults are the local SaaS stack, so npm run test:e2e takes no arguments there.

tests/E2E/support/seed.php describes the preconditions — My Account as the front page, a customer with a known password, an active subscription — and is applied through wp eval-file -, reading the script from stdin so no path has to line up between host and container. It runs again before each test that changes the subscription, and it leaves the customer's password alone when it already matches, which is what keeps the browser session alive across a reseed.

.wp-env.json describes a disposable site with the same three plugins, which is what the new e2e.yml workflow runs. Two differences from the local stack had to be spelled out there:

  • WooCommerce only offers the billing screen when an available gateway keeps payment methods. The local stack has Stripe; .wp-env.json maps a mu-plugin that declares one.
  • wp-env serves through Apache, so the rewrite rules need a .htaccess. The seed asks WP-CLI for a hard flush, which writes it.

Two things worth pointing out

  • Confirming a cancellation leaves the subscription in pending-cancel, not cancelled: WooCommerce Subscriptions honours the term already paid for. The test asserts what the software does, and the prompt the plugin shows is the one the customer sees before that happens.
  • tests/E2E/support/*.php is excluded from PHPStan. Both files run inside a WordPress that has WooCommerce Subscriptions and WP-CLI loaded, and there are no stubs for either. PHPCS and parallel-lint still cover them, and every E2E run exercises them.

Verification

The suite is green in both environments: 15 passed against the local stack, and 15 passed against wp-env with WP_BASE_URL=http://localhost:8888 WP_CLI="npx wp-env run cli wp". composer ci is still green — 239 PHPUnit tests, no lint, PHPCS or PHPStan findings.

@YvesCesar
YvesCesar marked this pull request as draft September 15, 2026 22:06
@YvesCesar
YvesCesar marked this pull request as ready for review September 16, 2026 22:13
Comment thread .github/workflows/e2e.yml Outdated
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
@vitormattos
vitormattos merged commit a553fcf into refactor/decision-logic-in-src Sep 18, 2026
12 checks passed
@vitormattos
vitormattos deleted the test/e2e-playwright branch September 18, 2026 20:39
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.

2 participants