Skip to content

test: midnight watcher tests should drive production StelekitViewModel path #109

@tstapler

Description

@tstapler

Background

Three tests in GraphLoaderProgressiveTest were added to cover the midnight boundary watcher behavior, but each reimplements the watcher loop locally rather than exercising StelekitViewModel.startMidnightBoundaryWatcher directly. This means a regression in the production wiring would not be caught.

Flagged during review of #108.

Affected tests

  • GraphLoaderProgressiveTest ~line 749 — watcher loop test duplicates production logic
  • GraphLoaderProgressiveTest ~line 782 — cancellation test verifies a local coroutine, not the real watcher
  • GraphLoaderProgressiveTest ~line 820 — lastJournalDate guard reimplemented locally; production guard bypass goes undetected

What needs to change

Extract a testable interface (or use dependency injection) so these tests can:

  1. Call StelekitViewModel.startMidnightBoundaryWatcher (or an injected equivalent)
  2. Observe JournalService.ensureTodayJournal() calls via a fake/stub
  3. Verify the real guard (lastJournalDate) is skipping or firing correctly across midnight boundaries

Acceptance criteria

  • Each of the three tests fails if the production startMidnightBoundaryWatcher is deleted or broken
  • No local reimplementation of the watcher loop in the test body

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions