Skip to content

General: Add unit tests for reaction logic and ViewModels#433

Merged
d4rken merged 1 commit intomainfrom
worktree-test-plan-viewmodel-reaction
Mar 7, 2026
Merged

General: Add unit tests for reaction logic and ViewModels#433
d4rken merged 1 commit intomainfrom
worktree-test-plan-viewmodel-reaction

Conversation

@d4rken
Copy link
Copy Markdown
Member

@d4rken d4rken commented Mar 5, 2026

What changed

No user-facing behavior change. Adds 60 unit tests covering ViewModel state and reaction decision logic. Fixes a bug where the connection popup false-positive filter never triggered.

Technical Context

  • Extracted pure decision functions from AutoConnect and PopUpReaction (same pattern as PlayPause) for unit testability
  • Added FakeDataStoreValue test helper to replace fragile MockK setter mocking on DataStoreValue
  • Fixed reversed Duration.between args in PopUpReaction connection monitor — the false-positive age filter was comparing negative durations against a positive threshold, so it never fired
  • Tests cover: ReactionSettingsViewModel (16), OverviewViewModel (13), AutoConnect decisions (15), PopUpReaction decisions (16)

Extract pure decision functions from AutoConnect and PopUpReaction for testability, following the existing PlayPause pattern. Add FakeDataStoreValue test helper.

Fix reversed Duration.between args in PopUpReaction connection monitor that caused the false-positive age filter to never trigger.
@d4rken d4rken force-pushed the worktree-test-plan-viewmodel-reaction branch from 4d3354a to c89e464 Compare March 7, 2026 13:52
@d4rken d4rken changed the title General: Add unit tests for ViewModels and reaction decision logic General: Add unit tests for reaction logic and ViewModels Mar 7, 2026
@d4rken d4rken marked this pull request as ready for review March 7, 2026 13:52
@d4rken d4rken merged commit 450a187 into main Mar 7, 2026
9 checks passed
@d4rken d4rken deleted the worktree-test-plan-viewmodel-reaction branch March 7, 2026 14:19
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