Skip to content

Add unit tests for HistoryViewModel search and filter logic #8

Description

@vssinghh

🎯 Summary

The project has solid unit test coverage for AIEngineImpl, EvaluateNotificationUseCase, ParseCommandUseCase, and ChatViewModel, but the HistoryViewModel currently has no unit tests. Add tests for its search/filter functionality.

📍 Where to Look

  • app/src/main/java/com/hush/app/ui/screens/history/HistoryViewModel.kt — The ViewModel to test
  • app/src/test/java/com/hush/app/ui/screens/chat/ChatViewModelTest.kt — Example of how ViewModels are tested in this project (use as a pattern reference)

✅ What to Do

  1. Create a new test file: app/src/test/java/com/hush/app/ui/screens/history/HistoryViewModelTest.kt
  2. Write tests covering:
    • Initial state has empty search query
    • Setting a search query updates the filtered logs
    • Search filters by app name, title, and text content
    • Empty search query returns all logs
    • Search is case-insensitive
  3. Mock the HistoryRepository dependency (follow the pattern in ChatViewModelTest)

🧪 How to Verify

./gradlew testDebugUnitTest --tests "*.HistoryViewModelTest"

All tests should pass.

📚 Resources

Great way to learn the project's architecture by writing tests for it! 🙌

Metadata

Metadata

Assignees

Labels

good first issueGood for newcomershelp wantedExtra attention is neededtestingTest improvements and additions

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions