Add High-Priority Playwright E2E Coverage for Trips #41

Closed
opened 2026-02-22 21:25:09 +00:00 by shaun · 2 comments
Owner

Task: Add High-Priority Playwright E2E Coverage for Trips

Objective

Implement high-priority e2e scenarios in trips using Playwright, with deterministic seeded data and optional one-off video capture for issue evidence.

Existing Context

  • Playwright config: playwright.config.ts
  • E2E folder: e2e/
  • Seed script: e2e/setup/seed-db.ts
  • Seeded users: e2e/setup/test-users.ts
    • regular: e2e_user / e2e-regular-password123
    • admin: e2e_admin / e2e-admin-password123
  • Existing tests:
    • e2e/auth.test.ts
    • e2e/trip-planning.test.ts

Requirements

  1. Add tests for:

    • login callback/redirect behavior
    • admin creates local-login user, new user can sign in
    • admin users table auth source visibility and local-password action behavior
    • incomplete-but-valid future trip planning (ensure this scenario is covered; extend/refactor existing trip planning test if already present)
  2. Keep tests deterministic:

    • use unique suffixes (Date.now()) for usernames/emails/trip names
    • no hard waits/sleeps; use role/URL/assertion waits only
  3. Prefer robust locators:

    • getByRole, getByLabel, getByText, aria-label
    • avoid brittle CSS selectors unless no accessible alternative exists
  4. Maintain existing style:

    • helper functions in test files for login/common actions
    • clear test names
    • single worker compatible

Test Cases to Implement

A) Login callback/redirect regression

File: e2e/auth-callback.test.ts (or fold into e2e/auth.test.ts)

Scenario:

  1. Start logged out.
  2. Navigate directly to protected route, e.g. /trips/upcoming.
  3. Verify redirect to /trips/login.
  4. Sign in locally as regular user.
  5. Assert final location is app route (not /trips/auth/...).
  6. Preferred assertion: lands on originally intended protected page if supported; otherwise assert safe app landing (/trips/dashboard or /trips/upcoming) and never auth callback endpoint.

Goal:

  • Catch regressions where callback URL points to auth endpoint or wrong base path.

B) Admin creates local user, new user signs in

File: e2e/admin-local-user-flow.test.ts

Scenario:

  1. Login as admin (e2e_admin).
  2. Go to /trips/admin/users.
  3. Click Add User.
  4. Fill:
    • username: unique (e2e_new_user_${timestamp})
    • full name
    • email: unique test email
    • password + confirm (>=12 chars)
  5. Submit and verify user row appears in table.
  6. Clear cookies / new context.
  7. Login as the new user via local login form.
  8. Assert successful landing on dashboard and non-admin access restrictions still apply (optional quick check: /trips/admin/users redirects away).

Goal:

  • Verify end-to-end admin provisioning + real credential use.

C) Auth source display + local credentials action visibility/behavior

File: e2e/admin-auth-source.test.ts

Scenario:

  1. Login as admin.
  2. Open /trips/admin/users.
  3. Locate rows for seeded users.
  4. Assert Auth source column renders expected labels for local users.
  5. Open Set local password action (aria-label="Set local password") for a user.
  6. Validate drawer behavior:
    • required/length/match validation messages appear for invalid input
    • successful save closes drawer and returns to table

Goal:

  • Lock down admin user-management UI behavior around auth source and local credential controls.

D) Future trip with unknown end date and plans visible

File: e2e/trip-planning.test.ts (extend existing) or e2e/trip-planning-minimal-future.test.ts

Scenario:

  1. Login as regular user.
  2. Plan new trip:
    • future start date
    • blank end date
    • description
  3. Add:
    • logged-in traveler
    • one new traveler
    • destination
    • flight
    • lodging
  4. Return to upcoming trips; assert new trip exists.
  5. Open trip; assert sections and entered plan details visible.

Goal:

  • Ensure key planning workflow works when end date is intentionally unknown.

Refactoring Expectations

  • If helpers are duplicated across files, extract shared helpers into e2e/helpers/ (optional, keep simple).
  • Do not weaken existing passing coverage.
  • If existing trip-planning.test.ts already covers D sufficiently, keep/clean it instead of creating duplicate scenario.

Execution Commands

  • Normal run:
    • bunx playwright test
  • One-off evidence run with trace + video:
    • PW_TRACE_MODE=on PW_VIDEO_MODE=on bunx playwright test e2e/admin-local-user-flow.test.ts
  • Open report:
    • bunx playwright show-report

Acceptance Criteria

  • All e2e tests pass locally.
  • New tests are stable across 2 consecutive runs.
  • Tests do not depend on manual DB state (seeded setup only).
  • No use of --video=on CLI flag (unsupported here); must use env vars (PW_VIDEO_MODE, PW_TRACE_MODE).

Deliverables

  1. New/updated test files under e2e/
  2. Any helper extraction files under e2e/helpers/ (if needed)
  3. Short summary in PR description:
    • scenarios added
    • command used for one-off video capture
    • where video artifact is produced (test-results/.../video.webm)
# Task: Add High-Priority Playwright E2E Coverage for Trips ## Objective Implement high-priority e2e scenarios in `trips` using Playwright, with deterministic seeded data and optional one-off video capture for issue evidence. ## Existing Context - Playwright config: `playwright.config.ts` - E2E folder: `e2e/` - Seed script: `e2e/setup/seed-db.ts` - Seeded users: `e2e/setup/test-users.ts` - regular: `e2e_user` / `e2e-regular-password123` - admin: `e2e_admin` / `e2e-admin-password123` - Existing tests: - `e2e/auth.test.ts` - `e2e/trip-planning.test.ts` ## Requirements 1. Add tests for: - login callback/redirect behavior - admin creates local-login user, new user can sign in - admin users table auth source visibility and local-password action behavior - incomplete-but-valid future trip planning (ensure this scenario is covered; extend/refactor existing trip planning test if already present) 2. Keep tests deterministic: - use unique suffixes (`Date.now()`) for usernames/emails/trip names - no hard waits/sleeps; use role/URL/assertion waits only 3. Prefer robust locators: - `getByRole`, `getByLabel`, `getByText`, `aria-label` - avoid brittle CSS selectors unless no accessible alternative exists 4. Maintain existing style: - helper functions in test files for login/common actions - clear test names - single worker compatible ## Test Cases to Implement ### A) Login callback/redirect regression File: `e2e/auth-callback.test.ts` (or fold into `e2e/auth.test.ts`) Scenario: 1. Start logged out. 2. Navigate directly to protected route, e.g. `/trips/upcoming`. 3. Verify redirect to `/trips/login`. 4. Sign in locally as regular user. 5. Assert final location is app route (not `/trips/auth/...`). 6. Preferred assertion: lands on originally intended protected page if supported; otherwise assert safe app landing (`/trips/dashboard` or `/trips/upcoming`) and never auth callback endpoint. Goal: - Catch regressions where callback URL points to auth endpoint or wrong base path. ### B) Admin creates local user, new user signs in File: `e2e/admin-local-user-flow.test.ts` Scenario: 1. Login as admin (`e2e_admin`). 2. Go to `/trips/admin/users`. 3. Click `Add User`. 4. Fill: - username: unique (`e2e_new_user_${timestamp}`) - full name - email: unique test email - password + confirm (>=12 chars) 5. Submit and verify user row appears in table. 6. Clear cookies / new context. 7. Login as the new user via local login form. 8. Assert successful landing on dashboard and non-admin access restrictions still apply (optional quick check: `/trips/admin/users` redirects away). Goal: - Verify end-to-end admin provisioning + real credential use. ### C) Auth source display + local credentials action visibility/behavior File: `e2e/admin-auth-source.test.ts` Scenario: 1. Login as admin. 2. Open `/trips/admin/users`. 3. Locate rows for seeded users. 4. Assert `Auth source` column renders expected labels for local users. 5. Open `Set local password` action (`aria-label="Set local password"`) for a user. 6. Validate drawer behavior: - required/length/match validation messages appear for invalid input - successful save closes drawer and returns to table Goal: - Lock down admin user-management UI behavior around auth source and local credential controls. ### D) Future trip with unknown end date and plans visible File: `e2e/trip-planning.test.ts` (extend existing) or `e2e/trip-planning-minimal-future.test.ts` Scenario: 1. Login as regular user. 2. Plan new trip: - future start date - blank end date - description 3. Add: - logged-in traveler - one new traveler - destination - flight - lodging 4. Return to upcoming trips; assert new trip exists. 5. Open trip; assert sections and entered plan details visible. Goal: - Ensure key planning workflow works when end date is intentionally unknown. ## Refactoring Expectations - If helpers are duplicated across files, extract shared helpers into `e2e/helpers/` (optional, keep simple). - Do not weaken existing passing coverage. - If existing `trip-planning.test.ts` already covers D sufficiently, keep/clean it instead of creating duplicate scenario. ## Execution Commands - Normal run: - `bunx playwright test` - One-off evidence run with trace + video: - `PW_TRACE_MODE=on PW_VIDEO_MODE=on bunx playwright test e2e/admin-local-user-flow.test.ts` - Open report: - `bunx playwright show-report` ## Acceptance Criteria - All e2e tests pass locally. - New tests are stable across 2 consecutive runs. - Tests do not depend on manual DB state (seeded setup only). - No use of `--video=on` CLI flag (unsupported here); must use env vars (`PW_VIDEO_MODE`, `PW_TRACE_MODE`). ## Deliverables 1. New/updated test files under `e2e/` 2. Any helper extraction files under `e2e/helpers/` (if needed) 3. Short summary in PR description: - scenarios added - command used for one-off video capture - where video artifact is produced (`test-results/.../video.webm`)
shaun added the ai-agent label 2026-02-22 21:25:09 +00:00
ai-agent was assigned by cicd 2026-02-22 21:25:11 +00:00
Member

PR create attempt failed.

Command:
tea pulls create --login ai-agent --repo campbellwireless/trips --head "ai-agent/41-add-high-priority-playwright-e2e-coverage-for-trips" --base main --title "Add high-priority Playwright trips coverage" --body "## Summary\n- add auth callback redirect coverage for protected routes\n- add admin user provisioning flow with new user sign-in\n- validate auth source display and local password drawer behavior\n- clarify trip planning coverage for unknown end date\n\n## Video Evidence\n- Capture command: \n- Artifact path: \n\n## Testing\n- Not run (bunx not found in environment)" --assignees shaun

Stderr:
Incorrect Usage: flag provided but not defined: -body

Error: flag provided but not defined: -body

PR create attempt failed. Command: tea pulls create --login ai-agent --repo campbellwireless/trips --head "ai-agent/41-add-high-priority-playwright-e2e-coverage-for-trips" --base main --title "Add high-priority Playwright trips coverage" --body "## Summary\n- add auth callback redirect coverage for protected routes\n- add admin user provisioning flow with new user sign-in\n- validate auth source display and local password drawer behavior\n- clarify trip planning coverage for unknown end date\n\n## Video Evidence\n- Capture command: \n- Artifact path: \n\n## Testing\n- Not run (bunx not found in environment)" --assignees shaun Stderr: Incorrect Usage: flag provided but not defined: -body Error: flag provided but not defined: -body
Member

AI orchestration has started.

  • Assigned to: @ai-agent
  • Planned branch: ai-agent/41-add-high-priority-playwright-e2e-coverage-for-trips
  • Worker state: started
  • OpenCode session: ses_378c2065affevTJCQ4vgcH1FoQ

When the worker needs clarification, it should comment here and pause until a reply arrives.

AI orchestration has started. - Assigned to: @ai-agent - Planned branch: `ai-agent/41-add-high-priority-playwright-e2e-coverage-for-trips` - Worker state: started - OpenCode session: `ses_378c2065affevTJCQ4vgcH1FoQ` When the worker needs clarification, it should comment here and pause until a reply arrives.
shaun closed this issue 2026-02-22 22:30:55 +00:00
Sign in to join this conversation.
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: campbellwireless/trips#41