mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-04 09:58:57 +00:00
* fix: guard against non-Map data type in push notification error handler
Check ReadableType before calling getMap("data") in the push notification
fetch error path. The server may return "data" as a String (e.g. HTML error
pages, proxy errors) instead of a Map, causing UnexpectedNativeTypeException.
Sentry: MATTERMOST-MOBILE-ANDROID-AWY6
https://mattermost-mr.sentry.io/issues/6306939631/
Co-authored-by: Claude <claude@anthropic.com>
* test: add unit tests for push notification error type guard
Add standalone test-runner with mocked ReadableMap to verify the
type check in General.kt's fetch() error handling:
- Map data type: extracts status_code and message correctly
- String data type: falls back to getString (HTML error pages, proxy errors)
- Null data type: handles gracefully
- Number data type: never calls getMap
- Null error map: handles gracefully
Uses lightweight React Native bridge stubs (ReadableMap interface,
ReadableType enum) to avoid full RN build dependency.
Sentry: MATTERMOST-MOBILE-ANDROID-AWY6
https://mattermost-mr.sentry.io/issues/6911684498/
Co-authored-by: Claude <claude@anthropic.com>
* fix: handle all ReadableType variants explicitly per CodeRabbit review
Replace if/else with exhaustive when-expression so every ReadableType
(Map, String, Number, Boolean, Array, Null) uses its type-safe getter.
Prevents UnexpectedNativeTypeException from the React Native bridge
when data is a non-String, non-Map type.
Tests updated: 7 cases covering every branch including missing key.
All pass locally (gradlew test).
Co-authored-by: Claude <claude@anthropic.com>
* test: add coverage for ReadableType.Array branch
Addresses CodeRabbit nitpick — the Array branch of the exhaustive
when-expression was the only one without a dedicated test case.
Co-authored-by: Claude <claude@anthropic.com>
* refactor: extract formatErrorMessage to eliminate test duplication
Extract the error formatting when-expression from General.kt into a
standalone formatErrorMessage() function in ErrorFormatting.kt. This
allows the test-runner to call the production function directly via
symlink instead of maintaining a duplicated extractErrorMessage() helper.
The test already covered Array type; all 8 tests pass against the
production function.
Co-authored-by: Claude <claude@anthropic.com>
* fix(android): harden nested map access and add comprehensive test coverage
Add defensive hasKey/getType checks for nested map fields (status_code,
message) in formatErrorMessage to prevent NoSuchKeyException and
UnexpectedNativeTypeException.
Add test coverage for all ReadableType branches and edge cases including
missing keys, wrong types, and null map.
Fix test-runner symlink to use relative path instead of absolute.
Co-authored-by: Claude <claude@anthropic.com>
---------
Co-authored-by: Claude <claude@anthropic.com>
2 lines
51 B
Plaintext
2 lines
51 B
Plaintext
rootProject.name = "mattermost-mobile-test-runner"
|