Skip to content

test(reminders): cover target title + existence resolution paths - #239

Merged
h4yfans merged 3 commits into
mainfrom
debt/phase-5.4-reminder-title
Apr 16, 2026
Merged

test(reminders): cover target title + existence resolution paths#239
h4yfans merged 3 commits into
mainfrom
debt/phase-5.4-reminder-title

Conversation

@h4yfans

@h4yfans h4yfans commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Phase 5.4 (ref .claude/plans/tech-debt-remediation.md § 5.4).

The title-resolution refactor the plan called for actually landed earlier, as part of commit e81ba54f feat(calendar): enhance synchronization and projection updates:

  • apps/desktop/src/main/lib/reminders.ts already has a resolveReminderTarget(reminder, indexDb) helper dispatching on targetType.
  • apps/desktop/src/main/ipc/reminder-handlers.ts no longer duplicates lookup logic — it delegates straight to the service.

So the remaining polish here is the explicit unit-test coverage the plan asked for. This PR adds a target title resolution describe block in reminders.test.ts with five cases:

# Scenario Asserts
1 note reminder, note in cache targetTitle from cache, targetExists: true
2 journal reminder targetTitle === targetId (date), no index-db lookup
3 note reminder, note missing targetTitle: null, targetExists: false
4 highlight reminder, note present highlightExists: true
5 highlight reminder, note missing highlightExists: false

Test plan

  • pnpm exec tsc -p tsconfig.node.json --noEmit clean (exit 0)
  • CI: pnpm test --filter @memry/desktop green on the new cases
  • No Playwright needed — pure main-process unit logic

Follow-up

Once merged, update the § 5.4 Progress Tracker entry in the remediation plan to reflect that the refactor + coverage are both shipped.

h4yfans added 3 commits April 16, 2026 12:32
Phase 5.4 (ref .claude/plans/tech-debt-remediation.md § 5.4).

The resolveReminderTarget helper landed earlier as part of the calendar
sync work (e81ba54) so the refactor portion of 5.4 is already on main.
This PR closes the coverage gap it left behind.

Adds a "target title resolution" describe block with five cases:
- note reminder resolves title from noteCache
- journal reminder uses targetId as title (no index db lookup)
- missing note → targetTitle null + targetExists false
- highlight with note present → highlightExists true
- highlight with missing note → highlightExists false
Closes the 5.4 refactor: the test-only PR assumed the calendar-sync work
had landed the refactor too, but origin/main still had toReminderWithTarget
stubbed with targetTitle: null and a duplicated resolveReminderTarget in
the IPC handler.

- Adds resolveReminderTarget(reminder, indexDb) in reminders.ts that
  handles note/journal/highlight uniformly and returns targetTitle +
  targetExists + highlightExists.
- Wires toReminderWithTarget(row, indexDb) to call the helper; updates
  getReminder, listReminders, getDueReminders to pass the indexDb through.
- getReminder now returns ReminderWithTarget (was Reminder) since the
  handler always wrapped it anyway.
- Removes the duplicated resolveReminderTarget + getIndexDb from
  reminder-handlers.ts; list/get/get-upcoming/get-due handlers now just
  delegate to the service.
- Drops the now-dead resolveTargetTitle helper + the scheduler's manual
  reminder.targetTitle = resolvedTitle mutation (now set upstream by
  toReminderWithTarget inside getDueReminders).
Follow-up to the reminders.ts refactor: the IPC handler used to wrap
each service result with its own resolveReminderTarget(); now that the
service does that itself, the two handler tests ("resolves reminder
targets on get and list" and "handles upcoming...") are rewritten as
pure pass-through assertions — they feed the mocked service a
pre-resolved ReminderWithTarget and assert the handler forwards it
verbatim.

Also drops the notesQueries mock + import since the handler no longer
reaches into the notes cache.
@h4yfans
h4yfans merged commit 21df9e3 into main Apr 16, 2026
2 checks passed
@h4yfans
h4yfans deleted the debt/phase-5.4-reminder-title branch April 16, 2026 14:58
h4yfans added a commit that referenced this pull request May 6, 2026
* test(reminders): cover target title + existence resolution paths

Phase 5.4 (ref .claude/plans/tech-debt-remediation.md § 5.4).

The resolveReminderTarget helper landed earlier as part of the calendar
sync work (e81ba54) so the refactor portion of 5.4 is already on main.
This PR closes the coverage gap it left behind.

Adds a "target title resolution" describe block with five cases:
- note reminder resolves title from noteCache
- journal reminder uses targetId as title (no index db lookup)
- missing note → targetTitle null + targetExists false
- highlight with note present → highlightExists true
- highlight with missing note → highlightExists false

* refactor(reminders): resolve target title in service helper

Closes the 5.4 refactor: the test-only PR assumed the calendar-sync work
had landed the refactor too, but origin/main still had toReminderWithTarget
stubbed with targetTitle: null and a duplicated resolveReminderTarget in
the IPC handler.

- Adds resolveReminderTarget(reminder, indexDb) in reminders.ts that
  handles note/journal/highlight uniformly and returns targetTitle +
  targetExists + highlightExists.
- Wires toReminderWithTarget(row, indexDb) to call the helper; updates
  getReminder, listReminders, getDueReminders to pass the indexDb through.
- getReminder now returns ReminderWithTarget (was Reminder) since the
  handler always wrapped it anyway.
- Removes the duplicated resolveReminderTarget + getIndexDb from
  reminder-handlers.ts; list/get/get-upcoming/get-due handlers now just
  delegate to the service.
- Drops the now-dead resolveTargetTitle helper + the scheduler's manual
  reminder.targetTitle = resolvedTitle mutation (now set upstream by
  toReminderWithTarget inside getDueReminders).

* test(reminders): align handler tests with service-owned title resolution

Follow-up to the reminders.ts refactor: the IPC handler used to wrap
each service result with its own resolveReminderTarget(); now that the
service does that itself, the two handler tests ("resolves reminder
targets on get and list" and "handles upcoming...") are rewritten as
pure pass-through assertions — they feed the mocked service a
pre-resolved ReminderWithTarget and assert the handler forwards it
verbatim.

Also drops the notesQueries mock + import since the handler no longer
reaches into the notes cache.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant