tududi/backend/tests
Chris 077addadde
Fix recurring task initial due date calculation to match recurrence pattern (#965)
* Fix recurring task initial due date calculation to match recurrence pattern

Resolves #963

When creating a recurring task without an explicit due date, the system
was incorrectly setting it to "today" regardless of the recurrence pattern.
This caused issues where:
- Monthly tasks set to recur on a specific day (e.g., 28th) would show the
  wrong due date (today/yesterday instead of the 28th)
- Tasks wouldn't appear correctly in the Upcoming view
- The base due_date didn't match the recurrence_month_day setting

Changes:
- Add calculateInitialDueDate() helper to compute correct first occurrence
- For monthly recurrence with specific day: calculate next occurrence of that day
- For weekly recurrence with specific weekday: calculate next occurrence of that weekday
- For other types (daily, etc.): maintain current behavior (use today)
- Apply same logic to both task creation and updates

Tests:
- Add comprehensive test suite (9 new tests) covering:
  - Monthly recurrence with future day in current month
  - Monthly recurrence with past day (should use next month)
  - Weekly recurrence with specific weekday
  - Daily recurrence (should still default to today)
  - Edge cases (31st of month, explicitly provided dates)
  - Task updates adding recurrence

All 54 recurring task tests pass.

* Fix UTC timezone bug in recurring task expansion and add comprehensive tests

- Fix expandRecurringTasks() to use setUTCHours instead of setHours
- Add 42 unit tests for recurringTaskService UTC consistency
- Add 24 DST transition tests (spring forward/fall back)
- Verify no occurrence skips or duplicates during DST
- Test month-end handling, leap years, and timezone boundaries
2026-03-23 18:24:54 +02:00
..
helpers Lint and formatting fixes 2025-07-23 12:22:06 +03:00
integration Fix recurring task initial due date calculation to match recurrence pattern (#965) 2026-03-23 18:24:54 +02:00
mocks Add nanoid 2025-08-04 23:50:53 +03:00
unit Fix recurring task initial due date calculation to match recurrence pattern (#965) 2026-03-23 18:24:54 +02:00