fix(e2e): harden card selectors for session resume
All checks were successful
Mirror to GitHub / mirror (push) Successful in 12s
CI / frontend (pull_request) Successful in 5m43s
CI / backend (pull_request) Successful in 10m21s
CI / e2e (pull_request) Successful in 11m23s

Co-Authored-By: Codex <noreply@openai.com>
This commit is contained in:
2026-04-25 16:42:33 -04:00
parent ede6eebf9a
commit 1e3a6cfa01
13 changed files with 76 additions and 65 deletions

View File

@@ -2,54 +2,52 @@
# HANDOFF.md
**Last updated:** 2026-04-25 (America/New_York)
**Last updated:** 2026-04-25 16:41 EDT
**Active task:** Land PR #150 (the consolidated CI-recovery PR), then enable backend + e2e gates on `main`. See [CURRENT_TASK.md](CURRENT_TASK.md).
**Active task:** Land PR #150 (the consolidated CI-recovery PR), then enable backend and eventually e2e gates on `main`. See [CURRENT_TASK.md](CURRENT_TASK.md).
**Branch:** `fix/ci-workflow-config` PR #150. PRs #151 and #152 were closed and consolidated into this branch — one PR is easier to land than three stacked ones, and the user got tired of waiting on serial CI runs of intermediate states.
**Branch:** `fix/ci-workflow-config` -> PR #150. PRs #151 and #152 were closed and consolidated into this branch.
**Runner setup:** Three Gitea Actions agents are registered on the homelab box, so `backend` / `frontend` / `e2e` jobs run truly in parallel. Combined with the xdist parallelization and the e2e decoupling in this PR, the previous 1h 14m wall-clock should drop to ~9 min.
## Current resume point
## What's on PR #150's branch (consolidated)
Latest PR #150 CI had backend and frontend green, but `CI / e2e (pull_request)` failed on the resume smoke test.
Seven CI-recovery commits that landed together because they were inter-dependent:
The failure was not product behavior. Playwright was using:
1. **Codex's `49f8856 wip(handoff): restore backend suite to green`** — fixes the 54 real backend test failures left after #149.
2. **Workflow correctness:** `DATABASE_TEST_URL` env, `actions/upload-artifact` v3 pin (Gitea Actions doesn't support v4+).
3. **Test-fix + cheap CI wins (`e976fb4`):** mocks `_extract_template_parameters` in `test_record_decision_persists_and_bumps_state_version` so it doesn't need an AI provider key; pip + npm caches; `--cov-report=term-missing` dropped (the custom display step parses JSON); `--maxfail=10` so structural breakage exits fast.
4. **Postgres port-collision fix (`1bd43ab`):** dropped `ports: 5432:5432` host mapping. With three Gitea runner agents now active, two parallel jobs would race on `0.0.0.0:5432`. Tests connect via the `postgres` service-DNS hostname, not the host, so the mapping wasn't actually needed.
5. **pytest-xdist with per-worker DBs (`7f71436`):** `pytest-xdist==3.6.1` added; `conftest.py` derives a per-worker DB URL from `PYTEST_XDIST_WORKER` and creates it synchronously on first import. Verified on PR #151's CI run before consolidation: 22m serial → 9m37s on the 4-core runner.
6. **Five e2e selector updates (`69f2a37`):** drift from the FlowPilot/PSA migration. `Sessions``Session History`, `Account Settings``Account Management`, `/assistant` accepts `/pilot`, "Flow Sessions" tab clicks for ticket/client filtering and Resume on `/sessions`.
7. **e2e decoupled from frontend (`261814a`):** dropped `needs: [frontend]` and the cross-job artifact handoff. e2e now builds its own frontend (npm ci + npm run build are already in the job). Adds ~1-2 min to the e2e job duration but removes the ~5 min of waiting for frontend to finish, and gets rid of the cross-job `actions/upload-artifact` mechanism entirely. e2e starts immediately on the third runner.
```ts
page.locator('.bg-card').filter({ hasText: tree.name }).first()
```
## Expected wall-clock on the next CI run
On the session history page this matched the tree filter `<select>` first because the select options contain the same flow name, then the test waited forever for a `Resume` button inside the select.
| Job | Duration | Starts at |
|---|---|---|
| backend | ~9 min (xdist on 4-core CI runner) | minute 0 |
| frontend | ~6 min | minute 0 |
| e2e | ~7 min (now self-builds) | minute 0 |
This session fixed that properly by adding stable test IDs to repeated cards and moving e2e tests off `.bg-card` selectors:
Total wall-clock: ~9 min (whichever job runs longest), down from 1h 14m.
- `flow-session-card` in `SessionHistoryPage.tsx`
- `tree-card` in `TreeGridView.tsx` and `TreeListView.tsx`
- `share-card` in `MySharesPage.tsx`
The workflow was also hardened:
- Postgres service healthchecks now run `pg_isready -U postgres` instead of checking as `root`.
- The e2e frontend build now bakes `VITE_API_URL="${PLAYWRIGHT_API_ORIGIN}"`, matching the Playwright backend origin.
## Verification completed
- `git diff --check`
- Confirmed no remaining `.bg-card` selectors in `frontend/e2e/*.ts`.
- `docker exec -w /app resolutionflow_frontend npm run build`
- Ran migrations and test-user seed in the dev backend container.
- Focused Playwright verification in an Actions-like Ubuntu container:
- First `e2e/resume.spec.ts` passed.
- Then `e2e/history.spec.ts e2e/library.spec.ts e2e/library-start.spec.ts e2e/resume.spec.ts e2e/shares.spec.ts --project=chromium --workers=1` passed: `6 passed (1.3m)`.
## Immediate next steps
1. **Watch PR #150's CI** on its latest sha (`261814a`). All three jobs should run concurrently and finish within ~9 min total.
2. **Merge PR #150** when all three jobs are green.
3. **Enable backend gate** on `main` branch protection — append `"CI / backend (pull_request)"` to `status_check_contexts`:
```bash
curl -X PATCH -H "Authorization: token $GITEA_TOKEN" \
"https://gitea.resolutionflow.com/api/v1/repos/chihlasm/resolutionflow/branch_protections/main" \
-H "Content-Type: application/json" \
-d '{"status_check_contexts": ["CI / frontend (pull_request)", "CI / backend (pull_request)"]}'
```
4. **Then enable `CI / e2e (pull_request)`** — same PATCH, append to the list. Verify e2e is reliably green for at least one PR run before locking it in.
PRs #151 (`fix/ci-pytest-xdist`) and #152 (`fix/e2e-test-selectors`) were closed as superseded by this PR.
## Uncommitted state
Working tree clean (after this handoff commit).
1. Push the WIP commit from this session to PR #150.
2. Watch PR #150 CI on the new SHA. Expected result: backend, frontend, and e2e all green.
3. Merge PR #150 when green.
4. Enable `CI / backend (pull_request)` as a required status check on `main`.
5. After at least one reliable green PR run, consider adding `CI / e2e (pull_request)` as required too.
## Branch protection on main (current)
@@ -58,21 +56,9 @@ Working tree clean (after this handoff commit).
- Force-push blocked
- No review required (solo)
## Recently merged on main
- `f27f671` — PR #149: fix(ci): frontend lint to zero errors + test-DB schema fix + dev-deps installable
- `06593a4` — PR #148: fix(tests): repair two pre-existing bugs blocking backend CI
- `32fae2c` — PR #147: feat: FlowPilot migration — Phase 1-9 + Phase 9 bug fixes + QA fixture harness
- `16060d2` — PR #141: feat: PSA ticket management
## Open questions
- One known concern with `--maxfail=10`: if a single bad commit produces 11+ legitimate failures, CI bails before reporting them all. Acceptable trade-off — the alternative is burning 25 min on a structural break.
- pytest-xdist load distribution is the default file-scoped balance. If one worker consistently gets the slow tests, switch to `--dist worksteal` (xdist 3.x). Not worth tuning preemptively.
## Useful breadcrumbs
- `.gitea/workflows/ci.yml` contains the parallel backend/frontend/e2e workflow.
- `backend/scripts/seed_phase9_qa_fixtures.py` pre-bakes Phase 9 QA fixtures.
- `.gstack/qa-reports/phase9-20260424-232700/REPORT.md` — full QA report from the FlowPilot session.
- gstack is in team mode for this repo. `/browse` Chromium needs `CONTAINER=1` env (see `~/.claude/skills/gstack/browse/src/browser-manager.ts:188`).
- Per-worker test DBs accumulate on the postgres service. Cheap to leave around; cleanup if it ever bothers anyone.
- `.gstack/qa-reports/phase9-20260424-232700/REPORT.md` has the FlowPilot QA report.
- Per-worker test DBs accumulate on the Postgres service. Cheap to leave around; cleanup if needed.