tududi/backend/tests/unit/modules/tasks
Chris 01a84c3598
Fix: Bi-weekly recurring task scheduling for multi-day patterns (#1005)
* fix: correct bi-weekly recurring task scheduling for multi-day patterns

Fixes #1004

Previously, when a recurring task was set to repeat every N weeks (where N > 1)
on multiple weekdays that span a week boundary (e.g., Saturday + Sunday), the
algorithm incorrectly calculated the next occurrence dates.

The issue was in the calculateWeeklyRecurrence function, which didn't properly
determine when to add the interval skip for multi-weekday patterns. It would:
- Correctly handle Sat -> Sun (adjacent days, same cycle)
- Incorrectly handle Sun -> Sat (should skip weeks, but didn't)

This fix improves the logic to:
1. Detect when the current day is the last weekday in the pattern cycle
2. Account for Sunday (day 0) wrapping around in the day-of-week numbering
3. Only add interval skips when truly moving to a new cycle, not when moving
   between weekdays within the same cycle

Test coverage added for:
- Bi-weekly Saturday + Sunday pattern (the reported bug)
- Starting from different days in the pattern
- Bi-weekly Tuesday + Thursday pattern
- Tri-weekly Friday + Saturday + Sunday pattern

* docs: update MEMORY.md with GitHub template requirements

- Add detailed PR template requirements and structure
- Expand bug report template requirements with all fields
- Update last modified date
2026-04-12 08:52:13 +03:00
..
biweekly-bug.test.js Fix: Bi-weekly recurring task scheduling for multi-day patterns (#1005) 2026-04-12 08:52:13 +03:00
builders.test.js Fix initial due date calculation for weekly tasks with multiple weekdays (#974) (#975) 2026-03-26 17:19:59 +02:00
dueTaskService.test.js Fix Telegram notification spam with channel-level rate limiting (#951) 2026-03-19 20:26:11 +02:00
recurringTaskService.test.js Fix recurring task initial due date calculation to match recurrence pattern (#965) 2026-03-23 18:24:54 +02:00