E2E tests.

This commit is contained in:
2026-01-12 22:19:58 +00:00
parent dbf0c32588
commit 6e391a46be

View File

@@ -4,7 +4,7 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
## Current State Summary
### Overall Status: 849 tests passing across 44 test files
### Overall Status: 889 tests passing across 46 test files
### Library Implementation
| File | Status | Gap Analysis |
@@ -31,7 +31,7 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
| OIDC Authentication | specs/authentication.md | P2.18 | **COMPLETE** |
| Token Expiration Warnings | specs/email.md | P3.9 | **COMPLETE** |
### API Routes (18 total)
### API Routes (15 route files, 18 HTTP endpoints)
| Route | Status | Notes |
|-------|--------|-------|
| POST /api/auth/logout | **COMPLETE** | Clears pb_auth cookie, logs out user (5 tests) |
@@ -75,6 +75,8 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
| `MiniCalendar` | **COMPLETE** | Compact calendar widget with phase colors, navigation, legend (23 tests) |
| `OnboardingBanner` | **COMPLETE** | Setup prompts for new users with icons and action buttons, 16 tests |
| `MonthView` | **COMPLETE** | Calendar grid with DayCell integration, navigation controls, phase legend, keyboard navigation |
| `PeriodDateModal` | **COMPLETE** | Period date input modal with validation, error handling, accessibility (22 tests) |
| `Skeletons` | **COMPLETE** | Loading skeleton components for all dashboard sections with shimmer animation (29 tests) |
### Test Coverage
| Test File | Status |
@@ -122,7 +124,6 @@ This file is maintained by Ralph. Run `./ralph-sandbox.sh plan 3` to generate ta
| `src/components/calendar/day-cell.test.tsx` | **EXISTS** - 27 tests (phase coloring, today highlighting, click handling, accessibility) |
| `src/app/plan/page.test.tsx` | **EXISTS** - 16 tests (loading states, error handling, phase display, exercise reference, rebounding techniques) |
| `src/app/layout.test.tsx` | **EXISTS** - 3 tests (skip navigation link rendering, accessibility) |
| E2E tests | **AUTHORIZED SKIP** - Per specs/testing.md |
### Critical Business Rules (from Spec)
1. **Override Priority:** flare > stress > sleep > pms (must be enforced in order)
@@ -685,7 +686,7 @@ Testing, error handling, and refinements.
- Email includes days until expiry and instructions for refreshing tokens
- **Why:** Users need time to refresh tokens (per spec requirement in specs/email.md)
### P3.10: E2E Test Suite (AUTHORIZED SKIP)
### P3.10: E2E Test Suite
- [ ] Comprehensive end-to-end tests
- **Files:**
- `tests/e2e/*.spec.ts` - Full user flows
@@ -697,7 +698,6 @@ Testing, error handling, and refinements.
- Garmin connection flow
- Calendar subscription
- **Why:** Confidence in production deployment
- **Status:** Per specs/testing.md: "End-to-end tests are not required for MVP (authorized skip)"
### P3.11: Missing Component Tests ✅ COMPLETE
- [x] Add unit tests for untested components
@@ -789,7 +789,7 @@ Enhancements from spec requirements that improve user experience.
- `src/app/settings/loading.tsx` - Settings route loading
- `src/components/dashboard/skeletons.tsx` - Skeleton components (29 tests)
- **Why:** Perceived performance improvement
- **Verification:** Build succeeds, all 825 tests pass, Next.js handles 100ms target via automatic loading.tsx rendering
- **Verification:** Build succeeds, all 889 tests pass, Next.js handles 100ms target via automatic loading.tsx rendering
### P4.5: Period Prediction Accuracy Feedback ✅ COMPLETE
- [x] Mark predicted vs confirmed period dates
@@ -868,8 +868,12 @@ P4.* UX Polish ────────> After core functionality complete
| Done | P4.4 Loading Performance | Complete | Next.js loading.tsx provides 100ms target |
| Done | P4.5 Period Prediction | Complete | Prediction tracking with feedback loop |
| Done | P4.6 Rate Limiting | Complete | Client-side rate limiting implemented |
| **Medium** | P5.1 Period History UI | Medium | New page + 3 API routes |
| **Low** | P5.2 Toast Notifications | Low | Install library + integrate |
| **Low** | P5.3 CI Pipeline | Low | Single workflow file |
| **Low** | P5.4 E2E Tests | Medium | 6 missing test files |
**All P4 UX Polish items are now complete.**
**All P0-P4 items are complete. P5 contains remaining gaps identified during gap analysis (2026-01-12).**
@@ -976,10 +980,113 @@ Analysis of all specs vs implementation revealed these gaps:
| Logout functionality | authentication.md | **COMPLETE** | Added POST /api/auth/logout + settings button |
| Garmin sync structured logging | observability.md | **COMPLETE** | Added sync start/complete/failure logging |
| Email sent/failed logging | observability.md | **COMPLETE** | Email events now logged (info for success, error for failure) with structured data (userId, emailType, success) |
| Period history UI | cycle-tracking.md | **PENDING** | UI for viewing/editing past periods |
| Period history UI | cycle-tracking.md | **PENDING** | See P5.1 below |
| Dashboard color-coded backgrounds | dashboard.md | **COMPLETE** | DecisionCard shows RED/YELLOW/GREEN backgrounds per status (8 new tests) |
| Toast notifications | dashboard.md | **PENDING** | Success/error toasts for user actions |
| CI pipeline | testing.md | **PENDING** | GitHub Actions for test/lint/build |
| Toast notifications | dashboard.md | **PENDING** | See P5.2 below |
| CI pipeline | testing.md | **PARTIALLY COMPLETE** | See P5.3 below |
---
## P5: Remaining Gaps
These items were identified during gap analysis and remain pending.
### P5.1: Period History UI (PENDING)
- [ ] Create period history viewing and editing UI
- **Spec Reference:** specs/cycle-tracking.md lines 93-111
- **Required Features:**
- List of all logged period dates
- Calculated cycle lengths between periods
- Average cycle length over time
- Ability to edit/delete entries
- **Current State:**
- `/history` page exists but shows DailyLogs (training history), not PeriodLogs
- No UI for viewing period history
- No API routes for editing/deleting PeriodLog entries
- **Implementation Tasks:**
1. Create GET /api/period-history route (paginated list of PeriodLogs with calculated cycle lengths)
2. Create PATCH /api/period-logs/[id] route (edit period start date)
3. Create DELETE /api/period-logs/[id] route (delete period entry)
4. Create `/period-history` page with table view
5. Add average cycle length calculation
6. Add edit/delete UI with confirmation dialogs
- **Files to Create:**
- `src/app/api/period-history/route.ts` + tests
- `src/app/api/period-logs/[id]/route.ts` + tests
- `src/app/period-history/page.tsx` + tests
- **Why:** Users need to view and correct their period log history
### P5.2: Toast Notifications (PENDING)
- [ ] Add toast notification system for user feedback
- **Spec Reference:** specs/dashboard.md lines 88-96
- **Required Features:**
- Toast position: Bottom-right
- Auto-dismiss after 5 seconds
- Errors persist until dismissed
- Toast types: success, error, info
- **Example Messages (from spec):**
- Network errors: "Unable to fetch data. Retry?"
- Garmin sync failed: "Garmin data unavailable. Using last known values."
- Save errors: "Failed to save. Try again."
- **Current State:**
- Only inline error messages exist
- No toast library installed
- No toast component
- **Implementation Tasks:**
1. Install toast library (react-hot-toast or sonner recommended)
2. Create Toast provider in layout.tsx
3. Create useToast hook for consistent API
4. Replace inline errors with toast notifications across:
- Dashboard (override toggle errors)
- Settings (save success/error)
- Garmin settings (connection success/error)
- Calendar (token regeneration success/error)
- Period logging (confirmation/error)
- **Files to Create/Modify:**
- `src/components/ui/toaster.tsx` + tests
- `src/app/layout.tsx` (add provider)
- Various page components (replace inline errors)
- **Why:** Better UX for transient feedback per spec requirements
### P5.3: CI Pipeline (PARTIALLY COMPLETE)
- [ ] Add test/lint/build to CI pipeline
- **Spec Reference:** specs/testing.md mentions CI pipeline
- **Required:** "All tests (unit, integration, E2E) pass in CI before merge"
- **Current State:**
- Gitea Actions exists for deployment (services/phaseflow.hcl)
- Lefthook runs pre-commit hooks locally (lint + tests)
- No CI pipeline running tests on push/PR
- **Gap:** Tests/lint/build are enforced locally via Lefthook but not in CI
- **Implementation Tasks:**
1. Create `.gitea/workflows/ci.yml` (or equivalent for Gitea Actions)
2. Add jobs for: pnpm install, pnpm lint, pnpm tsc --noEmit, pnpm test:run
3. Configure to run on push to main and on PRs
4. (Optional) Add build step: pnpm build
- **Files to Create:**
- `.gitea/workflows/ci.yml`
- **Why:** CI enforcement prevents broken code from being merged
### P5.4: E2E Tests (PARTIALLY COMPLETE)
- [ ] Complete E2E test suite for all user flows
- **Spec Reference:** specs/testing.md
- **Current State:**
- Playwright infrastructure exists (`playwright.config.ts`)
- Smoke tests exist (`e2e/smoke.spec.ts` - 3 tests)
- **Missing E2E Test Files:**
- `e2e/auth.spec.ts` - Login/logout flows
- `e2e/dashboard.spec.ts` - Decision display, overrides
- `e2e/settings.spec.ts` - Preferences save
- `e2e/garmin.spec.ts` - Token management
- `e2e/period-logging.spec.ts` - Period start logging
- `e2e/calendar.spec.ts` - ICS feed, calendar view
- **Implementation Tasks:**
1. Create auth.spec.ts covering login/logout user journeys
2. Create dashboard.spec.ts covering decision display and override toggles
3. Create settings.spec.ts covering preferences save flow
4. Create garmin.spec.ts covering token management flow
5. Create period-logging.spec.ts covering period start logging
6. Create calendar.spec.ts covering ICS subscription and calendar view
- **Why:** Comprehensive E2E coverage ensures production reliability
### Previously Fixed Issues
@@ -1010,6 +1117,6 @@ Analysis of all specs vs implementation revealed these gaps:
11. **Health Check Priority:** P2.15 (GET /api/health) should be implemented early - it's required for deployment monitoring and load balancer health probes
12. **Structured Logging:** P2.17 (pino logger) is COMPLETE - new code should use `import { logger } from "@/lib/logger"` for all logging
13. **OIDC Authentication:** P2.18 COMPLETE - Login page auto-detects OIDC via `listAuthMethods()` and shows "Sign In with Pocket-ID" button when configured. Falls back to email/password when OIDC not available. Configure OIDC provider in PocketBase Admin under Settings → Auth providers → OpenID Connect
14. **E2E Tests:** Authorized skip per specs/testing.md - unit and integration tests are sufficient for MVP
15. **Dark Mode:** Partial Tailwind support exists via dark: classes but may need prefers-color-scheme configuration in tailwind.config.js (see P4.3)
16. **Component Tests:** P3.11 COMPLETE - All 5 dashboard and calendar components now have comprehensive unit tests (82 tests total)
15. **Dark Mode:** COMPLETE - Auto-detects system preference via prefers-color-scheme media query (P4.3)
16. **Component Tests:** P3.11 COMPLETE - All 5 dashboard and calendar components now have comprehensive unit tests (90 tests total)
17. **Gap Analysis (2026-01-12):** Verified 889 tests across 46 files. All API routes (18), pages (7), components, and lib files (12) have tests. P0-P4 complete. Remaining gaps (Period History UI, Toast Notifications, CI Pipeline, E2E Tests) documented in P5.