# Browser E2E (Playwright)

This suite runs browser-based smoke/regression coverage against fixture-hosted admin UI (`tests/fixture/wp-admin/*`).

## Run

```bash
tests/e2e/run.sh
```

Or manually:

```bash
scripts/run_fixture_server.sh start
npm install
npx playwright install chromium
E2E_BASE_URL=http://127.0.0.1:8092 npx playwright test
```

Remote admin mode (uses `credentials/.env` `E2E_REMOTE_ADMIN*` vars):

```bash
E2E_REMOTE_ADMIN=1 tests/e2e/run.sh
```

## Specs

- `admin-ui-smoke.spec.mjs`
  - page-load smoke for Data Sources, Mailshots, Attachments, PDF Assets.
- `data-sources.spec.mjs`
  - modal create flow, preview regression guard (`contacts and accounts`), validation failure path.
- `mailshots-editor.spec.mjs`
  - datasource-driven token/field population, message/PDF overlay editor flows, create mailshot.
- `run-test-pages.spec.mjs`
  - Run/Test page load checks and API failure-path assertions (`run_mailshot` invalid id, `send_test` blank email).
- `download-pdf-renewal.spec.mjs`
  - Optional live-data e2e for `renewal_accounts_with_contacts` + `formats/renewals_v4.html`, asserts merged and ZIP downloads both succeed.

## Renewal Dataset E2E

Run this targeted dataset test with:

```bash
E2E_RENEWAL_ENABLE=1 \
E2E_RENEWAL_DATASOURCE=renewal_accounts_with_contacts \
E2E_BASE_URL=http://127.0.0.1:8092 \
npx playwright test tests/e2e/specs/download-pdf-renewal.spec.mjs
```

## Notes

- Tests clean up created Data Source/Mailshot artefacts.
- This suite is intended as a pre-manual gate before release/deploy.
