Unit tests for Insuree Inquiry #117
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces unit tests for the EnquireActivity feature in the mobile policies module. The tests validate that insuree information display, policy rendering, error handling, photo processing, and online/offline data fetching are correctly processed and exposed by the activity layer.
The Android environment and external dependencies are mocked to isolate UI logic and ensure consistent behavior without backend or database access.
Type of change
Chore (Testing / CI)
CheckLists
Unit Tests added:
Enquire – Value formatting
buildEnquireValue_WhenNull_ReturnsEmptyString – PASSED ✅
Ensures method returns empty string when value is null.
buildEnquireValue_WhenValueProvided_ReturnsFormattedString – PASSED ✅
Ensures value is correctly formatted with its label.
Enquire – Insuree display handling
renderResult_WhenInsureeIsNull_ShowsNotFoundDialog – PASSED ✅
Ensures error dialog is displayed when insuree is not found.
renderResult_WhenCHFIDMismatch_DoesNothing – PASSED ✅
Ensures UI remains unchanged when CHFID doesn't match.
renderResult_WhenValidInsuree_PopulatesUI – PASSED ✅
Ensures UI fields are correctly populated with insuree data.
Enquire – Photo handling
renderResult_WhenPhotoBytesPresent_DisplaysBitmap – PASSED ✅
Ensures insuree photo is displayed when provided as byte array.
Enquire – Policy display
renderResult_WithPolicies_PopulatesListView – PASSED ✅
Ensures ListView correctly displays insuree policies.
Enquire – Data fetching logic
getInsureeInfo_WhenOffline_UsesLocalDb – PASSED ✅
Ensures local database is used when network is unavailable.
getInsureeInfo_WhenOnline_RecordNotFound_ShowsDialog – PASSED ✅
Ensures error dialog is displayed when API returns HTTP 404.
Notes
Backend calls are not executed; Insuree and Policy data are mocked to isolate logic.
Android components (TextView, ImageView, ListView) are simulated using Robolectric.
Network availability is mocked via Global dependency.
Tests ensure correct UI rendering, error handling, and online/offline data fetching behavior.