From f0cbb65e77e4681be975c71c47250ac7d90a4103 Mon Sep 17 00:00:00 2001 From: Marcel Martinez Date: Wed, 4 Nov 2026 22:19:11 -0600 Subject: [PATCH 01/10] feat(warden): serve the environment for browser-based tests The Warden environment already brings up nginx, Varnish and Traefik, but nothing installed into it is reachable from the runner itself. Integration tests never noticed, because they drive Magento's own bootstrap rather than making HTTP requests. Three things have to be true before a browser can reach the storefront, and each is added here behind a default that preserves current behaviour: - setup:install needs --base-url, or Magento redirects to its default base URL regardless of where the environment is served - the Traefik hostname needs resolving on the runner, which has no dnsmasq - static content needs deploying, or the storefront returns 200 and renders nothing Also exposes the served URL as an output, so a caller does not have to reconstruct it, and makes the admin frontName and the Warden environment naming configurable rather than hardcoded -- a predictable admin URL is a prerequisite for testing the admin at all. Existing callers pass none of the new inputs and are unaffected. --- warden/setup-environment/README.md | 84 +++++++++++++++++++++ warden/setup-environment/action.yml | 111 +++++++++++++++++++++++++++- 2 files changed, 191 insertions(+), 4 deletions(-) create mode 100644 warden/setup-environment/README.md diff --git a/warden/setup-environment/README.md b/warden/setup-environment/README.md new file mode 100644 index 00000000..77aaa131 --- /dev/null +++ b/warden/setup-environment/README.md @@ -0,0 +1,84 @@ +# Setup Mage-OS in Warden + +Brings up a full Mage-OS service stack on the runner using +[Warden](https://github.com/wardenenv/warden), and optionally installs Magento +into it. + +Used by [`full-integration-tests.yaml`](../../.github/workflows/full-integration-tests.yaml) +and [`nx-integration-tests.yml`](../../.github/workflows/nx-integration-tests.yml). + +## Usage + +```yaml +- uses: mage-os/github-actions/warden/setup-environment@main + with: + php_version: '8.4' + database: 'mariadb:11.4' + search: 'opensearch:3.3' + run_composer_install: '1' + run_setup_install: '1' +``` + +### Browser-based tests + +PHPUnit suites drive Magento's own bootstrap and never make an HTTP request, so +they need nothing beyond the above. A browser does. Three things have to be true +before one can reach the storefront, and all three are off by default: + +```yaml +- uses: mage-os/github-actions/warden/setup-environment@main + id: warden + with: + php_version: '8.4' + run_composer_install: '1' + run_setup_install: '1' + # Install on the URL the environment is actually served on, otherwise + # Magento redirects the browser to its default base URL. + base_url: 'https://app.mageos.test/' + # Warden uses dnsmasq locally; a runner has no such resolver. + configure_host_resolution: '1' + # Without deployed static content the storefront returns 200 and renders + # nothing. + run_static_content_deploy: '1' + static_content_themes: 'Magento/luma' + +- run: npx playwright test + env: + E2E_BASE_URL: ${{ steps.warden.outputs.base_url }} +``` + +## Inputs + +| Name | Default | Description | +| --- | --- | --- | +| `warden_version` | `0.14.2` | Warden version to use. | +| `php_version` | `8.2` | PHP version in the Warden containers. | +| `composer_version` | `2.2.22` | Composer version to use. | +| `database` | `mariadb:10.6` | `distribution:version` of the database. | +| `search` | `opensearch:2.5` | Search engine; `elasticsearch:*` or `opensearch:*`. | +| `varnish` | `varnish:7.3` | Varnish version, or `null` to disable. | +| `rabbitmq` | `rabbitmq:3.11` | RabbitMQ version, or `null` to disable. | +| `redis` | `redis:7.0` | Redis version, or `null` to disable. | +| `base_directory` | `./` | Base directory of the Mage-OS codebase. | +| `run_composer_install` | `0` | Run `composer install`. | +| `run_setup_install` | `0` | Run `setup:install`. | +| `run_setup_upgrade` | `0` | Run `setup:upgrade`. | +| `run_reindex` | `0` | Run `indexer:reindex`. | +| `run_production_deploy_mode` | `0` | Run `deploy:mode:set production`. | +| `run_magento_config_preset` | `0` | Apply the test-oriented config preset. | +| `run_admin_user_creation` | `0` | Create an `admin` / `abcABC123` user. | +| `env_name` | `mageos` | `WARDEN_ENV_NAME`. | +| `traefik_domain` | `mageos.test` | `TRAEFIK_DOMAIN`. | +| `traefik_subdomain` | `app` | `TRAEFIK_SUBDOMAIN`. | +| `backend_frontname` | `admin` | Admin frontName passed to `setup:install`. | +| `base_url` | *(empty)* | Passed as `--base-url` with `--use-rewrites=1`. Empty leaves Magento's default. | +| `configure_host_resolution` | `0` | Resolve `.` to `127.0.0.1` on the runner. | +| `run_static_content_deploy` | `0` | Run `setup:static-content:deploy`. | +| `static_content_languages` | `en_US` | Space separated locales to deploy. | +| `static_content_themes` | *(empty)* | Space separated themes, e.g. `Magento/luma`. Empty deploys every theme. | + +## Outputs + +| Name | Description | +| --- | --- | +| `base_url` | The URL the environment is served on, derived from `traefik_subdomain` and `traefik_domain`. | diff --git a/warden/setup-environment/action.yml b/warden/setup-environment/action.yml index f38b9e8b..275259f2 100644 --- a/warden/setup-environment/action.yml +++ b/warden/setup-environment/action.yml @@ -83,6 +83,56 @@ inputs: default: "./" description: "Base directory for the Mage-OS codebase." + env_name: + required: false + default: "mageos" + description: "Warden environment name (WARDEN_ENV_NAME)." + + traefik_domain: + required: false + default: "mageos.test" + description: "Traefik domain the environment is served on (TRAEFIK_DOMAIN)." + + traefik_subdomain: + required: false + default: "app" + description: "Traefik subdomain the environment is served on (TRAEFIK_SUBDOMAIN)." + + backend_frontname: + required: false + default: "admin" + description: "Admin frontName passed to setup:install. Pinning this keeps the admin URL predictable, which browser-based tests need." + + base_url: + required: false + default: "" + description: "Base URL passed to setup:install as --base-url. Empty leaves Magento's default, which is what non-browser test suites want." + + configure_host_resolution: + required: false + default: "0" + description: "Whether to resolve the Traefik hostname on the runner itself, so tools outside the containers (a browser, curl) can reach the store." + + run_static_content_deploy: + required: false + default: "0" + description: "Whether to run setup:static-content:deploy. Required before a browser can render the storefront; pointless for PHPUnit suites." + + static_content_languages: + required: false + default: "en_US" + description: "Space separated locales to deploy static content for." + + static_content_themes: + required: false + default: "" + description: "Space separated themes to deploy static content for, e.g. 'Magento/luma'. Empty deploys every theme, which is considerably slower." + +outputs: + base_url: + description: "The URL the environment is served on, for callers that need to point a browser at it." + value: ${{ steps.resolve-base-url.outputs.base_url }} + runs: using: composite steps: @@ -104,6 +154,9 @@ runs: VARNISH: ${{ inputs.varnish }} RABBITMQ: ${{ inputs.rabbitmq }} REDIS: ${{ inputs.redis }} + ENV_NAME: ${{ inputs.env_name }} + TRAEFIK_DOMAIN_INPUT: ${{ inputs.traefik_domain }} + TRAEFIK_SUBDOMAIN_INPUT: ${{ inputs.traefik_subdomain }} run: | # Splitting database input to distribution and version DB_DISTRIBUTION=${DATABASE%%:*} @@ -149,12 +202,12 @@ runs: # Creating .env file by substituting variables directly in the template cat << EOF > .env - WARDEN_ENV_NAME=mageos + WARDEN_ENV_NAME=${ENV_NAME} WARDEN_ENV_TYPE=magento2 WARDEN_WEB_ROOT=/ - TRAEFIK_DOMAIN=mageos.test - TRAEFIK_SUBDOMAIN=app + TRAEFIK_DOMAIN=${TRAEFIK_DOMAIN_INPUT} + TRAEFIK_SUBDOMAIN=${TRAEFIK_SUBDOMAIN_INPUT} WARDEN_DB=1 WARDEN_ELASTICSEARCH=${WARDEN_ELASTICSEARCH} @@ -196,6 +249,15 @@ runs: echo ".env created" cat .env + - name: Resolve served base URL + id: resolve-base-url + shell: bash + env: + TRAEFIK_DOMAIN_INPUT: ${{ inputs.traefik_domain }} + TRAEFIK_SUBDOMAIN_INPUT: ${{ inputs.traefik_subdomain }} + run: | + echo "base_url=https://${TRAEFIK_SUBDOMAIN_INPUT}.${TRAEFIK_DOMAIN_INPUT}/" >> "$GITHUB_OUTPUT" + - name: Warden svc up && Warden env up working-directory: ${{ inputs.base_directory }} shell: bash @@ -211,6 +273,18 @@ runs: export WARDEN="$(dirname $(pwd))/warden/bin/warden" ${WARDEN} env exec -T php-fpm sudo chmod -R 777 . + - name: Resolve the Traefik hostname on the runner + if: ${{ inputs.configure_host_resolution == '1' }} + shell: bash + env: + HOSTNAME_TO_RESOLVE: ${{ inputs.traefik_subdomain }}.${{ inputs.traefik_domain }} + run: | + # Warden relies on dnsmasq locally; a runner has no such resolver, so + # anything running outside the containers -- a browser, curl -- cannot + # reach the store without this. + echo "127.0.0.1 ${HOSTNAME_TO_RESOLVE}" | sudo tee -a /etc/hosts + getent hosts "${HOSTNAME_TO_RESOLVE}" + - name: Wait for environment to be ready working-directory: ${{ inputs.base_directory }} shell: bash @@ -263,6 +337,8 @@ runs: RABBITMQ: ${{ inputs.rabbitmq }} VARNISH: ${{ inputs.varnish }} RUN_SETUP_INSTALL: ${{ inputs.run_setup_install }} + BACKEND_FRONTNAME: ${{ inputs.backend_frontname }} + BASE_URL: ${{ inputs.base_url }} run: | if [ $RUN_SETUP_INSTALL == "1" ]; then SEARCH_ENGINE_VERSION=${SEARCH##*:} @@ -291,7 +367,13 @@ runs: esac declare -a PARAMETERS - PARAMETERS+=(--backend-frontname=admin --db-host=db --db-name=magento --db-user=magento --db-password=magento) + PARAMETERS+=(--backend-frontname=${BACKEND_FRONTNAME} --db-host=db --db-name=magento --db-user=magento --db-password=magento) + + # Magento otherwise installs on its default base URL, which a browser + # pointed at the Traefik hostname would be redirected away from. + if [[ -n $BASE_URL ]]; then + PARAMETERS+=(--base-url=${BASE_URL} --use-rewrites=1) + fi if [[ -n $REDIS ]]; then PARAMETERS+=(--session-save=redis --session-save-redis-host=redis --session-save-redis-port=6379 --session-save-redis-db=2 --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0 --cache-backend-redis-port=6379 --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=1 --page-cache-redis-port=6379) @@ -374,6 +456,27 @@ runs: echo "Skipping deploy:mode:set production" fi + - name: Deploy static content + working-directory: ${{ inputs.base_directory }} + shell: bash + env: + LANGUAGES: ${{ inputs.static_content_languages }} + THEMES: ${{ inputs.static_content_themes }} + run: | + if [ ${{ inputs.run_static_content_deploy }} == "1" ]; then + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + declare -a DEPLOY_ARGS + DEPLOY_ARGS+=(${LANGUAGES}) + DEPLOY_ARGS+=(-f) + # Deploying every theme costs minutes a browser test does not need. + for THEME in ${THEMES}; do + DEPLOY_ARGS+=(--theme "${THEME}") + done + ${WARDEN} env exec -T php-fpm bin/magento setup:static-content:deploy "${DEPLOY_ARGS[@]}" + else + echo "Skipping setup:static-content:deploy" + fi + - name: Run Magento Re-indexation working-directory: ${{ inputs.base_directory }} shell: bash From 291691ca2e8e57b2b08f6878c7e12f6bbc284b47 Mon Sep 17 00:00:00 2001 From: Marcel Martinez Date: Thu, 5 Nov 2026 08:16:35 -0600 Subject: [PATCH 02/10] test(e2e): run a storefront smoke test against the Warden environment Adds the canary for the browser-serving inputs on warden/setup-environment: it installs Mage-OS, serves it, deploys Luma's static content and drives a browser at the result, following the _internal-* convention the other actions in this repository use. The suite lives with the demo package, as the dummy e2e test already did. It stays deliberately small: its job is to prove a storefront is being served, not to cover a store's behaviour. The assertions are chosen to fail against things that should not pass. A 200 is not evidence of a storefront -- the admin login page, a CMS no-route page and a Magento error page all answer 200 with a header, a footer and a title -- so the suite checks the resolved route in the body class, Luma's minicart block and whether a stylesheet actually parsed into rules. Without the last one it would pass against a store whose pub/static was never deployed. The suite now refuses to start without PLAYWRIGHT_BASE_URL rather than falling back to a public demo store, since a suite that reports green about a store nobody asked about is worse than one that will not run. --- .github/workflows/_internal-e2e.yaml | 121 ++++++++++++++++++ _test/demo-package/Test/e2e/.env | 1 - _test/demo-package/Test/e2e/.env.example | 3 + _test/demo-package/Test/e2e/.gitignore | 4 + _test/demo-package/Test/e2e/README.md | 46 ++++++- .../Test/e2e/hello-magento.spec.ts | 50 +++++--- _test/demo-package/Test/e2e/package-lock.json | 77 +++++++++++ _test/demo-package/Test/e2e/package.json | 13 ++ .../Test/e2e/playwright.config.ts | 33 ++++- 9 files changed, 326 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/_internal-e2e.yaml delete mode 100644 _test/demo-package/Test/e2e/.env create mode 100644 _test/demo-package/Test/e2e/.env.example create mode 100644 _test/demo-package/Test/e2e/.gitignore create mode 100644 _test/demo-package/Test/e2e/package-lock.json create mode 100644 _test/demo-package/Test/e2e/package.json diff --git a/.github/workflows/_internal-e2e.yaml b/.github/workflows/_internal-e2e.yaml new file mode 100644 index 00000000..894fd704 --- /dev/null +++ b/.github/workflows/_internal-e2e.yaml @@ -0,0 +1,121 @@ +name: E2E Test + +on: + workflow_dispatch: {} + push: + branches: + - main + paths: + - "_test/demo-package/Test/e2e/**" + - "warden/**" + - "setup-magento/**" + - ".github/workflows/_internal-e2e.yaml" + - "!(**/*.md)" + pull_request: + branches: + - main + paths: + - "_test/demo-package/Test/e2e/**" + - "warden/**" + - "setup-magento/**" + - ".github/workflows/_internal-e2e.yaml" + - "!(**/*.md)" + +# Standing up the whole stack costs a runner for a while; there is no reason to +# keep paying for a run whose commit has already been superseded. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + storefront-smoke-test: + name: "storefront smoke test" + if: "!startsWith(github.head_ref, 'release-please')" + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + # setup:install, the hostname the runner resolves and the URL the browser + # opens all have to agree, so they are derived from one place. + TRAEFIK_DOMAIN: mageos.test + TRAEFIK_SUBDOMAIN: app + E2E_DIRECTORY: _test/demo-package/Test/e2e + # Pinned rather than taken from supported-version: this workflow is here + # to tell us whether the action still serves a store, so a service bump + # elsewhere should not change what it reports. The release pipeline picks + # its own versions. + PHP_VERSION: "8.4" + COMPOSER_VERSION: "2.10.2" + steps: + - uses: actions/checkout@v6 + + # mode: extension is how the other internal workflows get a project onto + # disk -- composer create-project --no-install, into ./_ghamagento. The + # dependencies are then installed inside the container, by the PHP version + # that will serve them. + - name: Create the Mage-OS project + uses: ./setup-magento + with: + php-version: ${{ env.PHP_VERSION }} + tools: "composer:v2" + mode: extension + magento_repository: "https://repo.mage-os.org/" + magento_version: "mage-os/project-community-edition:4.0.0" + + - name: Serve the store in Warden + id: warden + uses: ./warden/setup-environment + with: + base_directory: "./_ghamagento" + php_version: ${{ env.PHP_VERSION }} + composer_version: ${{ env.COMPOSER_VERSION }} + database: "mariadb:11.8" + search: "opensearch:3.4" + rabbitmq: "rabbitmq:4.2" + redis: "redis:7.4" + varnish: "varnish:8.0" + run_composer_install: 1 + run_setup_install: 1 + run_admin_user_creation: 1 + run_magento_config_preset: 1 + run_reindex: 1 + traefik_domain: ${{ env.TRAEFIK_DOMAIN }} + traefik_subdomain: ${{ env.TRAEFIK_SUBDOMAIN }} + # The three inputs a browser needs, and nothing a PHPUnit suite pays for. + base_url: "https://${{ env.TRAEFIK_SUBDOMAIN }}.${{ env.TRAEFIK_DOMAIN }}/" + configure_host_resolution: 1 + run_static_content_deploy: 1 + static_content_themes: "Magento/luma" + + # Separate from the test run so that "the store was never reachable" and + # "the store rendered the wrong thing" are different red steps. + - name: Confirm the store answers on the resolved hostname + run: curl --silent --show-error --fail --insecure --head "${{ steps.warden.outputs.base_url }}" | head -1 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: ${{ env.E2E_DIRECTORY }}/package-lock.json + + - name: Install Playwright + working-directory: ${{ env.E2E_DIRECTORY }} + run: | + npm ci + npx playwright install --with-deps chromium + + - name: Run the storefront smoke test + working-directory: ${{ env.E2E_DIRECTORY }} + env: + PLAYWRIGHT_BASE_URL: ${{ steps.warden.outputs.base_url }} + run: npx playwright test + + - name: Upload the Playwright report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: playwright-report + path: | + ${{ env.E2E_DIRECTORY }}/playwright-report + ${{ env.E2E_DIRECTORY }}/test-results + retention-days: 7 + if-no-files-found: ignore diff --git a/_test/demo-package/Test/e2e/.env b/_test/demo-package/Test/e2e/.env deleted file mode 100644 index d0f3f161..00000000 --- a/_test/demo-package/Test/e2e/.env +++ /dev/null @@ -1 +0,0 @@ -PLAYWRIGHT_BASE_URL=https://hyva-demo.elgentos.io/ diff --git a/_test/demo-package/Test/e2e/.env.example b/_test/demo-package/Test/e2e/.env.example new file mode 100644 index 00000000..735dc1a9 --- /dev/null +++ b/_test/demo-package/Test/e2e/.env.example @@ -0,0 +1,3 @@ +# The store the suite opens. There is no default: a suite that silently tests +# someone else's demo store is worse than one that refuses to start. +PLAYWRIGHT_BASE_URL=https://app.mageos.test/ diff --git a/_test/demo-package/Test/e2e/.gitignore b/_test/demo-package/Test/e2e/.gitignore new file mode 100644 index 00000000..3c3e172c --- /dev/null +++ b/_test/demo-package/Test/e2e/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +playwright-report/ +test-results/ +.env diff --git a/_test/demo-package/Test/e2e/README.md b/_test/demo-package/Test/e2e/README.md index 36c8d271..76e1df29 100644 --- a/_test/demo-package/Test/e2e/README.md +++ b/_test/demo-package/Test/e2e/README.md @@ -1,5 +1,41 @@ -cd e2e -npm install -D @playwright/test -npx playwright install -npm install -D dotenv -npx playwright test hello-magento.spec.ts +# Storefront smoke test + +A deliberately small Playwright suite whose only job is to prove that a Mage-OS +storefront is **being served** -- installed, reachable over HTTP(S) and +rendering with its static content deployed. + +It is the canary for [`warden/setup-environment`](../../../../warden/setup-environment): +`.github/workflows/_internal-e2e.yaml` stands a store up with that action on +every change to it and runs this suite against the result. + +It is not a test suite for a store's behaviour. Product, cart and checkout +coverage belongs in a suite of its own, with its own fixtures. + +## Running it against a store + +```bash +cp .env.example .env # then point PLAYWRIGHT_BASE_URL at your store +npm ci +npx playwright install --with-deps chromium +npm test +``` + +There is no default base URL. A suite that silently falls back to some public +demo store reports green about a store nobody asked about. + +## Why the assertions look like that + +A `200` is not evidence of a storefront. The admin login page, a CMS no-route +page and a Magento error page all answer `200`, and all of them have a header, +a footer, a `` and no console errors. So each assertion here is one that +fails against something that should not pass: + +| Assertion | What it rejects | +| --- | --- | +| `body` has `cms-index-index` | Any other route answering 200 -- `/admin`, a 404 CMS page | +| `[data-block="minicart"]` is attached | A storefront page rendered without the Luma layout | +| A stylesheet parsed into CSS rules | A store whose `pub/static` was never deployed | + +Before changing an assertion, check that it still fails for the reason it was +written -- point `PLAYWRIGHT_BASE_URL` at the admin URL, or clear `pub/static`, +and watch the step go red. diff --git a/_test/demo-package/Test/e2e/hello-magento.spec.ts b/_test/demo-package/Test/e2e/hello-magento.spec.ts index 37762363..5de89855 100644 --- a/_test/demo-package/Test/e2e/hello-magento.spec.ts +++ b/_test/demo-package/Test/e2e/hello-magento.spec.ts @@ -1,20 +1,40 @@ import { test, expect } from '@playwright/test'; -test.describe('Page health checks', () => { - test('Homepage_returns_200', {tag: ['@smoke', '@cold']}, async ({page}) => { - const homepageURL = process.env.PLAYWRIGHT_BASE_URL || process.env.BASE_URL; - if (!homepageURL) { - throw new Error("PLAYWRIGHT_BASE_URL has not been defined in the .env file."); - } +// A 200 proves very little on its own: the admin login page, a CMS no-route +// page and a Magento error page all answer 200 and all carry a header, a +// footer and a title. Every assertion below is here because it fails on +// something a storefront check should not accept. +test.describe('Storefront smoke test', () => { + test('serves the Luma homepage with its static content deployed', { tag: ['@smoke', '@cold'] }, async ({ page }) => { + const response = await page.goto('/'); - const homepageResponsePromise = page.waitForResponse(homepageURL); - await page.goto(homepageURL); - const homepageResponse = await homepageResponsePromise; - expect(homepageResponse.status(), 'Homepage should return 200').toBe(200); + await test.step('the homepage responds 200', async () => { + expect(response?.status(), 'the homepage should respond 200').toBe(200); + }); - const pageTtitle = page.getByRole('heading', {level: 1}) + await test.step('the response is the storefront homepage, not some other 200', async () => { + // Luma puts the resolved route in the body class, which is the + // cheapest way to tell the homepage apart from /admin or a 404. + await expect(page.locator('body')).toHaveClass(/cms-index-index/); + await expect(page.locator('[data-block="minicart"]')).toBeAttached(); + }); - await expect(pageTtitle, 'Homepage has a visible title').toBeVisible(); - await expect(pageTtitle).toHaveText(/\S+/); - }) -}) + await test.step('static content is deployed', async () => { + await expect(page.locator('link[rel="stylesheet"]').first()).toBeAttached(); + + // A stylesheet that 404s is still a link element, so ask the + // browser whether any of them parsed into rules. Without this the + // test passes against a store whose pub/static is empty. + const ruleCount = await page.evaluate(() => + Array.from(document.styleSheets).reduce((total, sheet) => { + try { + return total + sheet.cssRules.length; + } catch { + return total; + } + }, 0), + ); + expect(ruleCount, 'at least one stylesheet should have loaded').toBeGreaterThan(0); + }); + }); +}); diff --git a/_test/demo-package/Test/e2e/package-lock.json b/_test/demo-package/Test/e2e/package-lock.json new file mode 100644 index 00000000..363816ae --- /dev/null +++ b/_test/demo-package/Test/e2e/package-lock.json @@ -0,0 +1,77 @@ +{ + "name": "demo-package-e2e", + "version": "0.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "demo-package-e2e", + "version": "0.0.0", + "devDependencies": { + "@playwright/test": "1.64.1", + "dotenv": "^18.0.9" + } + }, + "node_modules/@playwright/test": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz", + "integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.64.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/dotenv": { + "version": "18.0.9", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-18.0.9.tgz", + "integrity": "sha512-3fVOW4cB02R066PUSwn8O4TJyz9NckQl7F81blIbaq9jKBm2tSmOKky7ZHIXzGvkVPXCSn6jkpziBPZdGFs8Tw==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "dotenv": "dist/index.cjs" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/playwright": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.64.1.tgz", + "integrity": "sha512-HCrVhHr5QQuwYoswEUGTb7gGp522yflbv/ST8nF4sFWGuLjQCt17Q/EubpGGSNKYn1tsTCPZxqHhHCfVURu7UA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.64.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/playwright-core": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.64.1.tgz", + "integrity": "sha512-BC4s8y6SEVA6Q1rSxZTto8hI1KUI3xXlHGZgvGqP4IqPdI/a6FX9H29IDNz7vKo9l21b6LfYosScPL6M3xxyDQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + } + } +} diff --git a/_test/demo-package/Test/e2e/package.json b/_test/demo-package/Test/e2e/package.json new file mode 100644 index 00000000..65e5465a --- /dev/null +++ b/_test/demo-package/Test/e2e/package.json @@ -0,0 +1,13 @@ +{ + "name": "demo-package-e2e", + "version": "0.0.0", + "private": true, + "description": "Minimal Playwright suite proving a Mage-OS storefront is actually served.", + "scripts": { + "test": "playwright test" + }, + "devDependencies": { + "@playwright/test": "1.64.1", + "dotenv": "^18.0.9" + } +} diff --git a/_test/demo-package/Test/e2e/playwright.config.ts b/_test/demo-package/Test/e2e/playwright.config.ts index a71c8359..fc1f2550 100644 --- a/_test/demo-package/Test/e2e/playwright.config.ts +++ b/_test/demo-package/Test/e2e/playwright.config.ts @@ -1,8 +1,39 @@ -import { defineConfig } from '@playwright/test'; +import { defineConfig, devices } from '@playwright/test'; import dotenv from 'dotenv'; dotenv.config(); +const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? process.env.BASE_URL; + +if (!baseURL) { + throw new Error( + 'No store to test: set PLAYWRIGHT_BASE_URL, e.g. https://app.mageos.test/ (see .env.example).', + ); +} + export default defineConfig({ testDir: '.', + // A cold Magento page can take a while on a shared runner; everything here + // is deliberately slower than a Playwright default. + timeout: 120_000, + expect: { timeout: 20_000 }, + workers: 1, + fullyParallel: false, + forbidOnly: !!process.env.CI, + retries: process.env.CI ? 1 : 0, + reporter: process.env.CI + ? [['github'], ['list'], ['html', { open: 'never' }]] + : [['list'], ['html', { open: 'never' }]], + use: { + baseURL, + // Warden serves the environment under its own certificate authority, + // which is not installed on a GitHub runner. + ignoreHTTPSErrors: true, + navigationTimeout: 90_000, + actionTimeout: 20_000, + trace: 'on-first-retry', + screenshot: 'only-on-failure', + video: 'retain-on-failure', + }, + projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }], }); From 8971c3d773c005d686dfb04d230120860fb60c67 Mon Sep 17 00:00:00 2001 From: Marcel Martinez <martinezlopezmarcel@gmail.com> Date: Thu, 5 Nov 2026 08:24:11 -0600 Subject: [PATCH 03/10] test(e2e): check this repository out into a subdirectory The first run failed in the post phase of the Warden step: the local action could no longer be found. warden/setup-environment checks the Warden CLI out into warden/ at the workspace root, which is exactly where this repository keeps that action, so the checkout landed on top of it. Checking the repository out into actions/ leaves the workspace root free for the Warden CLI, which the steps reach as $(dirname $(pwd))/warden/bin/warden. --- .github/workflows/_internal-e2e.yaml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/_internal-e2e.yaml b/.github/workflows/_internal-e2e.yaml index 894fd704..a7984863 100644 --- a/.github/workflows/_internal-e2e.yaml +++ b/.github/workflows/_internal-e2e.yaml @@ -38,7 +38,7 @@ jobs: # opens all have to agree, so they are derived from one place. TRAEFIK_DOMAIN: mageos.test TRAEFIK_SUBDOMAIN: app - E2E_DIRECTORY: _test/demo-package/Test/e2e + E2E_DIRECTORY: actions/_test/demo-package/Test/e2e # Pinned rather than taken from supported-version: this workflow is here # to tell us whether the action still serves a store, so a service bump # elsewhere should not change what it reports. The release pipeline picks @@ -46,14 +46,19 @@ jobs: PHP_VERSION: "8.4" COMPOSER_VERSION: "2.10.2" steps: + # Not at the workspace root: warden/setup-environment checks the Warden + # CLI out into warden/ there, which is where this repository keeps that + # action, and the checkout would land on top of it. - uses: actions/checkout@v6 + with: + path: actions # mode: extension is how the other internal workflows get a project onto # disk -- composer create-project --no-install, into ./_ghamagento. The # dependencies are then installed inside the container, by the PHP version # that will serve them. - name: Create the Mage-OS project - uses: ./setup-magento + uses: ./actions/setup-magento with: php-version: ${{ env.PHP_VERSION }} tools: "composer:v2" @@ -63,7 +68,7 @@ jobs: - name: Serve the store in Warden id: warden - uses: ./warden/setup-environment + uses: ./actions/warden/setup-environment with: base_directory: "./_ghamagento" php_version: ${{ env.PHP_VERSION }} From 100535d4453480a7ad7bb38a4df8ecb02a06b6dc Mon Sep 17 00:00:00 2001 From: Marcel Martinez <martinezlopezmarcel@gmail.com> Date: Thu, 5 Nov 2026 10:52:01 -0600 Subject: [PATCH 04/10] docs(e2e): correct how to verify an assertion still bites The README told the reader to point PLAYWRIGHT_BASE_URL at the admin URL and watch the test go red. It does not go red: page.goto("/") resolves against the origin and drops the path, so the run hits the homepage again and passes -- the exact vacuous green this suite exists to refuse. Replacing it with a throwaway spec that navigates to the admin path directly, and the output it produces against a real store. --- _test/demo-package/Test/e2e/README.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/_test/demo-package/Test/e2e/README.md b/_test/demo-package/Test/e2e/README.md index 76e1df29..cd5d0eda 100644 --- a/_test/demo-package/Test/e2e/README.md +++ b/_test/demo-package/Test/e2e/README.md @@ -37,5 +37,28 @@ fails against something that should not pass: | A stylesheet parsed into CSS rules | A store whose `pub/static` was never deployed | Before changing an assertion, check that it still fails for the reason it was -written -- point `PLAYWRIGHT_BASE_URL` at the admin URL, or clear `pub/static`, -and watch the step go red. +written. Do that with a throwaway spec, not by repointing `PLAYWRIGHT_BASE_URL` +at the admin URL: a base URL with a path in it will not do what you expect, +because `page.goto("/")` resolves against the origin and drops the path, so you +end up testing the homepage again and watching it pass. + +```ts +// negative-control.spec.ts -- delete it afterwards +import { test, expect } from "@playwright/test"; + +test("the admin login page must not satisfy the homepage assertions", async ({ page }) => { + const response = await page.goto("/admin"); // your backend frontName + expect(response?.status()).toBe(200); // it answers 200 -- that is the point + await expect(page.locator("body")).toHaveClass(/cms-index-index/); +}); +``` + +Against a real store that fails on the body class alone, with the 200 and the +stylesheets both satisfied: + +``` +Expected pattern: /cms-index-index/ +Received string: "m137-admin-theme adminhtml-auth-login page-layout-admin-login" +``` + +For the static content assertion, clear `pub/static` and reload. From fed2ea69257bebbd3eae4cc99d3beb73f16dd304 Mon Sep 17 00:00:00 2001 From: Marcel Martinez <martinezlopezmarcel@gmail.com> Date: Thu, 5 Nov 2026 11:19:04 -0600 Subject: [PATCH 05/10] test(e2e): keep the evidence from the first failure trace: on-first-retry only produces a trace once a test has failed and been retried. A gate that fails is read by someone deciding whether to ship, and "re-run it and watch" is not an answer at that point, so the first failure now carries its own trace. Report artifacts are kept for 30 days rather than 7, long enough to outlive a release weekend. --- .github/workflows/_internal-e2e.yaml | 2 +- _test/demo-package/Test/e2e/playwright.config.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_internal-e2e.yaml b/.github/workflows/_internal-e2e.yaml index a7984863..3dea4c20 100644 --- a/.github/workflows/_internal-e2e.yaml +++ b/.github/workflows/_internal-e2e.yaml @@ -122,5 +122,5 @@ jobs: path: | ${{ env.E2E_DIRECTORY }}/playwright-report ${{ env.E2E_DIRECTORY }}/test-results - retention-days: 7 + retention-days: 30 if-no-files-found: ignore diff --git a/_test/demo-package/Test/e2e/playwright.config.ts b/_test/demo-package/Test/e2e/playwright.config.ts index fc1f2550..eed3cadf 100644 --- a/_test/demo-package/Test/e2e/playwright.config.ts +++ b/_test/demo-package/Test/e2e/playwright.config.ts @@ -31,7 +31,11 @@ export default defineConfig({ ignoreHTTPSErrors: true, navigationTimeout: 90_000, actionTimeout: 20_000, - trace: 'on-first-retry', + // retain-on-failure, not on-first-retry: the first failure is the one + // that has to carry its own evidence. A release gate that fails is + // read by someone deciding whether to ship, and "re-run it and watch" + // is not an answer at that point. + trace: 'retain-on-failure', screenshot: 'only-on-failure', video: 'retain-on-failure', }, From 99b519e2e3b3d27cbebe0042f17b2a89f94dd93f Mon Sep 17 00:00:00 2001 From: Marcel Martinez <martinezlopezmarcel@gmail.com> Date: Mon, 9 Nov 2026 21:44:46 -0600 Subject: [PATCH 06/10] test(e2e): place a guest order against the served store The homepage check proves a store is served. It does not prove a store can take money. This walks the deepest path a storefront check can: category listing, product page, cart, shipping address, rate selection, payment, order. It touches the price index, the quote, the shipping and payment method pools, order placement, and the private-content sections Varnish has to punch holes for. That path needs a salable product, which a bare setup:install does not have. fixtures/mageos-e2e.xml seeds the least data it takes: 20 simple products with deterministic SKUs, one configurable, two categories in the main navigation. 12s wall clock on Mage-OS 4.0.0 under Warden, including the reindex the command runs itself, and idempotent. Core ships no profile for functional seeding -- the smallest of the five performance profiles generates 800 products, 100 images and 80 orders, because those profiles exist to benchmark a store under catalog weight. Sample data was the other option and is worse for a gate: its content changes between releases, so an assertion on a product name is an assertion about sample data rather than about Mage-OS. Verified both directions against a Warden store: green with three persisted guest orders carrying Flat Rate and a $6.00 grand total, and red at the rate-selection step with carriers/flatrate/active set to 0. --- _test/demo-package/Test/e2e/README.md | 76 ++++++++- .../Test/e2e/fixtures/mageos-e2e.xml | 96 +++++++++++ .../Test/e2e/guest-checkout.spec.ts | 158 ++++++++++++++++++ 3 files changed, 324 insertions(+), 6 deletions(-) create mode 100644 _test/demo-package/Test/e2e/fixtures/mageos-e2e.xml create mode 100644 _test/demo-package/Test/e2e/guest-checkout.spec.ts diff --git a/_test/demo-package/Test/e2e/README.md b/_test/demo-package/Test/e2e/README.md index cd5d0eda..daf1bd8b 100644 --- a/_test/demo-package/Test/e2e/README.md +++ b/_test/demo-package/Test/e2e/README.md @@ -1,15 +1,18 @@ -# Storefront smoke test +# Storefront tests -A deliberately small Playwright suite whose only job is to prove that a Mage-OS -storefront is **being served** -- installed, reachable over HTTP(S) and -rendering with its static content deployed. +A small Playwright suite that proves a Mage-OS storefront is **being served** +and **can take an order** -- installed, reachable over HTTP(S), rendering with +its static content deployed, and able to carry a guest from a category listing +to a persisted order. It is the canary for [`warden/setup-environment`](../../../../warden/setup-environment): `.github/workflows/_internal-e2e.yaml` stands a store up with that action on every change to it and runs this suite against the result. -It is not a test suite for a store's behaviour. Product, cart and checkout -coverage belongs in a suite of its own, with its own fixtures. +| Spec | Needs fixtures | Asserts | +| --- | --- | --- | +| `hello-magento.spec.ts` | no | the Luma homepage renders with static content deployed | +| `guest-checkout.spec.ts` | yes | catalog -> product -> cart -> shipping -> payment -> order | ## Running it against a store @@ -20,6 +23,9 @@ npx playwright install --with-deps chromium npm test ``` +`guest-checkout.spec.ts` needs a salable product, which a bare `setup:install` +does not have. Seed one first -- see [Fixtures](#fixtures). + There is no default base URL. A suite that silently falls back to some public demo store reports green about a store nobody asked about. @@ -62,3 +68,61 @@ Received string: "m137-admin-theme adminhtml-auth-login page-layout-admin-login ``` For the static content assertion, clear `pub/static` and reload. + +## Fixtures + +`fixtures/mageos-e2e.xml` is a performance-toolkit profile, run with the +command the toolkit ships: + +```bash +bin/magento setup:performance:generate-fixtures path/to/fixtures/mageos-e2e.xml +``` + +Measured on Mage-OS 4.0.0 under Warden: **12s wall clock**, including the +reindex the command runs itself -- no separate `indexer:reindex` needed. It is +idempotent: re-running it does not duplicate anything. + +It produces 20 simple products (`product_dynamic_1` .. `product_dynamic_20`), +one configurable with three variations, and two categories that appear in the +main navigation. The SKUs are deterministic, which is the thing sample data +cannot offer: no assertion breaks because a product was renamed upstream. + +### Why not a profile that already exists + +Core ships five profiles, and the smallest is not small: + +| Profile | simple products | categories | customers | orders | images | +| --- | --- | --- | --- | --- | --- | +| `small` | 800 | 30 | 200 | 80 | 100 | +| `medium` | 24,000 | 300 | 2,000 | 50,000 | 1,000 | +| `large` | 300,000 | 3,000 | 5,000 | 100,000 | 2,000 | + +They exist to benchmark a store under catalog weight. Core ships nothing for +functional seeding, so this profile is that. + +### Why not sample data + +`magento2-sample-data` is mirrored into `repo.mage-os.org`, so it is installable +without Adobe credentials. But it is hundreds of megabytes, and its *content* +changes between releases -- an assertion on "Joust Duffle Bag" is an assertion +about sample data, not about Mage-OS. A gate that goes red because a product was +renamed is a gate people switch off. + +### Two things to know about the profile + +`small.xml` sets `admin/security/use_form_key` to `0` and +`admin_account_sharing` to `1`. Reasonable for load testing, wrong here: a gate +running against a store with admin CSRF protection disabled is not testing the +store we ship. Do not copy those over. + +`ConfigsApplyFixture` iterates `$configs['config']` as a list, but a single +`<config>` element collapses to a flat map, so the fixture iterates that +element's own values and fatals with `Cannot access offset of type string on +string`. `small.xml` carries four entries, so upstream never sees it. Keep at +least two in the `<configs>` block. + +## What the checkout spec does not cover + +Registered-customer checkout, a real payment gateway, taxes, discounts and +multi-address shipping. Each wants fixtures of its own, and none of them is on +the path between "we tagged a release" and "a shopper can buy something". diff --git a/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml b/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml new file mode 100644 index 00000000..1fce5599 --- /dev/null +++ b/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml @@ -0,0 +1,96 @@ +<?xml version="1.0"?> +<!-- + A fixture profile for the Mage-OS storefront check. + + The performance toolkit ships five profiles, and the smallest, small.xml, + generates 800 simple products, 16 configurables, 100 images, 30 categories, + 200 customers and 80 orders. Those profiles exist to benchmark a store under + catalog weight, not to seed a functional test, and core ships no profile for + the latter. This is that profile: the least data a storefront check needs to + reach a product page and place a guest order. + + Measured on Mage-OS 4.0.0 under Warden: 12s wall clock, including the reindex + the command runs itself. Re-running it does not duplicate anything. + + Deliberately absent: images (the slow part), customers and orders (guest + checkout needs neither), price rules, coupons, extra attribute sets and tax + rates. Nothing asserts on them. + + Also deliberately absent: small.xml sets admin/security/use_form_key to 0 and + admin_account_sharing to 1. That is reasonable for load testing and wrong + here. A gate that runs against a store with admin CSRF protection disabled is + not testing the store we ship. +--> +<config xmlns:xi="http://www.w3.org/2001/XInclude"> + <profile> + <websites>1</websites> + <store_groups>1</store_groups> + <store_views>1</store_views> + <sources>1</sources> + <stocks>1</stocks> + <assign_entities_to_all_websites>0</assign_entities_to_all_websites> + + <!-- product_dynamic_1 .. product_dynamic_20, and + "Configurable Product 1" with three variations. The SKUs are + deterministic, which is the thing sample data cannot offer: no + assertion breaks because a product was renamed upstream. --> + <simple_products>20</simple_products> + <configurable_products> + <config> + <attributes> + <attribute> + <options>3</options> + </attribute> + </attributes> + <sku>Configurable Product %s</sku> + <products>1</products> + </config> + </configurable_products> + + <categories>2</categories> + <categories_nesting_level>1</categories_nesting_level> + + <customers>0</customers> + <orders>0</orders> + <catalog_price_rules>0</catalog_price_rules> + <cart_price_rules>0</cart_price_rules> + <coupon_codes>0</coupon_codes> + <product_attribute_sets>0</product_attribute_sets> + + <configs> + <!-- No SMTP on a CI runner. A failed order confirmation email + must not obscure a real checkout failure. --> + <config> + <path>system/smtp/disable</path> + <scope>default</scope> + <scopeId>0</scopeId> + <value>1</value> + </config> + <!-- Already the stock default; stated so this profile carries + what guest checkout needs rather than relying on it. + + It is also a workaround. ConfigsApplyFixture iterates + $configs['config'] as a list, but a single <config> element + collapses to a flat map, so the fixture iterates that + element's own values and fatals with "Cannot access offset of + type string on string". small.xml carries four entries, so + upstream never sees it. Keep at least two here. --> + <config> + <path>carriers/flatrate/active</path> + <scope>default</scope> + <scopeId>0</scopeId> + <value>1</value> + </config> + </configs> + + <!-- Realtime indexing: the check must not wait on cron. --> + <indexers> + <indexer><id>catalog_category_product</id><set_scheduled>false</set_scheduled></indexer> + <indexer><id>catalog_product_category</id><set_scheduled>false</set_scheduled></indexer> + <indexer><id>catalog_product_price</id><set_scheduled>false</set_scheduled></indexer> + <indexer><id>catalog_product_attribute</id><set_scheduled>false</set_scheduled></indexer> + <indexer><id>cataloginventory_stock</id><set_scheduled>false</set_scheduled></indexer> + <indexer><id>catalogsearch_fulltext</id><set_scheduled>false</set_scheduled></indexer> + </indexers> + </profile> +</config> diff --git a/_test/demo-package/Test/e2e/guest-checkout.spec.ts b/_test/demo-package/Test/e2e/guest-checkout.spec.ts new file mode 100644 index 00000000..122f2c07 --- /dev/null +++ b/_test/demo-package/Test/e2e/guest-checkout.spec.ts @@ -0,0 +1,158 @@ +import { test, expect, type Page } from '@playwright/test'; + +// The deepest path a storefront check can walk: catalog -> product -> cart -> +// shipping -> payment -> order. It touches the layered navigation, the price +// index, the quote, the shipping and payment method pools, the order +// placement and the private-content sections that Varnish punches holes for. +// If a release breaks any of those, this fails and the homepage check does not. +// +// It needs a salable product, which a bare setup:install does not have. See +// fixtures/mageos-e2e.xml. + +const shopper = { + email: `mageos-e2e-${Date.now()}@example.com`, + firstname: 'Mage', + lastname: 'Tester', + street: '1 Open Source Way', + city: 'Austin', + regionId: process.env.E2E_REGION_ID ?? '57', // Texas + postcode: '78701', + telephone: '5125550123', + countryId: process.env.E2E_COUNTRY_ID ?? 'US', +}; + +// Every selector below is Luma's. Keeping them in one place is what makes the +// Hyva variant of this suite a copy of this file with a different map, rather +// than a rewrite. +const luma = { + navCategory: '.navigation li.level0 > a', + productItem: '.product-item-info', + productItemLink: 'a.product-item-link', + addToCart: '#product-addtocart-button', + cartSuccess: '.message-success', + minicartCounter: '.minicart-wrapper .counter-number', + cartItemName: '.cart.item .product-item-name', + proceedToCheckout: 'button[data-role="proceed-to-checkout"]', + checkoutEmail: '#customer-email', + shippingForm: '#co-shipping-form', + shippingMethod: 'input[value="flatrate_flatrate"]', + nextButton: 'button[data-role="opc-continue"]', + paymentSection: '#checkout-step-payment', + placeOrder: '#checkout-payment-method-load button.action.checkout.primary', + successPageTitle: '.page-title', + successBlock: '.checkout-success', +}; + +async function fillShippingAddress(page: Page) { + const form = page.locator(luma.shippingForm); + + // The country select repopulates the region field, so it goes first. + await form.locator('select[name="country_id"]').selectOption(shopper.countryId); + await form.locator('input[name="firstname"]').fill(shopper.firstname); + await form.locator('input[name="lastname"]').fill(shopper.lastname); + await form.locator('input[name="street[0]"]').fill(shopper.street); + await form.locator('input[name="city"]').fill(shopper.city); + + // Magento renders either a region select or a free-text input depending on + // the country. Handle whichever is actually on the page. + const regionSelect = form.locator('select[name="region_id"]'); + if (await regionSelect.isVisible()) { + await regionSelect.selectOption(shopper.regionId); + } else { + await form.locator('input[name="region"]').fill('Texas'); + } + + await form.locator('input[name="postcode"]').fill(shopper.postcode); + await form.locator('input[name="telephone"]').fill(shopper.telephone); +} + +test.describe('Guest checkout', () => { + test('places an order as a guest', { tag: ['@checkout', '@guest'] }, async ({ page }) => { + await test.step('a category in the main navigation lists products', async () => { + await page.goto('/'); + + const category = page.locator(luma.navCategory).first(); + await expect(category, 'the fixture categories should appear in the main navigation').toBeVisible(); + await category.click(); + + await expect(page.locator('body')).toHaveClass(/catalog-category-view/); + // Not toBeVisible on .first(): an empty category still renders the + // listing wrapper, and a priced, indexed, in-stock product is the + // thing being asserted. + await expect(page.locator(luma.productItem).first()).toBeVisible(); + }); + + await test.step('the product page offers the product for sale', async () => { + await page.locator(luma.productItemLink).first().click(); + + await expect(page.locator('body')).toHaveClass(/catalog-product-view/); + await expect(page.locator('.page-title')).toBeVisible(); + // A price proves the price index ran. Out-of-stock or unindexed + // products render a page but no add-to-cart button. + await expect(page.locator('.product-info-main .price').first()).toBeVisible(); + await expect(page.locator(luma.addToCart)).toBeEnabled(); + }); + + await test.step('adding to the cart updates the minicart', async () => { + await page.locator(luma.addToCart).click(); + + // customer-data arrives over a separate /customer/section/load + // request that Varnish must not have cached. A stale minicart here + // is a real bug, so assert the counter, not just the message. + await expect(page.locator(luma.cartSuccess)).toContainText('to your shopping cart'); + await expect(page.locator(luma.minicartCounter)).toHaveText('1'); + }); + + await test.step('the cart holds the line item', async () => { + await page.goto('/checkout/cart/'); + + await expect(page.locator('body')).toHaveClass(/checkout-cart-index/); + await expect(page.locator(luma.cartItemName)).toHaveCount(1); + await expect(page.locator(luma.proceedToCheckout)).toBeEnabled(); + }); + + await test.step('the shipping step accepts a guest address and a rate', async () => { + await page.locator(luma.proceedToCheckout).click(); + + await expect(page.locator(luma.checkoutEmail)).toBeVisible(); + await page.locator(luma.checkoutEmail).fill(shopper.email); + await fillShippingAddress(page); + + // The rate pool is requested from the server once the address is + // complete. No rate means no checkout, which is a release blocker. + const flatRate = page.locator(luma.shippingMethod); + await expect(flatRate, 'Flat Rate should be offered for the shipping address').toBeVisible(); + await flatRate.check(); + + await page.locator(luma.nextButton).click(); + }); + + await test.step('the payment step places the order', async () => { + await expect(page.locator(luma.paymentSection)).toBeVisible(); + + // Check / Money order is active by default and is the only method + // on a store with no gateway credentials, so it is already + // selected. Assert rather than click, so a store that offers + // nothing fails here instead of timing out on Place Order. + const checkmo = page.locator('input[value="checkmo"]'); + await expect(checkmo, 'Check / Money order should be available').toBeChecked(); + + await page.locator(luma.placeOrder).click(); + }); + + await test.step('the order is confirmed with an increment id', async () => { + await expect(page).toHaveURL(/checkout\/onepage\/success/); + // The confirmation copy is in the page heading; the increment id is + // in the block below it. + await expect(page.locator(luma.successPageTitle)).toContainText('Thank you for your purchase'); + await expect(page.locator(luma.successBlock)).toBeVisible(); + + // An increment id proves the order was persisted, not just that a + // success page rendered. Matched as a pattern rather than through + // a selector: success.phtml wraps the id in a.order-number only + // when the viewer can open the order, so a guest gets a bare + // <span>. Digits also keep this assertion locale-independent. + await expect(page.locator(luma.successBlock)).toContainText(/\d{9}/); + }); + }); +}); From 04e710ef9df8b6d02e2c32880bd8d1e355f073b0 Mon Sep 17 00:00:00 2001 From: Marcel Martinez <martinezlopezmarcel@gmail.com> Date: Mon, 9 Nov 2026 21:45:56 -0600 Subject: [PATCH 07/10] ci(e2e): seed a catalog before the storefront tests The checkout spec needs something to buy, and the install the workflow stands up has nothing. The profile is copied into the project directory because the command runs inside the container, which sees only that. It reindexes itself, so no indexer:reindex follows it. --- .github/workflows/_internal-e2e.yaml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_internal-e2e.yaml b/.github/workflows/_internal-e2e.yaml index 3dea4c20..ec783444 100644 --- a/.github/workflows/_internal-e2e.yaml +++ b/.github/workflows/_internal-e2e.yaml @@ -29,7 +29,7 @@ concurrency: jobs: storefront-smoke-test: - name: "storefront smoke test" + name: "storefront tests" if: "!startsWith(github.head_ref, 'release-please')" runs-on: ubuntu-latest timeout-minutes: 60 @@ -96,6 +96,20 @@ jobs: - name: Confirm the store answers on the resolved hostname run: curl --silent --show-error --fail --insecure --head "${{ steps.warden.outputs.base_url }}" | head -1 + # A bare setup:install has no salable product, so the checkout spec has + # nothing to buy. The profile is copied into the project because the + # command runs inside the container, which only sees that directory. + # It reindexes itself, so no indexer:reindex follows. + - name: Seed the catalog + working-directory: ./_ghamagento + shell: bash + env: + PROFILE: ${{ github.workspace }}/${{ env.E2E_DIRECTORY }}/fixtures/mageos-e2e.xml + run: | + cp "${PROFILE}" var/mageos-e2e.xml + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm bin/magento setup:performance:generate-fixtures var/mageos-e2e.xml + - uses: actions/setup-node@v4 with: node-version: 22 @@ -108,7 +122,7 @@ jobs: npm ci npx playwright install --with-deps chromium - - name: Run the storefront smoke test + - name: Run the storefront tests working-directory: ${{ env.E2E_DIRECTORY }} env: PLAYWRIGHT_BASE_URL: ${{ steps.warden.outputs.base_url }} From a53d46b5f185161b8b2f5a3a2a88768b4f053719 Mon Sep 17 00:00:00 2001 From: Marcel Martinez <martinezlopezmarcel@gmail.com> Date: Mon, 9 Nov 2026 21:50:39 -0600 Subject: [PATCH 08/10] ci(e2e): stream the fixture profile into the container The runner cannot write into the project directories the container has written to, because those are owned by the container's user: cp: cannot create regular file 'var/mageos-e2e.xml': Permission denied Piping the profile through exec avoids host permissions entirely and leaves nothing behind in the project. Keeping the profile outside setup/performance-toolkit means its di.xml is not loaded, which only mocks the mail transport -- noted in the profile, and nothing here generates customers or orders. --- .github/workflows/_internal-e2e.yaml | 13 ++++++++----- _test/demo-package/Test/e2e/fixtures/mageos-e2e.xml | 6 ++++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/_internal-e2e.yaml b/.github/workflows/_internal-e2e.yaml index ec783444..d195dca7 100644 --- a/.github/workflows/_internal-e2e.yaml +++ b/.github/workflows/_internal-e2e.yaml @@ -97,18 +97,21 @@ jobs: run: curl --silent --show-error --fail --insecure --head "${{ steps.warden.outputs.base_url }}" | head -1 # A bare setup:install has no salable product, so the checkout spec has - # nothing to buy. The profile is copied into the project because the - # command runs inside the container, which only sees that directory. - # It reindexes itself, so no indexer:reindex follows. + # nothing to buy. It reindexes itself, so no indexer:reindex follows. + # + # The profile is streamed into the container rather than copied into the + # project: the command runs inside the container, which sees only that + # directory, and the directories the container has written to are owned by + # its own user, so the runner cannot write there. - name: Seed the catalog working-directory: ./_ghamagento shell: bash env: PROFILE: ${{ github.workspace }}/${{ env.E2E_DIRECTORY }}/fixtures/mageos-e2e.xml run: | - cp "${PROFILE}" var/mageos-e2e.xml export WARDEN="$(dirname $(pwd))/warden/bin/warden" - ${WARDEN} env exec -T php-fpm bin/magento setup:performance:generate-fixtures var/mageos-e2e.xml + ${WARDEN} env exec -T php-fpm bash -c 'cat > /tmp/mageos-e2e.xml' < "${PROFILE}" + ${WARDEN} env exec -T php-fpm bin/magento setup:performance:generate-fixtures /tmp/mageos-e2e.xml - uses: actions/setup-node@v4 with: diff --git a/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml b/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml index 1fce5599..b5965c09 100644 --- a/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml +++ b/_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml @@ -16,6 +16,12 @@ checkout needs neither), price rules, coupons, extra attribute sets and tax rates. Nothing asserts on them. + One consequence of keeping this file outside setup/performance-toolkit: + FixtureConfig derives the profile's di.xml from dirname() of this file, so + the toolkit's own di.xml is not loaded. All it does is mock the mail + transport, and nothing here generates customers or orders, so nothing tries + to send mail. The smtp/disable config below covers the rest. + Also deliberately absent: small.xml sets admin/security/use_form_key to 0 and admin_account_sharing to 1. That is reasonable for load testing and wrong here. A gate that runs against a store with admin CSRF protection disabled is From f69b5e6098e9582eb75f1fbdc774d923efbc3531 Mon Sep 17 00:00:00 2001 From: Marcel Martinez <martinezlopezmarcel@gmail.com> Date: Mon, 9 Nov 2026 22:01:12 -0600 Subject: [PATCH 09/10] test(e2e): add to the cart whatever the catalog lists first Which product a category lists first is not ours to decide, and on a clean install it is the configurable. That will not go into the cart until every attribute has a value, so the first CI run failed waiting for a success message that was never coming -- it had a validation error instead. It passed locally only because a leftover simple product happened to sort ahead of it. Selecting the first available value for whatever the page asks for makes the step indifferent to catalog order, and lets the spec run against a simple product, a configurable, or a merchant's own catalog. Verified against a configurable locally: one dropdown, three values, first selection adds to the cart. --- .github/workflows/_internal-e2e.yaml | 10 ++---- .../Test/e2e/guest-checkout.spec.ts | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/.github/workflows/_internal-e2e.yaml b/.github/workflows/_internal-e2e.yaml index d195dca7..346e2d5d 100644 --- a/.github/workflows/_internal-e2e.yaml +++ b/.github/workflows/_internal-e2e.yaml @@ -96,13 +96,9 @@ jobs: - name: Confirm the store answers on the resolved hostname run: curl --silent --show-error --fail --insecure --head "${{ steps.warden.outputs.base_url }}" | head -1 - # A bare setup:install has no salable product, so the checkout spec has - # nothing to buy. It reindexes itself, so no indexer:reindex follows. - # - # The profile is streamed into the container rather than copied into the - # project: the command runs inside the container, which sees only that - # directory, and the directories the container has written to are owned by - # its own user, so the runner cannot write there. + # A bare setup:install has nothing to buy. The command reindexes itself. + # Streamed in rather than copied: the project directories are owned by the + # container's user. - name: Seed the catalog working-directory: ./_ghamagento shell: bash diff --git a/_test/demo-package/Test/e2e/guest-checkout.spec.ts b/_test/demo-package/Test/e2e/guest-checkout.spec.ts index 122f2c07..1e16c6a5 100644 --- a/_test/demo-package/Test/e2e/guest-checkout.spec.ts +++ b/_test/demo-package/Test/e2e/guest-checkout.spec.ts @@ -29,6 +29,9 @@ const luma = { productItem: '.product-item-info', productItemLink: 'a.product-item-link', addToCart: '#product-addtocart-button', + swatchGroup: '.swatch-attribute', + swatchOption: '.swatch-option:not(.disabled)', + optionSelect: 'select.super-attribute-select', cartSuccess: '.message-success', minicartCounter: '.minicart-wrapper .counter-number', cartItemName: '.cart.item .product-item-name', @@ -43,6 +46,35 @@ const luma = { successBlock: '.checkout-success', }; +// A configurable product will not go into the cart until every attribute has a +// value, and which product the catalog lists first is not ours to decide. So +// pick the first available value for whatever the page asks for, and let the +// spec work on a simple product, a configurable, or a merchant's own catalog. +async function selectRequiredOptions(page: Page) { + const swatchGroups = page.locator(luma.swatchGroup); + for (let i = 0; i < (await swatchGroups.count()); i++) { + const option = swatchGroups.nth(i).locator(luma.swatchOption).first(); + if (await option.count()) { + await option.click(); + } + } + + // Configurables render dropdowns instead of swatches when the attribute + // has no swatch values, which is what the fixture profile produces. + const selects = page.locator(luma.optionSelect); + for (let i = 0; i < (await selects.count()); i++) { + const select = selects.nth(i); + const values = await select + .locator('option') + .evaluateAll((options) => + options.map((option) => (option as HTMLOptionElement).value).filter(Boolean), + ); + if (values.length) { + await select.selectOption(values[0]); + } + } +} + async function fillShippingAddress(page: Page) { const form = page.locator(luma.shippingForm); @@ -94,6 +126,7 @@ test.describe('Guest checkout', () => { }); await test.step('adding to the cart updates the minicart', async () => { + await selectRequiredOptions(page); await page.locator(luma.addToCart).click(); // customer-data arrives over a separate /customer/section/load From 087ff4a604e5d6ee4002c64817e618e80cf88175 Mon Sep 17 00:00:00 2001 From: Marcel Martinez <martinezlopezmarcel@gmail.com> Date: Mon, 9 Nov 2026 22:34:20 -0600 Subject: [PATCH 10/10] feat(e2e): add a reusable workflow for browser-based tests _internal-e2e.yaml proves the actions work, but it cannot be reused: it references them through "./", and a relative path in a reusable workflow resolves against the caller's checkout, which is not this repository when the caller is the release pipeline. So own-repo actions are referenced by full ref here, as integration.yaml and full-integration-tests.yaml already do. test_command is an input rather than a hardcoded "npx playwright test". The workflow's job is to stand a store up and hand over a URL; it should not know what runner points at it, and a caller wanting a grep filter, a shard or a different reporter should not need a new input for each. It arrives through the environment rather than interpolated into the script, so quoting is bash's problem and not the expression engine's. Evidence policy stays in the suite's config, so the default command carries no flags: a CLI flag overrides the config, and --trace on records a trace for every passing test. fixture_profile seeds a catalog before the run, because a bare setup:install has nothing to buy. Empty skips it, which is right for a suite that asserts only on what a bare install provides. Verified green end to end on a throwaway branch, with the Warden action pointed at the stacked serving branch: store served, catalog seeded in 9s, 2 specs passed. At @main it needs the serving inputs, so this cannot go green until #395 is on main. --- .github/workflows/e2e-README.md | 156 +++++++++++++++++++++ .github/workflows/e2e.yaml | 241 ++++++++++++++++++++++++++++++++ 2 files changed, 397 insertions(+) create mode 100644 .github/workflows/e2e-README.md create mode 100644 .github/workflows/e2e.yaml diff --git a/.github/workflows/e2e-README.md b/.github/workflows/e2e-README.md new file mode 100644 index 00000000..e8b1c098 --- /dev/null +++ b/.github/workflows/e2e-README.md @@ -0,0 +1,156 @@ +# Browser-based E2E Tests for Mage-OS + +A Github Workflow that stands a Mage-OS store up, **serves it**, and points a +browser-based test runner at it. + +This is not the PHPUnit-based suite that upstream calls "functional tests". It +installs a store, serves it through Traefik and Varnish on a resolvable +hostname, optionally seeds a catalog, and runs a browser against the result. + +## Inputs + +See the [e2e.yaml](./e2e.yaml) + +### What to install + +| Input | Description | Required | Default | +| -------------------- | --------------------------------------------------------------------------- | -------- | ----------------------------- | +| magento_version | The package to install, e.g. `mage-os/project-community-edition:4.0.0` | true | NULL | +| magento_repository | The composer repository to install it from | false | https://repo.mage-os.org/ | +| php_version | The PHP version that installs and serves the store | false | 8.4 | +| composer_version | The Composer version used inside the container | false | 2.10.2 | + +A release gate points `magento_repository` at the preview repository and +`magento_version` at the release being built, which is how it tests the +artifact about to be tagged rather than whatever is already published. + +### What to serve it with + +| Input | Description | Required | Default | +| ---------------------- | ------------------------------------------------------------------------- | -------- | --------------- | +| database | Database service and version | false | mariadb:11.8 | +| search | Search service and version | false | opensearch:3.4 | +| rabbitmq | Message queue service and version | false | rabbitmq:4.2 | +| redis | Cache service and version | false | redis:7.4 | +| varnish | HTTP cache service and version | false | varnish:8.0 | +| static_content_themes | Space separated themes to deploy static content for. Empty deploys every theme, which is considerably slower. | false | Magento/luma | + +### Where the suite comes from + +| Input | Description | Required | Default | +| ----------------- | ---------------------------------------------------------------- | -------- | --------------------------------- | +| suite_repository | The repository holding the test suite | false | mage-os/github-actions | +| suite_ref | The ref to check it out at | false | main | +| test_directory | The suite's directory, relative to the root of `suite_repository` | false | _test/demo-package/Test/e2e | + +The defaults point at the suite this repository carries for its own canary. A +caller with a suite of its own overrides all three. + +### How to run it + +| Input | Description | Required | Default | +| ------------------------ | ------------------------------------------------------------------ | -------- | -------------------- | +| test_command | The command to run, from `test_directory` | false | `npx playwright test` | +| node_version | Node version for the runner | false | 22 | +| fixture_profile | A performance-toolkit profile to seed, relative to the suite root. Empty skips seeding. | false | _test/demo-package/Test/e2e/fixtures/mageos-e2e.xml | +| timeout_minutes | Job timeout | false | 60 | +| artifact_name | Name of the uploaded report artifact | false | playwright-report | +| artifact_retention_days | How long the report is kept | false | 30 | + +## Secrets + +| Input | Description | Required | Default | +| ------------- | --------------------------------------------------------------------------- | -------- | ------- | +| composer_auth | JSON string of composer credentials | false | NULL | + +## Outputs + +| Output | Description | +| -------- | ------------------------------------- | +| base_url | The URL the store was served on | + +## `test_command` + +The workflow does not know what test runner you use. `test_command` is run from +`test_directory` with `PLAYWRIGHT_BASE_URL` already set to the served store, so +a caller can pass grep filters, shards, a different reporter, or something that +is not Playwright at all, without this workflow growing an input per flag. + +The command arrives through the environment rather than interpolated into the +script, so its quoting is bash's problem and not the expression engine's. + +**Keep evidence policy out of it.** `trace`, `video` and `screenshot` belong in +the suite's own config, where they are reviewable. A CLI flag overrides the +config, and `--trace on` records a trace for every passing test, which uploads +a large artifact for no benefit. The default command carries no flags for that +reason. + +### A setup phase + +Playwright's project `dependencies` are the mechanism for shared state that is +expensive to build -- an authenticated admin or customer session saved as +`storageState` and reused by every spec that needs it. Express that in the +suite's config rather than as two `--grep` / `--grep-invert` invocations in +`test_command`: two invocations write to the same report directory, so the +second overwrites the first and a failing setup phase loses its own evidence. +One command, one report, one exit code. + +Data is a different matter. Catalog and configuration are seeded through +`fixture_profile` by the CLI in seconds; doing the same work through a browser +would be slower and flakier for no gain. + +## Fixtures + +`fixture_profile` is a [performance +toolkit](https://developer.adobe.com/commerce/php/development/tools/performance-toolkit/) +profile, applied with `setup:performance:generate-fixtures`. The command +reindexes as part of its own run, so no `indexer:reindex` follows it. + +A bare `setup:install` has no salable product, so any suite that reaches a +product page or a checkout needs this. Leave it empty for a suite that asserts +only on what a bare install provides. + +## Usage + +```yaml +jobs: + e2e: + uses: mage-os/github-actions/.github/workflows/e2e.yaml@main + with: + magento_version: "mage-os/project-community-edition:4.0.0" +``` + +Gating a release on the artifact that is about to be tagged: + +```yaml +jobs: + storefront-check: + needs: [ deploy ] + uses: mage-os/github-actions/.github/workflows/e2e.yaml@main + with: + magento_repository: ${{ inputs.repo }} + magento_version: "mage-os/project-community-edition:${{ inputs.mageos_release }}" + artifact_name: "storefront-check-${{ inputs.mageos_release }}" +``` + +Running a suite of your own: + +```yaml +jobs: + e2e: + uses: mage-os/github-actions/.github/workflows/e2e.yaml@main + with: + magento_version: "mage-os/project-community-edition:4.0.0" + suite_repository: my-org/my-e2e-tests + suite_ref: v1.2.0 + test_directory: "." + test_command: "npx playwright test --grep @smoke" + fixture_profile: "fixtures/minimal.xml" +``` + +## Where things end up on the runner + +`warden/setup-environment` checks the Warden CLI out into `warden/` at the +workspace root, and `base_directory` has to sit exactly one level below it. +That is why the suite is checked out into `suite/` and the store into +`_ghamagento/`, and why neither is at the workspace root. diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 00000000..cd1d8563 --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,241 @@ +name: E2E Tests + +# A reusable workflow that stands a Mage-OS store up, serves it, and points a +# browser-based test runner at it. +# +# It does not know what runner that is: test_command is an input, so a caller +# can pass grep filters, shards, a different reporter, or something that is not +# Playwright at all, without this workflow growing an input per flag. +# +# Own-repo actions are referenced by full ref rather than by "./", as +# integration.yaml and full-integration-tests.yaml do. A relative path in a +# reusable workflow resolves against the caller's checkout, which is not this +# repository when the caller is the release pipeline. + +on: + workflow_call: + inputs: + # What to install. + magento_version: + required: true + type: string + description: "The package to install, e.g. mage-os/project-community-edition:4.0.0." + magento_repository: + required: false + type: string + default: "https://repo.mage-os.org/" + description: "The composer repository to install it from. A release gate points this at the preview repository." + php_version: + required: false + type: string + default: "8.4" + composer_version: + required: false + type: string + default: "2.10.2" + + # What to serve it with. + database: + required: false + type: string + default: "mariadb:11.8" + search: + required: false + type: string + default: "opensearch:3.4" + rabbitmq: + required: false + type: string + default: "rabbitmq:4.2" + redis: + required: false + type: string + default: "redis:7.4" + varnish: + required: false + type: string + default: "varnish:8.0" + static_content_themes: + required: false + type: string + default: "Magento/luma" + description: "Space separated themes to deploy static content for. Empty deploys every theme, which is considerably slower." + + # Where the suite comes from. The default is the suite this repository + # carries for its own canary; a caller with a suite of its own overrides + # both of these. + suite_repository: + required: false + type: string + default: "mage-os/github-actions" + suite_ref: + required: false + type: string + default: "main" + test_directory: + required: false + type: string + default: "_test/demo-package/Test/e2e" + description: "The suite's directory, relative to the root of suite_repository." + + # How to run it. + test_command: + required: false + type: string + default: "npx playwright test" + description: > + Run from test_directory with PLAYWRIGHT_BASE_URL set. Keep evidence + policy (trace, video, screenshot) in the suite's own config rather + than in flags here: a CLI flag overrides the config, and a gate that + records a trace for every passing test uploads a large artifact for + no benefit. + node_version: + required: false + type: string + default: "22" + fixture_profile: + required: false + type: string + default: "_test/demo-package/Test/e2e/fixtures/mageos-e2e.xml" + description: > + A performance-toolkit profile, relative to the root of + suite_repository, seeded before the tests run. Empty skips seeding, + which is right for a suite that asserts only on what a bare + setup:install provides. + + # Housekeeping. + timeout_minutes: + required: false + type: number + default: 60 + artifact_name: + required: false + type: string + default: "playwright-report" + description: "Give this a release-specific name when several gates upload to the same run." + artifact_retention_days: + required: false + type: number + default: 30 + + secrets: + composer_auth: + required: false + + outputs: + base_url: + description: "The URL the store was served on." + value: ${{ jobs.e2e.outputs.base_url }} + +jobs: + e2e: + name: "e2e tests" + runs-on: ubuntu-latest + timeout-minutes: ${{ inputs.timeout_minutes }} + outputs: + base_url: ${{ steps.warden.outputs.base_url }} + + env: + TRAEFIK_DOMAIN: mageos.test + TRAEFIK_SUBDOMAIN: app + # The suite is checked out here, and the tests run in SUITE/<dir>. + SUITE: suite + + steps: + # Not at the workspace root: warden/setup-environment checks the Warden CLI + # out into warden/ there, and base_directory has to sit exactly one level + # below it. + - name: Check out the test suite + uses: actions/checkout@v6 + with: + repository: ${{ inputs.suite_repository }} + ref: ${{ inputs.suite_ref }} + path: suite + + - name: Create the Mage-OS project + uses: mage-os/github-actions/setup-magento@main + with: + php-version: ${{ inputs.php_version }} + tools: "composer:v2" + mode: extension + magento_repository: ${{ inputs.magento_repository }} + magento_version: ${{ inputs.magento_version }} + composer_auth: ${{ secrets.composer_auth }} + + - name: Serve the store in Warden + id: warden + uses: mage-os/github-actions/warden/setup-environment@main + with: + base_directory: "./_ghamagento" + php_version: ${{ inputs.php_version }} + composer_version: ${{ inputs.composer_version }} + database: ${{ inputs.database }} + search: ${{ inputs.search }} + rabbitmq: ${{ inputs.rabbitmq }} + redis: ${{ inputs.redis }} + varnish: ${{ inputs.varnish }} + run_composer_install: 1 + run_setup_install: 1 + run_admin_user_creation: 1 + run_magento_config_preset: 1 + run_reindex: 1 + traefik_domain: ${{ env.TRAEFIK_DOMAIN }} + traefik_subdomain: ${{ env.TRAEFIK_SUBDOMAIN }} + base_url: "https://${{ env.TRAEFIK_SUBDOMAIN }}.${{ env.TRAEFIK_DOMAIN }}/" + configure_host_resolution: 1 + run_static_content_deploy: 1 + static_content_themes: ${{ inputs.static_content_themes }} + + # Separate from the test run so that "the store was never reachable" and + # "the store rendered the wrong thing" are different red steps. + - name: Confirm the store answers on the resolved hostname + run: curl --silent --show-error --fail --insecure --head "${{ steps.warden.outputs.base_url }}" | head -1 + + # A bare setup:install has nothing to buy. The command reindexes itself. + # Streamed in rather than copied: the project directories are owned by the + # container's user. + - name: Seed the catalog + if: inputs.fixture_profile != '' + working-directory: ./_ghamagento + shell: bash + env: + PROFILE: ${{ github.workspace }}/${{ env.SUITE }}/${{ inputs.fixture_profile }} + run: | + export WARDEN="$(dirname $(pwd))/warden/bin/warden" + ${WARDEN} env exec -T php-fpm bash -c 'cat > /tmp/fixture-profile.xml' < "${PROFILE}" + ${WARDEN} env exec -T php-fpm bin/magento setup:performance:generate-fixtures /tmp/fixture-profile.xml + + - uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node_version }} + cache: npm + cache-dependency-path: ${{ env.SUITE }}/${{ inputs.test_directory }}/package-lock.json + + - name: Install the test runner + working-directory: ${{ env.SUITE }}/${{ inputs.test_directory }} + run: | + npm ci + npx playwright install --with-deps chromium + + # The command arrives through the environment rather than interpolated into + # the script, so its quoting is bash's problem and not the expression + # engine's. + - name: Run the tests + working-directory: ${{ env.SUITE }}/${{ inputs.test_directory }} + env: + TEST_COMMAND: ${{ inputs.test_command }} + PLAYWRIGHT_BASE_URL: ${{ steps.warden.outputs.base_url }} + run: bash -c "$TEST_COMMAND" + + # A failing gate is read by someone deciding whether to ship, so the + # evidence has to outlive the run. + - name: Upload the test report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: ${{ inputs.artifact_name }} + path: | + ${{ env.SUITE }}/${{ inputs.test_directory }}/playwright-report + ${{ env.SUITE }}/${{ inputs.test_directory }}/test-results + retention-days: ${{ inputs.artifact_retention_days }} + if-no-files-found: ignore