diff --git a/docs/features/recurring-tasks.md b/docs/features/recurring-tasks.md index b72726963..ce5b6edad 100644 --- a/docs/features/recurring-tasks.md +++ b/docs/features/recurring-tasks.md @@ -263,9 +263,13 @@ When completion changes, `scheduled` updates to the next uncompleted instance. I This means completion history and next-action planning stay synchronized automatically, without manually advancing recurring tasks. -### Rescheduling clears later instances +### Rescheduling and recorded instances -When you change a recurring task's scheduled date (from the context menu or the scheduled-date field), TaskNotes restarts the timeline from the new date: it clears every completed and skipped instance dated **on or after** that date, while keeping older instances as history. This reactivates occurrences you had completed or skipped off-schedule so they can be acted on again. Because clearing is destructive, TaskNotes asks you to confirm first — listing the dates that will be cleared — and cancelling leaves both the schedule and the recorded instances untouched. +For **scheduled-anchored** recurring tasks, moving the next occurrence keeps its original rule date in `recurrence_original_date` and leaves other occurrences' completed and skipped history untouched — even when you move it earlier than a skipped date or onto a previously completed day. When a moved occurrence has no `recurrence_original_date` (such as a Google Calendar-synced task or an older off-pattern note without a marker), moving it onto a day that is already completed or skipped clears only that landing day so the rescheduled occurrence is active there. + +For **completion-anchored** recurring tasks, changing the scheduled date re-anchors the timeline and clears every completed and skipped instance dated **on or after** the new date, while keeping older instances as history. + +Whenever a reschedule would clear recorded instances from the context menu or the scheduled-date field, TaskNotes asks you to confirm first — listing the dates that will be cleared — and cancelling leaves both the schedule and the recorded instances untouched. ## Flexible Scheduling diff --git a/docs/releases/unreleased.md b/docs/releases/unreleased.md index 1685c20d6..3d4ec827b 100644 --- a/docs/releases/unreleased.md +++ b/docs/releases/unreleased.md @@ -39,6 +39,7 @@ When a change has user-facing documentation, include a canonical tasknotes.dev l ## Fixed +- (#2691) Moving the next occurrence of a scheduled-anchored recurring task no longer clears completed or skipped history on other dates. Moves without a `recurrence_original_date` (such as Google-synced or legacy off-pattern notes) clear only the landing day when it is already recorded, still behind confirmation; completion-anchored recurring tasks keep clearing recorded instances on or after the new date. See [Recurring Tasks](https://tasknotes.dev/features/recurring-tasks/#rescheduling-and-recorded-instances). Thanks to @martin-forge for reporting. - (#2706) Fixed mdbase validation of scheduled and due times written by TaskNotes. Existing generated type definitions are updated when TaskNotes loads the vault. - Thanks to @iantierney for reporting - Protect task notes from being emptied by a failed save, including during workflow loops. If TaskNotes cannot restore an empty note, it keeps a recovery copy and includes its location in the error. Thanks to @chrabia for reporting ([Workflows issue 27](https://github.com/callumalpass/tasknotes-workflows/issues/27)). diff --git a/src/main.ts b/src/main.ts index 04c74a3a8..eec72f6c5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1281,7 +1281,8 @@ export default class TaskNotesPlugin extends Plugin { /** * Ask the user to confirm clearing recorded completed/skipped instances that a - * reschedule would remove (those on or after the new scheduled date). + * reschedule would remove (the landing day for unmarked scheduled-anchored + * moves, or instances on or after the new date for completion-anchored tasks). */ private async confirmClearRescheduledInstances(cleared: { complete: string[]; diff --git a/src/services/TaskService.ts b/src/services/TaskService.ts index f71519f1b..55b6d1e48 100644 --- a/src/services/TaskService.ts +++ b/src/services/TaskService.ts @@ -703,8 +703,12 @@ export class TaskService { clearRecurringMoveAfterSeriesChange(freshTask, updatePlan.updatedTask); } - // Reschedule reactivates the timeline: drop instances on/after the new date - // (kept as YYYY-MM-DD, so a lexicographic compare is chronological). + // Completion-anchored moves re-anchor the timeline and clear recorded instances + // on or after the new date (YYYY-MM-DD lexicographic order is chronological). + // Scheduled-anchored moves preserve other occurrences' history when the moved + // occurrence keeps its rule identity in `recurrence_original_date`; only an + // unmarked occurrence (such as a Google-synced or legacy off-pattern note) + // clears a recorded landing day. let rescheduleClearedOccurrence = false; if ( property === "scheduled" && @@ -716,32 +720,42 @@ export class TaskService { const previousScheduledDateStr = getDatePart(freshTask.scheduled); const scheduledDateStr = getDatePart(updatePlan.normalizedValue); const scheduledDateChanged = previousScheduledDateStr !== scheduledDateStr; - const completeInstances = freshTask.complete_instances ?? []; - const skippedInstances = freshTask.skipped_instances ?? []; - const removedComplete = completeInstances.filter((d) => d >= scheduledDateStr); - const removedSkipped = skippedInstances.filter((d) => d >= scheduledDateStr); - if ( - scheduledDateChanged && - (removedComplete.length > 0 || removedSkipped.length > 0) - ) { - // Give the caller a chance to confirm the destructive clear before - // anything is written; a false result aborts the whole reschedule. - if (options.confirmClearInstances) { - const proceed = await options.confirmClearInstances({ - complete: removedComplete, - skipped: removedSkipped, - }); - if (!proceed) { - return freshTask; + const isCompletionAnchored = + (freshTask.recurrence_anchor || "scheduled") === "completion"; + const hasMoveIdentity = Boolean( + updatePlan.updatedTask.recurrence_original_date || + getRecurringMoveOriginalDate(freshTask) === scheduledDateStr + ); + const shouldClear = isCompletionAnchored + ? (d: string) => d >= scheduledDateStr + : !hasMoveIdentity + ? (d: string) => d === scheduledDateStr + : null; + if (scheduledDateChanged && shouldClear) { + const completeInstances = freshTask.complete_instances ?? []; + const skippedInstances = freshTask.skipped_instances ?? []; + const removedComplete = completeInstances.filter(shouldClear); + const removedSkipped = skippedInstances.filter(shouldClear); + if (removedComplete.length > 0 || removedSkipped.length > 0) { + // Give the caller a chance to confirm the destructive clear before + // anything is written; a false result aborts the whole reschedule. + if (options.confirmClearInstances) { + const proceed = await options.confirmClearInstances({ + complete: removedComplete, + skipped: removedSkipped, + }); + if (!proceed) { + return freshTask; + } } + rescheduleClearedOccurrence = true; + updatePlan.updatedTask.complete_instances = completeInstances.filter( + (d) => !shouldClear(d) + ); + updatePlan.updatedTask.skipped_instances = skippedInstances.filter( + (d) => !shouldClear(d) + ); } - rescheduleClearedOccurrence = true; - updatePlan.updatedTask.complete_instances = completeInstances.filter( - (d) => d < scheduledDateStr - ); - updatePlan.updatedTask.skipped_instances = skippedInstances.filter( - (d) => d < scheduledDateStr - ); } } diff --git a/tests/unit/issues/issue-2691-reschedule-clear-rule.test.ts b/tests/unit/issues/issue-2691-reschedule-clear-rule.test.ts new file mode 100644 index 000000000..42eb8aa30 --- /dev/null +++ b/tests/unit/issues/issue-2691-reschedule-clear-rule.test.ts @@ -0,0 +1,279 @@ +/** + * Issue #2691: Moving the next occurrence of a scheduled-anchored recurring task + * must not clear other occurrences' completed/skipped history. + * + * - Scheduled-anchored tasks with a rule identity (`recurrence_original_date`) + * clear nothing on move. + * - Scheduled-anchored tasks without a rule identity (Google Calendar-synced or + * legacy off-pattern notes without a marker) clear only the landing day when + * that day is already recorded, still behind confirmation. + * - Completion-anchored recurring tasks keep the existing ">= new date" rule. + */ + +jest.mock("rrule", () => jest.requireActual("rrule/dist/es5/rrule.js")); + +import type TaskNotesPlugin from "../../../src/main"; +import { TaskService } from "../../../src/services/TaskService"; +import type { TaskInfo } from "../../../src/types"; +import { PluginFactory, TaskFactory } from "../../helpers/mock-factories"; + +function weeklyTask(overrides: Partial = {}): TaskInfo { + return TaskFactory.createTask({ + id: "weekly", + path: "Tasks/Weekly review.md", + title: "Weekly review", + scheduled: "2026-11-22", + recurrence: "DTSTART:20261101;FREQ=WEEKLY", + complete_instances: ["2026-11-08", "2026-11-15"], + skipped_instances: ["2026-11-29"], + ...overrides, + }); +} + +function createHarness(task: TaskInfo, confirmed = true) { + const frontmatter: Record = { + scheduled: task.scheduled, + recurrence: task.recurrence, + complete_instances: [...(task.complete_instances ?? [])], + skipped_instances: [...(task.skipped_instances ?? [])], + ...(task.recurrence_original_date + ? { recurrence_original_date: task.recurrence_original_date } + : {}), + }; + const confirm = jest.fn(async () => confirmed); + const plugin = PluginFactory.createMockPlugin({ + cacheManager: { + getTaskInfo: jest.fn(async () => task), + updateTaskInfoInCache: jest.fn(), + }, + taskCalendarSyncService: { isEnabled: () => false }, + }); + plugin.app.fileManager.processFrontMatter = jest.fn( + async (_file: unknown, update: (fm: Record) => void) => { + update(frontmatter); + } + ); + const taskService = new TaskService(plugin as unknown as TaskNotesPlugin); + return { task, frontmatter, confirm, plugin, taskService }; +} + +describe("issue #2691 narrower reschedule-clear rule", () => { + describe("scheduled-anchored native recurring tasks", () => { + it("moving 22 Nov to 21 Nov preserves the skip on 29 Nov and does not ask to confirm", async () => { + const { task, frontmatter, confirm, taskService } = createHarness(weeklyTask()); + + const result = await taskService.updateProperty(task, "scheduled", "2026-11-21", { + confirmClearInstances: confirm, + }); + + expect(confirm).not.toHaveBeenCalled(); + expect(result.scheduled).toBe("2026-11-21"); + expect(result.recurrence_original_date).toBe("2026-11-22"); + expect(result.complete_instances).toEqual(["2026-11-08", "2026-11-15"]); + expect(result.skipped_instances).toEqual(["2026-11-29"]); + expect(frontmatter).toMatchObject({ + scheduled: "2026-11-21", + recurrence_original_date: "2026-11-22", + complete_instances: ["2026-11-08", "2026-11-15"], + skipped_instances: ["2026-11-29"], + }); + }); + + it("moving 22 Nov onto completed 15 Nov preserves 15 Nov completion and 29 Nov skip", async () => { + const { task, frontmatter, confirm, taskService } = createHarness(weeklyTask()); + + const result = await taskService.updateProperty(task, "scheduled", "2026-11-15", { + confirmClearInstances: confirm, + }); + + expect(confirm).not.toHaveBeenCalled(); + expect(result.scheduled).toBe("2026-11-15"); + expect(result.recurrence_original_date).toBe("2026-11-22"); + expect(result.complete_instances).toEqual(["2026-11-08", "2026-11-15"]); + expect(result.skipped_instances).toEqual(["2026-11-29"]); + expect(frontmatter.complete_instances).toEqual(["2026-11-08", "2026-11-15"]); + expect(frontmatter.skipped_instances).toEqual(["2026-11-29"]); + }); + + it("moving 22 Nov onto skipped 29 Nov preserves 29 Nov skip", async () => { + const { task, confirm, taskService } = createHarness(weeklyTask()); + + const result = await taskService.updateProperty(task, "scheduled", "2026-11-29", { + confirmClearInstances: confirm, + }); + + expect(confirm).not.toHaveBeenCalled(); + expect(result.recurrence_original_date).toBe("2026-11-22"); + expect(result.skipped_instances).toEqual(["2026-11-29"]); + }); + + it("moving an already-moved occurrence preserves history, including when returning to its original date", async () => { + const moved = weeklyTask({ + scheduled: "2026-11-21", + recurrence_original_date: "2026-11-22", + }); + const ontoCompleted = createHarness(moved); + const result = await ontoCompleted.taskService.updateProperty( + moved, + "scheduled", + "2026-11-15", + { confirmClearInstances: ontoCompleted.confirm } + ); + expect(ontoCompleted.confirm).not.toHaveBeenCalled(); + expect(result.recurrence_original_date).toBe("2026-11-22"); + expect(result.complete_instances).toEqual(["2026-11-08", "2026-11-15"]); + expect(result.skipped_instances).toEqual(["2026-11-29"]); + + // Exhausted moved occurrence returned home keeps its recorded completion. + const exhaustedMoved = weeklyTask({ + scheduled: "2026-11-21", + recurrence: "DTSTART:20261115;FREQ=WEEKLY;COUNT=2", + recurrence_original_date: "2026-11-22", + complete_instances: ["2026-11-15", "2026-11-22"], + skipped_instances: [], + }); + const returned = createHarness(exhaustedMoved); + const homeResult = await returned.taskService.updateProperty( + exhaustedMoved, + "scheduled", + "2026-11-22", + { confirmClearInstances: returned.confirm } + ); + expect(returned.confirm).not.toHaveBeenCalled(); + expect(homeResult.recurrence_original_date).toBeUndefined(); + expect(homeResult.complete_instances).toEqual(["2026-11-15", "2026-11-22"]); + }); + }); + + describe("scheduled-anchored tasks without recurrence_original_date", () => { + it("Google-synced move onto an unrecorded day clears nothing and keeps later skips", async () => { + const synced = weeklyTask({ googleCalendarEventId: "gcal-1" }); + const { confirm, taskService } = createHarness(synced); + + const result = await taskService.updateProperty(synced, "scheduled", "2026-11-21", { + confirmClearInstances: confirm, + }); + + expect(confirm).not.toHaveBeenCalled(); + expect(result.recurrence_original_date).toBeUndefined(); + expect(result.complete_instances).toEqual(["2026-11-08", "2026-11-15"]); + expect(result.skipped_instances).toEqual(["2026-11-29"]); + }); + + it("Google-synced move onto a completed day asks to clear only that day and keeps later skips", async () => { + const synced = weeklyTask({ googleCalendarEventId: "gcal-1" }); + const { frontmatter, confirm, taskService } = createHarness(synced, true); + + const result = await taskService.updateProperty( + synced, + "scheduled", + "2026-11-15T10:30", + { confirmClearInstances: confirm } + ); + + expect(confirm).toHaveBeenCalledWith({ complete: ["2026-11-15"], skipped: [] }); + expect(result.complete_instances).toEqual(["2026-11-08"]); + expect(result.skipped_instances).toEqual(["2026-11-29"]); + expect(frontmatter.complete_instances).toEqual(["2026-11-08"]); + expect(frontmatter.skipped_instances).toEqual(["2026-11-29"]); + }); + + it("Google-synced move onto a recorded day aborts with no write when confirmation is declined", async () => { + const synced = weeklyTask({ googleCalendarEventId: "gcal-1" }); + const { confirm, plugin, taskService } = createHarness(synced, false); + + const result = await taskService.updateProperty(synced, "scheduled", "2026-11-29", { + confirmClearInstances: confirm, + }); + + expect(confirm).toHaveBeenCalledWith({ complete: [], skipped: ["2026-11-29"] }); + expect(plugin.app.fileManager.processFrontMatter).not.toHaveBeenCalled(); + expect(result.scheduled).toBe("2026-11-22"); + expect(result.skipped_instances).toEqual(["2026-11-29"]); + }); + + it("legacy off-pattern note without marker clears only a recorded landing day", async () => { + const legacy = weeklyTask({ scheduled: "2026-11-19" }); + + const toUnrecorded = createHarness(legacy); + const unrecordedResult = await toUnrecorded.taskService.updateProperty( + legacy, + "scheduled", + "2026-11-21", + { confirmClearInstances: toUnrecorded.confirm } + ); + expect(toUnrecorded.confirm).not.toHaveBeenCalled(); + expect(unrecordedResult.complete_instances).toEqual(["2026-11-08", "2026-11-15"]); + expect(unrecordedResult.skipped_instances).toEqual(["2026-11-29"]); + + const toCompleted = createHarness(legacy, true); + const completedResult = await toCompleted.taskService.updateProperty( + legacy, + "scheduled", + "2026-11-15", + { confirmClearInstances: toCompleted.confirm } + ); + expect(toCompleted.confirm).toHaveBeenCalledWith({ + complete: ["2026-11-15"], + skipped: [], + }); + expect(completedResult.complete_instances).toEqual(["2026-11-08"]); + expect(completedResult.skipped_instances).toEqual(["2026-11-29"]); + + const declined = createHarness(legacy, false); + const declinedResult = await declined.taskService.updateProperty( + legacy, + "scheduled", + "2026-11-15", + { confirmClearInstances: declined.confirm } + ); + expect(declined.confirm).toHaveBeenCalledWith({ + complete: ["2026-11-15"], + skipped: [], + }); + expect(declined.plugin.app.fileManager.processFrontMatter).not.toHaveBeenCalled(); + expect(declinedResult.scheduled).toBe("2026-11-19"); + }); + }); + + describe("completion-anchored recurring tasks (unchanged)", () => { + it("still clears all recorded instances on or after the new scheduled date", async () => { + const completionAnchored = weeklyTask({ recurrence_anchor: "completion" }); + + const toSat = createHarness(completionAnchored, true); + const satResult = await toSat.taskService.updateProperty( + completionAnchored, + "scheduled", + "2026-11-21", + { confirmClearInstances: toSat.confirm } + ); + expect(toSat.confirm).toHaveBeenCalledWith({ complete: [], skipped: ["2026-11-29"] }); + expect(satResult.complete_instances).toEqual(["2026-11-08", "2026-11-15"]); + expect(satResult.skipped_instances).toEqual([]); + + const toEarlier = createHarness(completionAnchored, true); + const earlierResult = await toEarlier.taskService.updateProperty( + completionAnchored, + "scheduled", + "2026-11-15", + { confirmClearInstances: toEarlier.confirm } + ); + expect(toEarlier.confirm).toHaveBeenCalledWith({ + complete: ["2026-11-15"], + skipped: ["2026-11-29"], + }); + expect(earlierResult.complete_instances).toEqual(["2026-11-08"]); + expect(earlierResult.skipped_instances).toEqual([]); + + const declined = createHarness(completionAnchored, false); + const declinedResult = await declined.taskService.updateProperty( + completionAnchored, + "scheduled", + "2026-11-15", + { confirmClearInstances: declined.confirm } + ); + expect(declined.plugin.app.fileManager.processFrontMatter).not.toHaveBeenCalled(); + expect(declinedResult.scheduled).toBe("2026-11-22"); + }); + }); +}); diff --git a/tests/unit/services/TaskService.test.ts b/tests/unit/services/TaskService.test.ts index cce4f55d5..1d4190f6d 100644 --- a/tests/unit/services/TaskService.test.ts +++ b/tests/unit/services/TaskService.test.ts @@ -924,25 +924,50 @@ describe('TaskService', () => { expect(result.completedDate).toBeUndefined(); }); - // #3: rescheduling a recurring task onto a recorded date reactivates that occurrence. - it('removes the rescheduled date from complete_instances for a recurring task', async () => { + // #2691: scheduled-anchored native moves keep their rule identity and leave recorded + // instances intact; unmarked scheduled-anchored moves (e.g. Google-synced) clear only + // the landing day; completion-anchored moves still clear instances on or after the new date. + it('preserves recorded instances when moving a native scheduled-anchored recurring task', async () => { const recurringTask = TaskFactory.createTask({ recurrence: 'FREQ=WEEKLY', scheduled: '2026-06-09', complete_instances: ['2026-06-02', '2026-05-26'], - skipped_instances: [], + skipped_instances: ['2026-06-16'], + }); + mockPlugin.cacheManager.getTaskInfo.mockResolvedValue(recurringTask); + const confirm = jest.fn(async () => true); + + const result = await taskService.updateProperty(recurringTask, 'scheduled', '2026-06-02', { + confirmClearInstances: confirm, + }); + + expect(result.recurrence_original_date).toBe('2026-06-09'); + expect(result.complete_instances).toEqual(['2026-06-02', '2026-05-26']); + expect(result.skipped_instances).toEqual(['2026-06-16']); + expect(confirm).not.toHaveBeenCalled(); + }); + + it('removes the rescheduled landing day from complete_instances for an unmarked recurring task', async () => { + const recurringTask = TaskFactory.createTask({ + recurrence: 'FREQ=WEEKLY', + scheduled: '2026-06-09', + googleCalendarEventId: 'gcal-1', + complete_instances: ['2026-06-02', '2026-05-26'], + skipped_instances: ['2026-06-16'], }); mockPlugin.cacheManager.getTaskInfo.mockResolvedValue(recurringTask); const result = await taskService.updateProperty(recurringTask, 'scheduled', '2026-06-02'); expect(result.complete_instances).toEqual(['2026-05-26']); + expect(result.skipped_instances).toEqual(['2026-06-16']); }); - it('removes the rescheduled date from skipped_instances for a recurring task', async () => { + it('removes the rescheduled landing day from skipped_instances for an unmarked recurring task', async () => { const recurringTask = TaskFactory.createTask({ recurrence: 'FREQ=WEEKLY', scheduled: '2026-06-09', + googleCalendarEventId: 'gcal-1', complete_instances: [], skipped_instances: ['2026-06-02'], }); @@ -953,10 +978,11 @@ describe('TaskService', () => { expect(result.skipped_instances).toEqual([]); }); - it('ignores the time component when matching the rescheduled date', async () => { + it('ignores the time component when matching the rescheduled landing day', async () => { const recurringTask = TaskFactory.createTask({ recurrence: 'FREQ=WEEKLY', scheduled: '2026-06-09', + googleCalendarEventId: 'gcal-1', complete_instances: ['2026-06-02'], skipped_instances: [], }); @@ -1016,11 +1042,28 @@ describe('TaskService', () => { expect(confirm).not.toHaveBeenCalled(); }); - it('clears an off-schedule completion/skip recorded on or after the rescheduled date, keeping older history', async () => { + it('clears only the landing day for an unmarked scheduled-anchored task, keeping earlier and later history', async () => { + const recurringTask = TaskFactory.createTask({ + recurrence: 'FREQ=WEEKLY', + scheduled: '2026-06-12', + googleCalendarEventId: 'gcal-1', + complete_instances: ['2026-05-29', '2026-06-05'], + skipped_instances: ['2026-06-19'], + }); + mockPlugin.cacheManager.getTaskInfo.mockResolvedValue(recurringTask); + + const result = await taskService.updateProperty(recurringTask, 'scheduled', '2026-06-05'); + + expect(result.complete_instances).toEqual(['2026-05-29']); + expect(result.skipped_instances).toEqual(['2026-06-19']); + }); + + it('clears an off-schedule completion/skip recorded on or after the rescheduled date for completion-anchored tasks, keeping older history', async () => { // Off-schedule completion (06-08) + later skip (06-19), reschedule back to 06-05: - // the ">= new date" rule clears both while keeping the older 05-29 history. + // completion-anchored tasks keep the ">= new date" rule while preserving older 05-29 history. const recurringTask = TaskFactory.createTask({ recurrence: 'FREQ=WEEKLY', + recurrence_anchor: 'completion', scheduled: '2026-06-12', complete_instances: ['2026-05-29', '2026-06-08'], skipped_instances: ['2026-06-19'], @@ -1060,9 +1103,10 @@ describe('TaskService', () => { ).resolves.toBeDefined(); }); - it('aborts the reschedule (no write, instances intact) when confirmClearInstances returns false', async () => { + it('aborts the reschedule (no write, instances intact) when confirmClearInstances returns false for completion-anchored tasks', async () => { const recurringTask = TaskFactory.createTask({ recurrence: 'FREQ=WEEKLY', + recurrence_anchor: 'completion', scheduled: '2026-06-12', complete_instances: ['2026-06-08'], skipped_instances: ['2026-06-19'], @@ -1080,9 +1124,10 @@ describe('TaskService', () => { expect(mockPlugin.app.fileManager.processFrontMatter).not.toHaveBeenCalled(); }); - it('proceeds and clears when confirmClearInstances returns true', async () => { + it('proceeds and clears when confirmClearInstances returns true for completion-anchored tasks', async () => { const recurringTask = TaskFactory.createTask({ recurrence: 'FREQ=WEEKLY', + recurrence_anchor: 'completion', scheduled: '2026-06-12', complete_instances: ['2026-06-08'], skipped_instances: [], @@ -1098,6 +1143,28 @@ describe('TaskService', () => { expect(result.complete_instances).toEqual([]); }); + it('aborts an unmarked scheduled-anchored landing-day clear when confirmClearInstances returns false', async () => { + const recurringTask = TaskFactory.createTask({ + recurrence: 'FREQ=WEEKLY', + scheduled: '2026-06-12', + googleCalendarEventId: 'gcal-1', + complete_instances: ['2026-06-05'], + skipped_instances: ['2026-06-19'], + }); + mockPlugin.cacheManager.getTaskInfo.mockResolvedValue(recurringTask); + const confirm = jest.fn(async () => false); + + const result = await taskService.updateProperty(recurringTask, 'scheduled', '2026-06-05', { + confirmClearInstances: confirm, + }); + + expect(confirm).toHaveBeenCalledWith({ complete: ['2026-06-05'], skipped: [] }); + expect(result.complete_instances).toEqual(['2026-06-05']); + expect(result.skipped_instances).toEqual(['2026-06-19']); + expect(result.scheduled).toBe('2026-06-12'); + expect(mockPlugin.app.fileManager.processFrontMatter).not.toHaveBeenCalled(); + }); + it('does not call confirmClearInstances when nothing would be cleared', async () => { const recurringTask = TaskFactory.createTask({ recurrence: 'FREQ=WEEKLY',