feat: 16.0 - Frontend - Delete habit with confirmation

This commit is contained in:
Echo
2026-02-10 13:29:29 +00:00
parent 0f9c0de1a2
commit 46dc3a5041
4 changed files with 474 additions and 5 deletions

View File

@@ -578,3 +578,41 @@ NEXT STEPS:
Files modified:
- dashboard/habits.html (enhanced mobile CSS, added input attributes)
- dashboard/test_habits_mobile.py (created)
[✓] Story 15.0: Backend - Delete habit endpoint
Commit: 0f9c0de
Date: 2026-02-10
Implementation:
- Added do_DELETE method to api.py for handling DELETE requests
- Route: DELETE /api/habits/{id} deletes habit by ID
- Extracts habit ID from URL path (/api/habits/{id})
- Returns 404 if habit not found in habits.json
- Removes habit from habits array using list.pop(index)
- Updates lastUpdated timestamp after deletion
- Returns 200 with success message, including deleted habit ID
- Graceful error handling for missing/corrupt habits.json (returns 404)
- Follows existing API patterns (similar to handle_habits_check)
- Error responses include descriptive error messages
Tests:
- Created dashboard/test_habits_delete.py with 6 comprehensive tests
- Tests for habit removal from habits.json file (AC1)
- Tests for 200 status with success message response (AC2)
- Tests for 404 when habit not found (AC3)
- Tests for lastUpdated timestamp update (AC4)
- Tests for edge cases: deleting already deleted habit, invalid paths
- Tests for graceful handling when habits.json is missing
- All 6 tests pass ✓ (AC5)
- All previous tests (schema, GET, POST, streak, check) still pass ✓
Files modified:
- dashboard/api.py (added do_DELETE method and handle_habits_delete)
- dashboard/test_habits_delete.py (created)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
NEXT STEPS:
- Continue with remaining 2 stories (16.0, 17.0)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━