Skip to content

Conversation

@Blue-B-code
Copy link

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.

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