🐛 Isolate Playwright E2E DB and add live-target guardrails#53
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive E2E test isolation infrastructure to prevent accidental data corruption during Playwright test runs. The implementation introduces a harness-managed local API with disposable SQLite databases, enforces localhost-only API targets by default, and adds explicit safety guardrails that fail fast if unsafe targets are detected.
Changes:
- Added Playwright global setup/teardown to spawn an isolated API process with a unique disposable DB for each E2E run
- Implemented safety guardrails that block non-localhost API targets unless explicitly overridden with
ALLOW_NON_ISOLATED_E2E=1 - Added backend
API_BIND_ADDRconfiguration support to enable E2E harness orchestration - Refactored E2E tests to use stable selectors and wait for API responses to improve reliability
- Updated documentation to describe safe E2E workflow and validation requirements
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| sleep-ui/tests/global.setup.ts | New global setup that spawns isolated API with disposable DB, validates safety preconditions, and waits for API readiness |
| sleep-ui/tests/global.teardown.ts | New global teardown that terminates spawned API process and cleans up DB artifacts |
| sleep-ui/tests/e2e.spec.ts | Refactored tests to use helper functions for stable selectors, wait for API responses, and handle conditional fields |
| sleep-ui/tests/auth.setup.ts | Added safety assertions to prevent running auth bootstrap against unsafe targets |
| sleep-ui/playwright.config.ts | Integrated global setup/teardown, added URL validation, configured webServer to use isolated API |
| sleep-ui/package.json | Added test:e2e:safe script alias (redundant with test:e2e) |
| sleep-ui/README.md | Documented safe E2E workflow and explicit bypass mechanism |
| sleep-api/src/main.rs | Updated to use configurable bind address from API_BIND_ADDR env var |
| sleep-api/src/config.rs | Added api_bind_addr() function with default 0.0.0.0:8080 |
| docs/coding-agent/references/validation.md | Updated with E2E isolation validation requirements and canonical commands |
| docs/coding-agent/references/how-to-run.md | Documented API/UI runtime requirements, bind address config, and E2E workflows |
| docs/coding-agent/plans/active/sleep-ui-e2e-db-isolation-guardrails-plan.md | Added comprehensive plan document describing isolation approach and validation strategy |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Addressed review follow-ups from PR53:
Validation rerun:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Correction to previous note (plain text): Addressed newest PR53 feedback and main conflict.
Validation evidence:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 10 comments.
Comments suppressed due to low confidence (1)
docs/coding-agent/plans/active/pr53-unresolved-comments-and-main-conflict-resolution-plan.md:120
- This plan document describes future work to resolve PR #53 review comments and merge conflicts. It's unusual to include a plan for future PR revisions within the PR itself, as this creates a circular reference (the PR contains a plan to fix the PR).
Consider keeping such plans external to the PR (in a separate branch or working directory) until the work is complete, or mark them more clearly as "meta-documentation" that tracks the evolution of the PR. The current inclusion isn't harmful but may be confusing to reviewers who expect plan documents to describe completed or in-progress work, not future iterations.
# PR53 Unresolved Comments and Main Conflict Resolution Plan
- status: draft
- owner: orchestrator
- work_type: mixed
- created: 2026-02-22
## Goal
Resolve new unresolved PR #53 review comments (must + should as requested) and cleanly merge `origin/main` into `feat/e2e-db-isolation-guardrails` without regressions.
## Definition of Done
- New unresolved **must** comments are fixed:
- bypass runtime-state write path creates parent runtime dir.
- teardown termination is reliable for Unix detached/process-group behavior.
- New unresolved **should** comment is addressed:
- readiness predicate in setup is tightened from broad `<500` behavior.
- Branch is rebased/merged with `origin/main` and has no unresolved conflicts.
- Required validations pass and PR #53 is updated with response notes.
## Scope
- `sleep-ui/tests/global.setup.ts`
- `sleep-ui/tests/global.teardown.ts`
- `sleep-ui/src/routes/login/+page.svelte` (merge conflict)
- PR #53 thread responses and validation evidence
## Non-goals
- No broad E2E harness redesign.
- No unrelated UI/test refactors.
- No backend behavior changes beyond what is needed for comment/conflict resolution.
## Task Waves
- Wave 1 (sequential triage): `Task_1`
- Wave 2 (parallel implementation): `Task_2`, `Task_3`, `Task_4`
- Wave 3 (sequential verification): `Task_5`
## Tasks
### Task_1
- type: research
- title: Confirm unresolved comments and merge conflict targets
- owns:
- PR #53 review thread metadata
- merge-base status with `origin/main`
- depends_on: []
- acceptance:
- unresolved items are classified into must/should.
- exact conflicted file list is confirmed.
- validation:
- required: true
owner: orchestrator
kind: review
detail: Classification accepted before edits.
### Task_2
- type: impl
- title: Fix runtime-state bypass path and readiness strictness
- owns:
- `sleep-ui/tests/global.setup.ts`
- depends_on: [Task_1]
- acceptance:
- `ALLOW_NON_ISOLATED_E2E=1` path cannot fail from missing runtime dir.
- readiness probe checks expected successful/known states (not generic `<500`).
- validation:
- required: true
owner: worker
kind: command
detail: targeted auth smoke passes and unsafe/bypass paths behave as expected.
### Task_3
- type: impl
- title: Harden teardown for detached process cleanup on Unix
- owns:
- `sleep-ui/tests/global.teardown.ts`
- depends_on: [Task_1]
- acceptance:
- teardown targets detached process group on Unix where needed.
- DB cleanup runs with retry only after termination attempts.
- validation:
- required: true
owner: worker
kind: command
detail: `npm run test:e2e:auth` finishes without leaked API process symptoms.
### Task_4
- type: impl
- title: Resolve merge conflict with origin/main in login page
- owns:
- `sleep-ui/src/routes/login/+page.svelte`
- depends_on: [Task_1]
- acceptance:
- preserve both `method="post" action="/api/login"` and incoming `data-testid` form hook.
- no conflict markers remain.
- validation:
- required: true
owner: worker
kind: command
detail: `git diff --name-only --diff-filter=U` is empty after merge.
### Task_5
- type: validation
- title: Run required validations and post PR53 updates
- owns:
- `sleep-ui/**`
- depends_on: [Task_2, Task_3, Task_4]
- acceptance:
- `npm run check` and `npm run test:unit` pass.
- `npm run test:e2e:auth` pass.
- PR #53 comment with resolution mapping is posted.
- validation:
- required: true
owner: worker
kind: command
detail: `cd sleep-ui && npm run check && npm run test:unit && npm run test:e2e:auth`
## Progress Log
- 2026-02-22: Drafted from Researcher triage of newest unresolved threads and merge conflict.
## Decision Log
- 2026-02-22: Treat two teardown/setup threads as must-fix and readiness strictness as should-fix per user request to address both categories.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Validation