Repository navigation
fix: unit tests no longer race the app's pubky link setup - #1776
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Low impact] This test-only change appears safe to merge. SummaryAdds
Reviews (1) · Last reviewed commit: "fix: unit tests no longer race the app's..." · Reviewed by Greptile |
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 3b32a12 against 44bf50e.
Looks good. Tests that need Hilt already set @Config(application = HiltTestApplication::class), which overrides this default, and the tests that depend on App.currentActivity or the app storage path set them up themselves. No findings.
Review details
Claude Opus 5.5, effort high
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
talosmachina
left a comment
There was a problem hiding this comment.
No findings. Adds app/src/test/resources/robolectric.properties so Robolectric unit tests boot a plain android.app.Application instead of App, which stops PubkyAuthHandlerRegistrar.start() (and the other App.onCreate services) from running in the test JVM and flipping the signup alias under PubkyAuthManifestTest. Reviewed 3b32a12, light tier, static: on this repo an auto review does not build the branch, so this rests on the code and on CI.
What I checked, and 4 candidates I ruled out
Read in full: App.kt, Env.kt (paths region), Logger.kt (session saver), the new properties file
Tests affected: the 18 Robolectric classes with no application = in @Config (e.g. AppWidgetRefreshSchedulerTest, PaykitSubscriptionNotificationSchedulerTest, ContentViewTest, AppViewModelSendFlowTest, PubkyAuthHandlerRegistrarTest); the classes that name Application or HiltTestApplication are unchanged, since @Config overrides the properties file
CI: build-and-test (runs testDevDebugUnitTest) green, lint and detekt green; compose-ui and the e2e jobs were still running and do not read src/test resources
Ruled out
- A test relied on
App.onCreateside effects: the only uses ofAppin those 18 classes set the staticApp.currentActivity, which needs noAppinstance. Env.initAppStoragePathno longer runs, soEnv.logDiror a storage path throws:AppLoggerwraps session path creation inrunCatching, and the two tests that touch storage paths (TrezorRepoTest,LightningServiceTest) callinitAppStoragePaththemselves.- WorkManager not configured without
AppasConfiguration.Provider: the scheduler tests inject fake or mocked work clients,InitializationProvideris already removed in the manifest, andAppDb's seed enqueue is wrapped in a catch. testDebugsource set (SheetDeepLinksTest) misses the file:src/test/resourcesis on the classpath of every unit test variant.
Merge confidence: 5/5, the unit suite runs green on this head in CI and the change is a test configuration value.
Reviewer model: claude-opus-5-5
Reasoning effort: 15 (numeric run setting, no named level)
jvsena42
left a comment
There was a problem hiding this comment.
Approving at 3b32a12.
Checked and clean:
robolectric.propertiessetsapplication=android.app.Application, which only applies to tests that name no application in@Config. Tests that need Hilt already nameHiltTestApplication.- No unit test at this head casts the application to
Appor reads it throughgetApplicationContext<App>(), so switching the default to a plainApplicationbreaks none of them.build-and-testis green at this head, which runs the full unit suite. - The change only affects the test source set; nothing ships in the app.
Device gate: no device check needed (test configuration only). perf: not relevant.
coreyphillips
left a comment
There was a problem hiding this comment.
Two independent reviews, nothing blocking a merge.
|
Merged: approved by @pwltr, @jvsena42 and @coreyphillips, all checks green, no open threads. |
Unit tests fail now and then on
PubkyAuthManifestTest>signup and authorization links resolve only through their enabled aliases, depending on timing.What happens:
Appfor every test that doesn't name an application.App.onCreatestartsPubkyAuthHandlerRegistraron a real IO scope.MainActivityPubkySignupalias. By then a later test is running in the same process, and if that test isPubkyAuthManifestTest, it finds the alias already enabled and fails.spar/issue-1144(fix: enforce max send fee drains confirmed amount #1147),fix/restore-identity-background(fix: decouple wallet restore from profile refresh #1686),fix/profile-delete-session-recovery(fix: stop automatic profile deletion replay #1688),fix/home-balance-loader(fix: steady home balance header #1729),fix/allowance-backup(fix: keep allowance history across a wallet restore #1708),fix/allowance-follow-ups(fix: allowance follow-ups #1707) andfix/profile-removal-ownership(fix: bind profile removal to its original owner #1693).masterpasses only because of test order and timing.Description
app/src/test/resources/robolectric.propertieswithapplication=android.app.Application, so unit tests run on a plainApplicationunless a test names another one in@Config. The realAppand its production services no longer start in unit tests.masterneeds the realApp: tests that touch it only set the staticApp.currentActivity, and tests that need Hilt already nameHiltTestApplication.Out of Scope
PubkyAuthHandlerRegistrar: its launch scope stays as it is; this PR only stops unit tests from starting it.Design
N/A — no UI changes.
Preview
N/A
QA Notes
Setup
N/A — test-only change; no device testing required.
Journeys
N/A — no user-visible behaviour change.
Manual Tests
N/A
Automated Checks
N/A
Evidence
./gradlew testDevDebugUnitTeston this branch's commit, locally on JDK 17: 4,850 tests, 0 failures.Gaps
Models used
claude-opus-5-5(reasoning:low)claude-opus-5-5(reasoning:low)