Skip to content

test: Add more unit tests and integration tests#518

Merged
spuday90 merged 9 commits intomainfrom
feat/codebase-improvements
Mar 26, 2026
Merged

test: Add more unit tests and integration tests#518
spuday90 merged 9 commits intomainfrom
feat/codebase-improvements

Conversation

@adeekshith
Copy link
Copy Markdown
Owner

No description provided.

Extract the notification reply decision logic (canReply, shouldReply,
isSupportedPackage, canSendReplyNow, isGroupMessageAndReplyAllowed)
into a standalone NotificationReplyDecider class that accepts its
dependencies via constructor, making it unit-testable.

Tests cover: service gating, package filtering, old notification
rejection, group message rules, cooldown enforcement, self-reply
prevention, and contact whitelist/blacklist filtering.
Integration tests using real SharedPreferences, real Room database,
and real StatusBarNotification objects on device/emulator. Tests the
full decision pipeline including:
- Service enabled/disabled with real prefs
- WhatsApp/Telegram package filtering
- Old notification rejection
- Group message rules
- Cooldown enforcement with real Room DB entries
- Self-reply prevention
- Contact whitelist/blacklist filtering with real prefs
- Full canReply + shouldReply pipeline scenarios

Uses real StatusBarNotification constructor instead of Mockito to
avoid compatibility issues with newer Android API levels.
Add isAdded/binding null checks in Retrofit onResponse and onFailure
callbacks to prevent IllegalStateException when the fragment detaches
before the network response arrives. Also add onDestroyView to null
out ViewBinding reference. Restores the recreation instrumentation test
that was previously removed as a workaround.
Add jacocoCoverageVerification task with 5% minimum instruction
coverage for testable model/utility classes. Excludes UI classes
(activities, fragments, adapters) that cannot be unit-tested.
Threshold is conservative due to Robolectric tests not contributing
to JaCoCo offline instrumentation.
Verify base URLs, converter factories, singleton behavior, and error
parsing for all three Retrofit instances (GitHub, OpenAI, Atomatic AI).
…sts)

Test ServiceUtils singleton and the Settings.Secure notification
listener enabled check logic used by MainFragment.isListenerEnabled().
AppsAdapter: item count, view type resolution, data preservation.
ContactListAdapter: item count, view types, checkpoint/restore,
custom name insertion, filter availability.
Verify launch, toolbar, root layout, fragment container, fragment
loading, and activity recreation.
Verify the notification intent handler launches without crashing for
various intent configurations: no extras, valid package, null package,
and empty package. Activity calls finish() in onCreate so tests verify
no-crash behavior rather than UI assertions.
@adeekshith adeekshith changed the title test: Add NotificationService unit tests and integration tests test: Add more unit tests and integration tests Mar 23, 2026
@spuday90 spuday90 merged commit 9c5e50c into main Mar 26, 2026
2 checks passed
@spuday90 spuday90 deleted the feat/codebase-improvements branch March 26, 2026 01:46
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.

2 participants