@acromedia/integration-tests
Overview
This package contains integration tests for the Gesso's Demo Sites using Playwright.
The tests are designed to run in different environments, such as production, staging, local, and merge request environmnets allowing for robust testing across multiple platforms.
Configuration
Copy the .env.example file to .env and update the values to match your environment.
If you want to run the tests against an MR environment, you can set the TEST_ENVIRONMENT
to match your merge request ID ie: TEST_ENVIRONMENT=mr-1234 and specify the platforms to tests
by setting the TEST_PLATFORMS variable to a comma-separated list of platforms ie: TEST_PLATFORMS=shopify, bigcommerce, drupal-commerce, drupal-commerce-jsonapi.
Test suites
Specs are split by whether they write to the commerce backend.
tests/read-only browses: catalogue listing, sorting, facets and price filters,
content and blog navigation, and metatags. Nothing it does outlives the page, so
any number of pipelines can run it against the same environment at once. This is
the suite CI runs.
tests/stateful writes. account.spec signs in and renames the customer it
signs in as; checkout.spec adds to the cart and drives the checkout flow, which
on some platforms reaches a "Complete Order" button behind a card number;
password-reset.spec requests a password reset and saves the password again from
the emailed link, on the Drupal Commerce platforms only. CI does not run it, and
assertEnvironmentAcceptsWrites refuses to let it start against production.
It is out of CI because its fixtures are shared rather than because the flows do
not matter. TEST_USERNAME is one account for the whole project, so two
pipelines running at once rename the same customer and race each other's
assertions, and nothing puts the store back afterwards. Giving each run its own
customer — registered through /account/create-account and deleted afterwards on
a best-effort basis — is what it needs before it can run unattended, at which
point a nightly job suits it better than a per-merge-request one: the drift it
catches is measured in days, not commits.
Run it by hand against a merge request or staging environment with:
pnpm test:stateful
password-reset.spec reads the reset email from the environment's MailHog. It
needs MAILHOG_URL locally, and MAILHOG_USERNAME and MAILHOG_PASSWORD where
MailHog asks for a login (see example.env). Merge request environments use the
staging MailHog. If MailHog can't be reached or is down, the reset test is
skipped. A wrong login or a missing MAILHOG_URL fails it. The test saves
TEST_PASSWORD again, so the account ends unchanged. Locally, set
TEST_PLATFORMS=drupal-commerce, as the default platforms all point at the same
URL.
Each run of the invalid-link test counts as at least one failed link check
against the Drupal module's limit of 20 per hour per IP address. Over it, Drupal
answers 429 and the tests skip until the hour is up. To iterate locally, raise
validate_limit in gesso_password_reset.settings. The specs share one backend,
one mailbox and one account, and saving a new password ends that account's other
sessions. So pnpm test:stateful uses one worker, and only one run should be
going at a time.
Installation
To install the package and its dependencies, run:
pnpm install
Make sure you have the necessary dependencies installed in your environment to run Playwright tests.
Scripts
pnpm test
Runs the read-only tests in the default environment. Use this when setting TEST_ENVIRONMENT, TEST_PLATFORMS in the .env file.
pnpm test:stateful
Runs the tests that write to the backend. Never runs against production. See
Test suites before reaching for it.
pnpm test:ui
Runs the Playwright tests with the Playwright Test UI. This allows you to run tests interactively, debug, and see detailed test results.
pnpm test:production
Runs the read-only tests in the production environment.
pnpm test:staging
Runs the read-only tests in the staging environment.
pnpm test:local
Runs the read-only tests in the local environment. This is useful for testing against a local server.