# Routines Feature E2E Plan ## Application Overview The routines feature adds a new parent-defined checklist entity that sits between chores and rewards in child mode. A routine is confirmed as a whole (not per-item), then approved or rejected by the parent. Routine visibility and state are schedule-aware, include deadline extension support, and support per-child point overrides. This plan is intentionally implementation-driven so we can incrementally add tests as each phase ships. --- ## Coverage Areas ### 1. Parent Routine Library Management File target: e2e/mode_parent/routines/routine-library.spec.ts 1. Parent can create a routine with name, points, image. 2. Parent can add multiple routine items and persist item order. 3. Parent can edit routine metadata and item metadata. 4. Parent can delete a routine item. 5. Parent can delete a routine and it disappears from routine library list. ### 2. Parent Child Assignment and Management File target: e2e/mode_parent/routines/routine-assignment.spec.ts 1. Parent can assign routine to a child from assignable list. 2. Parent can remove routine assignment from child. 3. Parent can set/replace full routine assignment list for a child. 4. Parent can set routine point override and child-facing value reflects override. 5. Parent can set routine schedule and update it later. 6. Parent can extend routine deadline for today. ### 3. Child Routine Rendering and Navigation File target: e2e/mode_child/routines/routine-visibility.spec.ts 1. Routines list renders between chores and rewards. 2. Clicking a routine opens routine detail route (/child/:id/routine/:routineId). 3. Detail view shows routine image, title, points, and non-interactive item list. 4. Back navigation returns to child main view. ### 4. Child Routine Confirmation Flow File target: e2e/mode_child/routines/routine-confirmation.spec.ts 1. Child can mark routine Done; routine becomes pending. 2. Child can cancel a pending routine confirmation. 3. Child cannot submit duplicate pending confirmations. 4. Approved-today routine shows completed state on child UI. 5. Rejected routine returns to available state. ### 5. Parent Pending Confirmation Flow File target: e2e/mode_parent/routines/routine-approval.spec.ts 1. Routine confirmation appears in parent notification/pending list. 2. Parent can approve routine; child points increase by default routine points. 3. Parent can reject routine; child points do not change. 4. Parent can reset approved/rejected routine to clear completion state. 5. If routine override exists, approval uses override points instead of base points. ### 6. Routine Scheduling and Deadline Behavior File target: e2e/mode_child/routines/routine-schedule.spec.ts 1. Day-based schedules only show routines on scheduled days. 2. Interval schedules show/hide routines on expected interval dates. 3. Routine with deadline in the past displays TOO LATE and blocks Done. 4. Extending deadline removes TOO LATE state for that day. 5. Changing schedule resets stale pending status. ### 7. Cascade and Data Integrity File target: e2e/mode_parent/routines/routine-cascade.spec.ts 1. Deleting routine removes it from all assigned children. 2. Deleting routine removes routine items. 3. Deleting routine removes routine schedules and extensions. 4. Deleting routine removes routine point overrides. 5. Deleting child removes child routine schedules/extensions/overrides. ### 8. SSE Reactivity File target: e2e/multi-session/routines/routine-sse.spec.ts 1. Parent routine add/edit/delete updates child assignment views without refresh. 2. Child routine pending/approved/rejected/reset updates parent notification UI without refresh. 3. Schedule/extension changes update child routine card state without refresh. 4. Override changes update points display without refresh. --- ## Test Data and Execution Notes 1. Use API seeding in beforeAll and cleanup in afterAll per spec file. 2. Use stable role/label-based locators only. 3. Avoid /auth/login navigation in tests; rely on global storageState. 4. For time-sensitive schedule tests, set deterministic times (or use clock controls where practical). --- ## Unit Test Expansion Checklist ### Backend unit tests to add during implementation 1. Routine CRUD API validation and ownership checks. 2. Routine item CRUD and ordering behavior. 3. Child routine assignment list and assignable-list filtering. 4. Routine confirmation approve/reject/reset state transitions. 5. Routine schedule and extension endpoints (including duplicate extension conflict). 6. Routine deletion cascades (items/schedules/extensions/overrides/child assignments). ### Frontend unit tests to add during implementation 1. API helper coverage for routine endpoints. 2. ScheduleModal entityType routing behavior for task vs routine. 3. Child routine list sorting/filtering utility behavior. 4. Routine detail confirmation UI state transitions. 5. Parent pending confirmation card rendering for entity_type='routine'.