Plan: E2E Test Hardening
On this page
Context
The E2E test suite (83 Playwright tests across 15 spec files) has several fragility patterns that cause false passes or flaky failures.
Identified during review after the Rules Cache Race Fix revealed that one E2E failure (cases.spec.ts:19) was caused by a test assuming seeded data always appears on page 1 of results.
Issues (Prioritized)
P0: .catch(() ⇒ false) Silences Real Failures
20+ occurrences across cases.spec.ts, intake.spec.ts, placement.spec.ts, exchange.spec.ts, error-paths.spec.ts.
// Anti-pattern: silently passes when element is missing
if (await element.isVisible({ timeout: 3000 }).catch(() => false)) {
// do something
}
// else: test does NOTHING — masks broken features
Fix strategy per occurrence:
-
Element MUST exist → Remove the catch, use
await expect(element).toBeVisible() -
Element is genuinely conditional (state-dependent) → Assert the expected alternative in the
elsebranch -
Test depends on prior test state → Skip with
test.skip()or restructure to be self-contained
P1: Pagination-Blind List Assertions
Tests use .data-table td/a with hasText to find items in tables.
If test-created data pushes seeded items off page 1, assertions fail.
Fix: Add a findInTable(page, text) helper that paginates through all pages until it finds the text or exhausts all pages.
Files Modified
| File | Change |
|---|---|
|
Add |
|
|
|
|
|
|
|
Remove 11 |
|
Remove 4 catches, narrow overly-broad flash regex, use |
|
Remove 4 catches, tighten inner conditionals |
|
Document 1 genuinely-conditional catch |
|
Replace catch with direct form-page assertion, replace |
What We’re NOT Changing (And Why)
-
data-testidattributes: Would touch 39 templates for marginal benefit; CSS selectors are stable because we control the HTML -
Seed data references: Deterministic and type-checked via TypeScript manifest; changes caught at compile time
-
Keycloak login selectors: Keycloak controls the login page;
#username,#password,#kc-loginare stable -
Test execution order: Sequential (1 worker) by design
-
Page object CSS selectors:
.data-table,.kv-key,.badge,.flash-banner__textare our own design system classes
Verification
-
cargo xtask dev restart— clean seed data -
cargo xtask e2e— all 83 tests pass -
Run E2E 3x to confirm stability
-
Manually verify that breaking a feature causes the previously-silent test to actually fail