|
| 1 | +# ADR 0005: E2E Testing Strategy -- Playwright for URL Smoke Tests |
| 2 | + |
| 3 | +**Status**: Accepted |
| 4 | + |
| 5 | +**Date**: 2025-12-21 |
| 6 | + |
| 7 | +**Deciders**: Engineering Team |
| 8 | + |
| 9 | +**Context**: The app needed automated end-to-end testing to validate routing and deep linking. Two approaches were evaluated: Patrol with Firebase Test Lab (native Flutter E2E on real Android devices) and Playwright (browser-based testing). Flutter web renders to a `<canvas>` element, which makes traditional DOM-based testing largely ineffective for UI interactions. |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Decision |
| 14 | + |
| 15 | +We adopted **Playwright for URL and routing smoke tests only**, and deferred native E2E testing. |
| 16 | + |
| 17 | +Playwright tests verify: |
| 18 | +- URL routing works (correct URLs after navigation) |
| 19 | +- Browser back/forward/refresh preserves routes |
| 20 | +- No critical console errors on page load |
| 21 | +- Basic ARIA label presence (accessibility smoke test) |
| 22 | + |
| 23 | +Playwright tests **do not** verify: |
| 24 | +- Visual appearance, layout, or rendered text |
| 25 | +- Widget interactions (tapping buttons, filling forms) |
| 26 | +- User flows (search, filter, favorite) |
| 27 | +- Canvas-rendered content |
| 28 | + |
| 29 | +Widget interactions are covered by Flutter's own `testWidgets` framework in `test/`. |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## Alternatives Considered |
| 34 | + |
| 35 | +### Patrol + Firebase Test Lab |
| 36 | + |
| 37 | +A detailed plan was created (see `docs/planning/archive/patrol-firebase-testing/`) proposing: |
| 38 | +- Native Flutter E2E tests using the Patrol framework |
| 39 | +- Execution on real Android devices via Firebase Test Lab free tier (15 tests/day) |
| 40 | +- 4-5 week implementation timeline across 5 phases |
| 41 | + |
| 42 | +**Why it was not implemented:** |
| 43 | +- Significant setup complexity (Firebase Test Lab, GCP service accounts, Android instrumentation builds) |
| 44 | +- 4-5 week implementation investment for a pre-release app |
| 45 | +- Free tier limit (15 tests/day) constrains CI usage |
| 46 | +- Flutter widget tests already cover interaction flows effectively |
| 47 | +- The immediate need was validating URL routing for the deep linking feature, not full native E2E |
| 48 | + |
| 49 | +**When to reconsider:** |
| 50 | +- If the app ships on Android/iOS and needs device-specific testing (permissions, system dialogs, push notifications) |
| 51 | +- If visual regression testing becomes important |
| 52 | +- If Flutter widget tests prove insufficient for catching real-world bugs |
| 53 | + |
| 54 | +### Flutter Integration Tests |
| 55 | + |
| 56 | +Flutter's built-in `integration_test` package was considered but not prioritised. It would run the full app in a test harness and can interact with widgets directly. This remains a valid option for future investment (tracked in todos.md item #1). |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Consequences |
| 61 | + |
| 62 | +### Positive |
| 63 | + |
| 64 | +- Fast to implement (2 test files, ~440 lines) |
| 65 | +- Validates the most critical web concern: URL routing works correctly |
| 66 | +- Runs in CI without special infrastructure |
| 67 | +- ARIA label checks enforce accessibility as a side effect |
| 68 | +- No ongoing cost or quota limits |
| 69 | + |
| 70 | +### Negative |
| 71 | + |
| 72 | +- Cannot test actual user flows through the UI |
| 73 | +- Cannot verify that the correct screen renders for a given URL |
| 74 | +- Flutter canvas rendering means Playwright can never do meaningful UI testing for this app |
| 75 | +- Gap between "URL works" and "screen works" -- a route could return 200 but render an error state |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## Implementation |
| 80 | + |
| 81 | +- **Config**: `playwright.config.ts` |
| 82 | +- **Tests**: `test-e2e/app.spec.ts` (loading, console errors, ARIA), `test-e2e/routing.spec.ts` (URL routing, browser history) |
| 83 | +- **Approach doc**: `docs/tooling/flutter-web-testing.md` |
| 84 | + |
| 85 | +## Related Documents |
| 86 | + |
| 87 | +- `docs/tooling/flutter-web-testing.md` -- how Playwright works with Flutter's canvas renderer |
| 88 | +- `docs/planning/archive/patrol-firebase-testing/` -- the Patrol evaluation that was not implemented |
0 commit comments