test(compose): Robolectric JVM tests for settings screens (#380) #401

Merged
JMR-dev merged 1 commits from test-380-robolectric-settings into main 2026-07-07 05:19:42 +00:00
JMR-dev commented 2026-07-07 01:50:21 +00:00 (Migrated from github.com)

Converts the settings screens/components to Robolectric JVM Compose tests (umbrella #373, batch 5/9) and drops their globs from jacocoNonJvmTestableSurface in app/build.gradle.kts, so they count toward JaCoCo's JVM-testable surface without an emulator.

New src/test Robolectric Compose tests

Pattern per #375: @RunWith(RobolectricTestRunner) + @GraphicsMode(NATIVE) + @Config(sdk=[36]) + v2 createComposeRule(), mocking each ViewModel (MockK) where needed; a hand-rolled RESUMED LocalLifecycleOwner satisfies collectAsStateWithLifecycle.

  • SettingsComponentsJvmTest — SectionHeader, SwitchRow, ClickRow, RadioRow, RetentionSection (global vs per-account "use default", count/age selection)
  • SettingsScreenJvmTest — empty/populated accounts, fetch-policy radios, appearance/notification switches, collapsible Advanced, battery subtitle branch, retention wiring, contacts rationale/blocked dialog branch, plus the stateless ContactAutocompleteRow
  • AccountSettingsScreenJvmTest — email/fallback title, default-account/signature/notification switches, signatures-summary count branch, per-account retention, remove-account, back
  • SignaturesScreenJvmTest — empty state, name + default badge, row→edit, make-default radio, delete, add FAB
  • SignatureEditScreenJvmTest — new/edit title, name field, loaded/not-loaded body-field branch, name-change callback, save (incl. saving-disabled)

Coverage

Newly-included files (line): SettingsComponents 100%, SignatureEditScreen 100%, SignaturesScreen 97%, SettingsScreen 95%, AccountSettingsScreen 84%. Overall scoped line coverage 86.2% (well above the 0.79 floor).

The instrumented androidTest E2E (SettingsScreenTest, AccountSettingsScreenTest, ContactAutocompleteRowTest, SignaturesScreenTest, SignatureEditScreenTest) stay. The JaCoCo floor is not raised — the re-ratchet is #386.

Gate

assembleDebug + testDebugUnitTest + jacocoTestCoverageVerification + compileDebugAndroidTestKotlin + lintDebug + ktlintCheck + detekt — all green.

Closes #380.

🤖 Generated with Claude Code

Converts the settings screens/components to Robolectric JVM Compose tests (umbrella #373, batch 5/9) and drops their globs from `jacocoNonJvmTestableSurface` in `app/build.gradle.kts`, so they count toward JaCoCo's JVM-testable surface without an emulator. ## New `src/test` Robolectric Compose tests Pattern per #375: `@RunWith(RobolectricTestRunner)` + `@GraphicsMode(NATIVE)` + `@Config(sdk=[36])` + v2 `createComposeRule()`, mocking each ViewModel (MockK) where needed; a hand-rolled RESUMED `LocalLifecycleOwner` satisfies `collectAsStateWithLifecycle`. - `SettingsComponentsJvmTest` — `SectionHeader`, `SwitchRow`, `ClickRow`, `RadioRow`, `RetentionSection` (global vs per-account "use default", count/age selection) - `SettingsScreenJvmTest` — empty/populated accounts, fetch-policy radios, appearance/notification switches, collapsible Advanced, battery subtitle branch, retention wiring, contacts rationale/blocked dialog branch, plus the stateless `ContactAutocompleteRow` - `AccountSettingsScreenJvmTest` — email/fallback title, default-account/signature/notification switches, signatures-summary count branch, per-account retention, remove-account, back - `SignaturesScreenJvmTest` — empty state, name + default badge, row→edit, make-default radio, delete, add FAB - `SignatureEditScreenJvmTest` — new/edit title, name field, loaded/not-loaded body-field branch, name-change callback, save (incl. saving-disabled) ## Coverage Newly-included files (line): SettingsComponents 100%, SignatureEditScreen 100%, SignaturesScreen 97%, SettingsScreen 95%, AccountSettingsScreen 84%. Overall scoped line coverage 86.2% (well above the 0.79 floor). The instrumented `androidTest` E2E (`SettingsScreenTest`, `AccountSettingsScreenTest`, `ContactAutocompleteRowTest`, `SignaturesScreenTest`, `SignatureEditScreenTest`) stay. The JaCoCo floor is **not** raised — the re-ratchet is #386. ## Gate `assembleDebug` + `testDebugUnitTest` + `jacocoTestCoverageVerification` + `compileDebugAndroidTestKotlin` + `lintDebug` + `ktlintCheck` + `detekt` — all green. Closes #380. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.