|
| 1 | +# INF-956: WooCommerce Plugin E2E Tests |
| 2 | + |
| 3 | +Linear: https://linear.app/tillit/issue/INF-956 |
| 4 | + |
| 5 | +## Context |
| 6 | + |
| 7 | +WooCommerce e2e tests were deleted from the e2e-tests repo during the API migration (INF-940). They now live in the woocommerce-plugin repo, running against the local Docker dev environment (WordPress + WooCommerce + Two plugin at localhost:8888). |
| 8 | + |
| 9 | +Tests focus on plugin-specific behaviour: WooCommerce store checkout with Two payment, order lifecycle through WP admin, and Two API state verification. |
| 10 | + |
| 11 | +## Docker environment |
| 12 | + |
| 13 | +- Store: `http://localhost:8888` (Storefront theme, NL, EUR) |
| 14 | +- Admin: `http://localhost:8888/wp-admin` (admin / twoinb2b) |
| 15 | +- Products: "Product 1"–"Product 4", random prices 100–200 |
| 16 | +- Plugin config: `docker/config/staging-tillittestuk.json` → `api.staging.two.inc` |
| 17 | +- Merchant: tillittestuk (UK, org 13078389) — has merchant-wide `skip_verification` rule |
| 18 | + |
| 19 | +## Checklist |
| 20 | + |
| 21 | +### Docker bootstrap |
| 22 | + |
| 23 | +- [x] **`docker/wpcli.sh`**: Uncomment plugin activation (line 19) |
| 24 | +- [x] Add `_regular_price` and `_stock_status` meta so products display correctly in Storefront |
| 25 | + |
| 26 | +### Test infrastructure (`tests/e2e/`) |
| 27 | + |
| 28 | +- [x] `package.json` — Playwright Test, TypeScript |
| 29 | +- [x] `playwright.config.ts` — chromium, baseURL localhost:8888, trace/video on failure |
| 30 | +- [x] `config.ts` — reads `MERCHANT_API_KEY` from env var, defaults to staging Two API |
| 31 | +- [x] `checkout-api.ts` — Two API client (get order state, verify, confirm, cancel) |
| 32 | +- [x] `docker/config/staging-tillittestuk.json.tpl` — template for Docker plugin config, populated at CI time |
| 33 | + |
| 34 | +### Page objects |
| 35 | + |
| 36 | +- [x] `pages/store.ts` — add product to cart, go to checkout |
| 37 | +- [x] `pages/checkout.ts` — select Two payment, company search (Select2), billing details, place order |
| 38 | +- [x] `pages/wp-admin.ts` — login, navigate to orders, change status, refund |
| 39 | + |
| 40 | +### Tests |
| 41 | + |
| 42 | +- [x] `tests/order-flow.spec.ts` — place order → verify CONFIRMED → fulfil via WP admin → verify FULFILLED → refund → verify REFUNDED |
| 43 | +- [x] `tests/cancel-order.spec.ts` — place order → cancel via WP admin → verify CANCELLED |
| 44 | +- [x] `tests/max-limit.spec.ts` — excessive quantity → rejection on checkout |
| 45 | + |
| 46 | +### CI/CD |
| 47 | + |
| 48 | +- [x] `.github/workflows/e2e-tests.yaml` — GCP auth via WIF, fetch API key from Secret Manager, generate Docker config, start WordPress, run Playwright tests, upload artifacts on failure |
| 49 | +- [x] Makefile targets: `e2e-install`, `e2e-test`, `e2e-test-headed` |
| 50 | + |
| 51 | +### Infrastructure |
| 52 | + |
| 53 | +- [x] Generated new API key for tillittestuk merchant via `POST /admin/v1/merchant/{id}/api_key` |
| 54 | +- [x] Stored as `STAGING_SHOP_MERCHANT_API_KEY_TILLITTESTUK` in GCP Secret Manager (two-beta) |
| 55 | +- [x] `GCP_E2E_TESTS_SA_NAME_TWO_BETA` org var: added woocommerce-plugin to selected repos |
| 56 | +- [x] `WORKLOAD_IDENTITY_PROVIDER_PREFIX_TWO_BETA` org var: changed from "private" to "selected", added e2e-tests + woocommerce-plugin |
| 57 | +- [ ] Verify CI passes end-to-end |
| 58 | + |
| 59 | +## Running locally |
| 60 | + |
| 61 | +```bash |
| 62 | +docker compose up -d |
| 63 | +# wait for wpcli to finish bootstrapping (~60s) |
| 64 | +make e2e-install |
| 65 | +MERCHANT_API_KEY=secret_test_xxx make e2e-test |
| 66 | +``` |
| 67 | + |
| 68 | +The API key comes from your local `docker/config/staging-tillittestuk.json` (gitignored). In CI it's fetched from GCP Secret Manager. |
| 69 | + |
| 70 | +## Out of scope |
| 71 | + |
| 72 | +- Identity verification / SCA flow (covered in e2e-tests repo) |
| 73 | +- Merchant portal tests (covered in e2e-tests repo) |
| 74 | +- Multi-country support (single NL environment) |
0 commit comments