Fix critical bug: cycle phase boundaries now scale with cycle length

CRITICAL BUG FIX:
- Phase boundaries were hardcoded for 31-day cycle, breaking correct
  phase calculations for users with different cycle lengths (28, 35, etc.)
- Added getPhaseBoundaries(cycleLength) function in cycle.ts
- Updated getPhase() to accept cycleLength parameter (default 31)
- Updated all callers (API routes, components) to pass cycleLength
- Added 13 new tests for phase boundaries with 28, 31, and 35-day cycles

ICS IMPROVEMENTS:
- Fixed emojis to match calendar.md spec: 🩸🌱🌸🌙🌑
- Added CATEGORIES field for calendar app colors per spec:
  MENSTRUAL=Red, FOLLICULAR=Green, OVULATION=Pink,
  EARLY_LUTEAL=Yellow, LATE_LUTEAL=Orange
- Added 5 new tests for CATEGORIES

Updated IMPLEMENTATION_PLAN.md with discovered issues and test counts.

825 tests passing (up from 807)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-11 22:39:09 +00:00
parent 58f6c5605a
commit a977934c23
15 changed files with 337 additions and 148 deletions

View File

@@ -354,8 +354,8 @@ describe("GET /api/today", () => {
});
it("returns days until next phase", async () => {
// Cycle day 10 in FOLLICULAR (days 4-14)
// Next phase (OVULATION) starts day 15, so 5 days away
// Cycle day 10 in FOLLICULAR (days 4-15 for 31-day cycle)
// Next phase (OVULATION) starts day 16, so 6 days away
currentMockUser = createMockUser({
lastPeriodDate: new Date("2025-01-01"),
});
@@ -366,7 +366,7 @@ describe("GET /api/today", () => {
expect(response.status).toBe(200);
const body = await response.json();
expect(body.daysUntilNextPhase).toBe(5);
expect(body.daysUntilNextPhase).toBe(6);
});
});