Skip to content

test: cover the workspace, checkout and lost password flows end to end with playwright - #17

Open
YvesCesar wants to merge 4 commits into
fix/block-checkout-termsfrom
test/e2e-playwright
Open

YvesCesar wants to merge 4 commits into
fix/block-checkout-termsfrom
test/e2e-playwright

Conversation

@YvesCesar

@YvesCesar YvesCesar commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

The PHP suites check the theme hooks one by one, but the flows a customer goes through run in the browser: the WooCommerce checkout block validates in JavaScript, the CPF/CNPJ field is shown or hidden by the theme script, and the lost password page is printed and ends the request with exit. This adds a Playwright suite for those flows.

Flows

  • tests/E2E/Inc/Registration.spec.ts, creating a workspace together with a plan: a visitor without a plan in the cart is sent to choose one; with a plan, the workspace is created and the customer continues to checkout; without the terms consent (the required attribute removed, so the server check runs) the workspace is refused.
  • tests/E2E/Inc/Checkout.spec.ts, the policy consent: the terms text links to the policy, an order without the consent is refused, and with it the order is placed.
  • tests/E2E/Inc/CpfCnpj.spec.ts, the CPF/CNPJ field: shown in Brazil and hidden when the country changes, required in Brazil, and an invalid CPF is refused. The theme script refuses these before the order is sent, so the server check in inc/cpf-cnpj.php stays covered by the integration tests.
  • tests/E2E/Inc/Account.spec.ts, the lost password page: /lost-password/ renders the form on its own page, and the account page links to it.

Setup

  • tests/E2E/docker-compose.yml runs WordPress 7.1 on PHP 8.3 at :8889, with this theme and WooCommerce from vendor/test-plugins, so a composer install comes first. support/setup.sh installs the site, activates the theme, turns on account registration and the check payments gateway, and support/seed.php creates the WooCommerce pages and a "Basic" plan. The seed only runs once, so env:start can be run again.
  • Scripts: test:e2e, test:e2e:ui, env:start, env:stop. Results go to tests/E2E/.results and tests/E2E/.report, both ignored.
  • playwright.yml installs Composer and Node dependencies, starts the stack, runs the suite with the github and HTML reporters, and uploads the report with include-hidden-files: true, since the report folder is hidden.
  • readme.txt says how to run it.

Verification

  • npm run env:start && npm run test:e2e passes: 11 tests. It also passes after env:stop and a fresh start, and when env:start runs again on a started stack.
  • Breaking one rule at a time in the theme makes a spec fail: the checkout consent made optional, the policy link removed, the CPF check in the checkout script, the Brazil-only visibility, the field not registered, the workspace terms validation, the registration shown without a purchase, and the direct lost password route.

…d with playwright

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
…t hides elsewhere

Signed-off-by: YvesCesar <yvesamorim73@gmail.com>
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.

1 participant