Skip to content

Commit 74160fc

Browse files
Tsvetan StoychevTsvetan Stoychev
authored andcommitted
Add WooCommerce end-to-end page type tests
1 parent dbd3aba commit 74160fc

16 files changed

Lines changed: 499 additions & 4 deletions

‎.github/workflows/ci.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,26 @@ jobs:
100100
- name: Test JavaScript loaders
101101
run: npm run test:js
102102

103+
woocommerce-e2e:
104+
name: WooCommerce E2E page types
105+
runs-on: ubuntu-latest
106+
timeout-minutes: 20
107+
108+
steps:
109+
- name: Checkout
110+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
111+
112+
- name: Run WooCommerce E2E suite
113+
run: make woocommerce-e2e
114+
115+
- name: Upload WooCommerce E2E diagnostics
116+
if: failure()
117+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
118+
with:
119+
name: woocommerce-e2e-diagnostics
120+
path: test-results/woocommerce-e2e
121+
if-no-files-found: ignore
122+
103123
unit:
104124
name: Unit (PHP ${{ matrix.php }})
105125
runs-on: ubuntu-latest
@@ -202,6 +222,7 @@ jobs:
202222
- quality
203223
- translations
204224
- javascript
225+
- woocommerce-e2e
205226
- unit
206227
- integration
207228

‎.github/workflows/prerelease.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
BASICRUM_RELEASE_TAG: ${{ github.event.release.tag_name }}
2424
run: make conventions
2525

26+
- name: Run WooCommerce E2E page-type tests
27+
run: make woocommerce-e2e
28+
2629
- name: Setup release PHP
2730
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
2831
with:

‎.github/workflows/release.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
BASICRUM_RELEASE_TAG: ${{ github.event.release.tag_name }}
2424
run: make conventions
2525

26+
- name: Run WooCommerce E2E page-type tests
27+
run: make woocommerce-e2e
28+
2629
- name: Setup release PHP
2730
uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # v2
2831
with:

‎AGENTS.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ namespace, PSR-4 Composer autoloading, PHP 7.4+, and WordPress 6.0+.
3232
hard-coded script handles.
3333
- Boomerang lives in `assets/js/boomr/`; standard and consent loaders live in
3434
`assets/js/loaders/`.
35+
- WooCommerce browser E2E tests are root-level test tooling. Keep the pinned
36+
WooCommerce version and checksum synchronized in `tools/setup-woocommerce-e2e.sh`.
37+
Review and update each Docker image tag and digest together in
38+
`docker/woocommerce-e2e.yml`.
3539
- Pin third-party GitHub Actions to full 40-character commit SHAs. Keep the
3640
reviewed release tag in the adjacent comment and update pins through reviewed
3741
Dependabot pull requests.
@@ -50,6 +54,7 @@ make composer-audit
5054
make conventions
5155
make unit
5256
make js-test
57+
make woocommerce-e2e
5358
make integration-setup
5459
make integration
5560
make translations

‎Makefile‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ TEST_DB_PASS = root
1313
TEST_DB_HOST = db
1414
WP_TEST_VERSION ?= latest
1515

16-
.PHONY: help build up down restart logs shell composer-install wp-install lint lint-fix lint-php analyse composer-validate composer-audit conventions translations js-install js-test integration-setup integration test package package-verify package-smoke clean
16+
.PHONY: help build up down restart logs shell composer-install wp-install lint lint-fix lint-php analyse composer-validate composer-audit conventions translations js-install js-test woocommerce-e2e integration-setup integration test package package-verify package-smoke clean
1717

1818
help:
1919
@echo "Targets:"
@@ -35,6 +35,7 @@ help:
3535
@echo " translations Update POT, PO, and MO translation catalogs"
3636
@echo " js-install Install locked JavaScript test dependencies"
3737
@echo " js-test Run loader behavior tests in Chromium"
38+
@echo " woocommerce-e2e Run WooCommerce page-type browser tests"
3839
@echo " unit Run unit tests"
3940
@echo " integration-setup Install WordPress test suite inside containers"
4041
@echo " integration Run integration tests"
@@ -99,6 +100,9 @@ js-install:
99100
js-test: js-install
100101
$(COMPOSE) run --rm --no-deps --user "$$(id -u):$$(id -g)" -e HOME=/tmp $(JS_SERVICE) npm run test:js
101102

103+
woocommerce-e2e:
104+
sh tools/run-woocommerce-e2e.sh
105+
102106
unit:
103107
$(COMPOSE) run --rm -w $(PLUGIN_WORKDIR) $(PHP_SERVICE) composer unit
104108

‎README.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ make composer-audit
2828
make conventions
2929
make translations
3030
make js-test
31+
make woocommerce-e2e
3132
make package
3233
make package-smoke
3334
```
@@ -121,6 +122,15 @@ intercept the synthetic Boomerang request, and block every unexpected network
121122
request. They cover consent gating, repeated opt-in, opt-out cleanup, and cookie
122123
behavior on HTTP, HTTPS, localhost, and subdomains.
123124

125+
`make woocommerce-e2e` starts an isolated WordPress 6.9 and WooCommerce 10.9.4
126+
stack, seeds a product and completed order, then uses Playwright to visit the
127+
shop, product, cart, checkout, and order-received pages. It intercepts the
128+
synthetic collector and verifies the actual Basicrum beacon `p_type` values.
129+
The WooCommerce download is pinned and checksum-verified in
130+
`tools/setup-woocommerce-e2e.sh`; update its version and checksum together.
131+
The stack's Docker image tags and immutable digests are reviewed together in
132+
`docker/woocommerce-e2e.yml`.
133+
124134
The JavaScript package, Playwright configuration, and browser tests live at the
125135
repository root. The release builder copies only `plugins/basicrum/`, and the
126136
release verifier also rejects Node or Playwright development files if they ever

‎checklist.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ Acceptance criteria:
9393
- [ ] Test the latest stable WordPress release with a currently supported PHP
9494
version.
9595
- [ ] Test WordPress trunk with the newest compatible PHP version.
96+
- [x] Add an isolated WooCommerce E2E suite covering shop, product, cart,
97+
checkout, and order-received page types through actual Basicrum beacons.
9698
- [ ] Update `Tested up to` only after the stable integration test passes.
9799
- [ ] Document how compatibility metadata is updated for each release.
98100

‎docker/woocommerce-e2e.yml‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
services:
2+
db:
3+
# Reviewed tag: mysql:8.0
4+
image: mysql:8.0@sha256:7dcddc01f13bab2f15cde676d44d01f61fc9f99fe7785e86196dfc07d358ae2b
5+
command: --default-authentication-plugin=mysql_native_password
6+
environment:
7+
MYSQL_DATABASE: wordpress
8+
MYSQL_USER: wordpress
9+
MYSQL_PASSWORD: wordpress
10+
MYSQL_ROOT_PASSWORD: root
11+
healthcheck:
12+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-proot"]
13+
interval: 5s
14+
timeout: 5s
15+
retries: 20
16+
17+
wordpress:
18+
# Reviewed tag: wordpress:6.9-php8.2-apache
19+
image: wordpress:6.9-php8.2-apache@sha256:29a3af5db27d8c1716367575280bbf449cd231ced707daf8ce411895c042ed76
20+
depends_on:
21+
db:
22+
condition: service_healthy
23+
environment:
24+
WORDPRESS_DB_HOST: db:3306
25+
WORDPRESS_DB_NAME: wordpress
26+
WORDPRESS_DB_USER: wordpress
27+
WORDPRESS_DB_PASSWORD: wordpress
28+
volumes:
29+
- wordpress_data:/var/www/html
30+
- plugin_workspace:/var/www/html/wp-content/plugins/basicrum:ro
31+
32+
wpcli:
33+
# Reviewed tag: wordpress:cli-2.12.0-php8.2
34+
image: wordpress:cli-2.12.0-php8.2@sha256:b93ed9324c515901534955dfb528b7e1de158827815d7bb699d774b6bb6df8aa
35+
user: "33:33"
36+
depends_on:
37+
db:
38+
condition: service_healthy
39+
environment:
40+
WORDPRESS_DB_HOST: db:3306
41+
WORDPRESS_DB_NAME: wordpress
42+
WORDPRESS_DB_USER: wordpress
43+
WORDPRESS_DB_PASSWORD: wordpress
44+
WP_URL: http://wordpress
45+
WP_TITLE: Basicrum WooCommerce E2E
46+
WP_ADMIN_USER: admin
47+
WP_ADMIN_PASSWORD: basicrum-e2e-password
48+
WP_ADMIN_EMAIL: admin@example.test
49+
HTTP_HOST: wordpress
50+
volumes:
51+
- wordpress_data:/var/www/html
52+
- plugin_workspace:/var/www/html/wp-content/plugins/basicrum:ro
53+
- ../tools:/tools:ro
54+
55+
plugin:
56+
# Reviewed tag: composer:2
57+
image: composer:2@sha256:5946476338742b200bb9ff88f8be56275ddae4b3949c72305cb0dbf10cfcb760
58+
entrypoint: ["sh", "-c"]
59+
command:
60+
- >-
61+
rm -rf /workspace/vendor &&
62+
tar -C /source --exclude='./vendor' -cf - . | tar -C /workspace -xf -
63+
volumes:
64+
- ../plugins/basicrum:/source:ro
65+
- plugin_workspace:/workspace
66+
67+
composer:
68+
# Reviewed tag: composer:2
69+
image: composer:2@sha256:5946476338742b200bb9ff88f8be56275ddae4b3949c72305cb0dbf10cfcb760
70+
working_dir: /workspace
71+
volumes:
72+
- plugin_workspace:/workspace
73+
74+
javascript:
75+
# Reviewed tag: mcr.microsoft.com/playwright:v1.61.1-noble
76+
image: mcr.microsoft.com/playwright:v1.61.1-noble@sha256:5b8f294aff9041b7191c34a4bab3ac270157a28774d4b0660e9743297b697e48
77+
working_dir: /workspace
78+
environment:
79+
CI: "true"
80+
HOME: /tmp
81+
WOOCOMMERCE_E2E_BASE_URL: http://wordpress
82+
volumes:
83+
- ../:/workspace
84+
ipc: host
85+
86+
volumes:
87+
wordpress_data:
88+
plugin_workspace:

‎package.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"scripts": {
99
"test": "npm run test:js",
1010
"test:js": "playwright test",
11-
"test:js:headed": "playwright test --headed"
11+
"test:js:headed": "playwright test --headed",
12+
"test:e2e:woocommerce": "playwright test --config=playwright.woocommerce-e2e.config.js"
1213
},
1314
"devDependencies": {
1415
"@playwright/test": "1.61.1"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { defineConfig } = require( '@playwright/test' );
2+
3+
const baseURL = process.env.WOOCOMMERCE_E2E_BASE_URL;
4+
5+
if ( ! baseURL ) {
6+
throw new Error( 'WOOCOMMERCE_E2E_BASE_URL must be set for WooCommerce E2E tests.' );
7+
}
8+
9+
module.exports = defineConfig( {
10+
testDir: './tests/e2e',
11+
fullyParallel: false,
12+
forbidOnly: Boolean( process.env.CI ),
13+
retries: process.env.CI ? 1 : 0,
14+
workers: 1,
15+
reporter: process.env.CI
16+
? [
17+
[ 'line' ],
18+
[ 'html', { outputFolder: 'test-results/woocommerce-e2e/report', open: 'never' } ],
19+
]
20+
: 'list',
21+
timeout: 45_000,
22+
expect: {
23+
timeout: 20_000,
24+
},
25+
use: {
26+
baseURL,
27+
browserName: 'chromium',
28+
headless: true,
29+
ignoreHTTPSErrors: true,
30+
actionTimeout: 10_000,
31+
navigationTimeout: 30_000,
32+
screenshot: 'only-on-failure',
33+
trace: 'retain-on-failure',
34+
video: 'retain-on-failure',
35+
},
36+
outputDir: 'test-results/woocommerce-e2e/results',
37+
} );

0 commit comments

Comments
 (0)