|
| 1 | +# Playwright Plan: Test All Runtime and UI Modes |
| 2 | + |
| 3 | +## Objective |
| 4 | +Build a deterministic Playwright test suite that validates LibreSpeed behavior across all supported deployment modes and UI design modes, without asserting real network throughput values. |
| 5 | + |
| 6 | +## Modes to Cover |
| 7 | + |
| 8 | +### Docker runtime modes |
| 9 | +- `standalone` |
| 10 | +- `backend` |
| 11 | +- `frontend` |
| 12 | +- `dual` |
| 13 | + |
| 14 | +### UI design modes |
| 15 | +- Classic (`index-classic.html`) |
| 16 | +- Modern (`index-modern.html`) |
| 17 | +- Switcher behavior from `index.html`: |
| 18 | + - default from `config.json` (`useNewDesign`) |
| 19 | + - `?design=new` override |
| 20 | + - `?design=old` override |
| 21 | + |
| 22 | +## Test Strategy |
| 23 | + |
| 24 | +### 1. Keep assertions deterministic |
| 25 | +Do not assert real bandwidth numbers. Focus on: |
| 26 | +- HTTP availability of expected files/endpoints |
| 27 | +- correct redirects/switching behavior |
| 28 | +- expected UI controls rendered |
| 29 | +- expected server-list loading behavior |
| 30 | +- ability to initiate/abort flow at UI level |
| 31 | + |
| 32 | +### 2. Separate test types |
| 33 | +- **Mode smoke tests** (fast, always-run): verify each runtime mode serves the right surfaces. |
| 34 | +- **UI mode tests**: verify classic/modern pages and switcher rules. |
| 35 | +- **Optional flow tests** (later): mock `Speedtest` in browser to simulate state changes and verify UI updates. |
| 36 | + |
| 37 | +### 3. Use Docker Compose as the environment contract |
| 38 | +Run Playwright against containers started with explicit `MODE` values to mirror production entrypoint behavior. |
| 39 | + |
| 40 | +## Proposed Test Matrix |
| 41 | + |
| 42 | +### A) `standalone` |
| 43 | +Expectations: |
| 44 | +- `GET /` responds and serves UI (classic by default unless overridden) |
| 45 | +- `GET /backend/empty.php`, `GET /backend/garbage.php`, `GET /backend/getIP.php` available |
| 46 | +- `GET /results/telemetry.php` reachable (even if telemetry disabled behavior differs) |
| 47 | +- `GET /index.html?design=new` resolves to modern page |
| 48 | +- `GET /index.html?design=old` resolves to classic page |
| 49 | + |
| 50 | +### B) `backend` |
| 51 | +Expectations: |
| 52 | +- backend endpoints return success (`/backend/empty.php`, `/backend/garbage.php`, `/backend/getIP.php`) |
| 53 | +- tests only assert local backend endpoint contracts in this mode |
| 54 | + |
| 55 | +### C) `frontend` |
| 56 | +Expectations: |
| 57 | +- UI entrypoint available |
| 58 | +- server list loads from `/servers.json` (or `SERVER_LIST_URL` if set) |
| 59 | +- backend test endpoints should not be treated as local testpoint contract in this mode |
| 60 | +- selecting server and pressing start does not crash UI shell |
| 61 | + |
| 62 | +### D) `dual` |
| 63 | +Expectations: |
| 64 | +- combines frontend + local backend availability |
| 65 | +- UI can load multi-server list |
| 66 | +- backend endpoints available locally |
| 67 | + |
| 68 | +## Playwright Architecture |
| 69 | + |
| 70 | +### Files |
| 71 | +- `playwright.config.ts` |
| 72 | +- `tests/e2e/modes.spec.ts` (runtime-mode smoke) |
| 73 | +- `tests/e2e/design-switch.spec.ts` (classic/modern/switch overrides) |
| 74 | +- `tests/e2e/helpers/env.ts` (base URLs + mode metadata) |
| 75 | +- `tests/e2e/helpers/ui.ts` (shared selectors, start/abort helpers) |
| 76 | + |
| 77 | +### Environment boot |
| 78 | +- `docker compose -f tests/docker-compose-playwright.yml up -d --build` |
| 79 | +- dedicate one service per runtime mode on separate ports |
| 80 | +- for `frontend` and `dual`, mount a stable `servers.json` |
| 81 | + |
| 82 | +### Selector policy |
| 83 | +Use role/text selectors anchored on stable labels and IDs already in pages; avoid brittle CSS-path selectors. |
| 84 | + |
| 85 | +## Phased Rollout |
| 86 | + |
| 87 | +### Phase 1 (recommended first PR) |
| 88 | +- Add Playwright scaffolding and CI job |
| 89 | +- Add smoke coverage for 4 Docker runtime modes |
| 90 | +- Add design switch tests (`index.html`, `?design=new`, `?design=old`) |
| 91 | +- No full speed measurement assertions |
| 92 | + |
| 93 | +### Phase 2 |
| 94 | +- Add deterministic UI flow tests with mocked Speedtest state updates |
| 95 | +- Validate button states (`Start` -> running -> abort/end) |
| 96 | +- Validate result widgets receive simulated values |
| 97 | + |
| 98 | +### Phase 3 |
| 99 | +- Add telemetry-enabled scenario tests (`TELEMETRY=true`) for link visibility and stats exposure |
| 100 | +- Add negative tests (missing/invalid `servers.json` in frontend/dual) |
| 101 | + |
| 102 | +## Risks and Mitigations |
| 103 | +- Flaky speed measurements due to host/network variance |
| 104 | + - Mitigation: avoid throughput assertions; use mocked state for UI behavior. |
| 105 | +- Divergence between local static run and Docker entrypoint behavior |
| 106 | + - Mitigation: run all mode tests against Docker services. |
| 107 | +- Selector drift between classic and modern UIs |
| 108 | + - Mitigation: maintain per-design helper selectors with minimal coupling. |
| 109 | + |
| 110 | +## CI Proposal |
| 111 | +- Trigger on PR + main branch |
| 112 | +- Build test image once, run mode services in parallel ports |
| 113 | +- Playwright retries: `1` in CI, `0` locally |
| 114 | +- Upload traces/screenshots on failure only |
| 115 | +- Browser scope for v1: Chromium only |
| 116 | + |
| 117 | +## Confirmed Decisions |
| 118 | +1. Browser scope for v1: Chromium only. |
| 119 | +2. Telemetry checks are deferred to Phase 3. |
| 120 | +3. `backend` mode tests assert backend endpoint contracts only. |
0 commit comments