digidem / digidem/comapeo-core-react-native
Test: cover ComapeoPrefs.open() factory path on Android (Robolectric)
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 1
- Forks
- 0
- Avg merge
- 8h 24m
- Merged PRs (30d)
- 9
Description
Background
The Android ComapeoPrefs JVM unit tests in android/src/test/java/com/comapeo/core/ComapeoPrefsTest.kt exercise the lambda-seam constructor only — the open(context) factory that actually wires SharedPreferences("com.comapeo.core.prefs", MODE_PRIVATE) and reads the plugin defaults via SentryConfig.loadFromManifest is untested.
This came up in the review of the diagnostics-toggle PR (#TBD). A regression in the production factory (wrong MODE_* constant, key-namespace typo in the production getSharedPreferences lambda, wrong default precedence between manifest/baked-in) wouldn't be caught by the existing tests.
What's needed
A Robolectric-based test (or instrumented test if Robolectric is too heavy to add) that:
- Verifies
open(context)returns aComapeoPrefsreading fromgetSharedPreferences("com.comapeo.core.prefs", MODE_PRIVATE)— write through it via a separateSharedPreferenceshandle to the same file, observe viareadDiagnosticsEnabled(). - Verifies the default-fallback precedence:
user write > plugin default > baked-in DEFAULT_DIAGNOSTICS_ENABLED. Plugin defaults come viaSentryConfig.loadFromManifest, which reads<meta-data>fromAndroidManifest.xml— easiest via Robolectric'sRuntimeEnvironment.application. - Verifies the storage key names by reading the on-disk prefs file directly after a write.
Why deferred
Adding Robolectric is a non-trivial dependency bump on the test classpath — out of scope for the toggle-persistence PR. The lambda-seam tests cover the read/write logic; this issue covers the wiring.
References
android/src/main/java/com/comapeo/core/ComapeoPrefs.ktandroid/src/test/java/com/comapeo/core/ComapeoPrefsTest.kt- Plan:
docs/sentry-integration-plan.md§9.8
🤖 Generated with Claude Code
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading android/src/main/java/com/comapeo/core/ComapeoPrefs.kt and the existing tests in android/src/test/java/com/comapeo/core/ComapeoPrefsTest.kt, then inspect the AndroidManifest metadata used by SentryConfig.loadFromManifest. Add a Robolectric or instrumented test covering open(context), SharedPreferences wiring, default precedence, and storage key names; it is done when those production-factory paths are verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100