Skip to content

fix: unit tests no longer race the app's pubky link setup - #1776

Merged
ovitrif merged 1 commit into
masterfrom
fix/unit-tests-plain-application
Nov 4, 2026
Merged

ovitrif merged 1 commit into
masterfrom
fix/unit-tests-plain-application

Conversation

@ovitrif

@ovitrif ovitrif commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Unit tests fail now and then on PubkyAuthManifestTest > signup and authorization links resolve only through their enabled aliases, depending on timing.

What happens:

Description

  • Adds app/src/test/resources/robolectric.properties with application=android.app.Application, so unit tests run on a plain Application unless a test names another one in @Config. The real App and its production services no longer start in unit tests.
  • No test on master needs the real App: tests that touch it only set the static App.currentActivity, and tests that need Hilt already name HiltTestApplication.
  • The same change fixed this failure on the Spark branch, feat: add spark via breez sdk #1697, in commit 2cc9102.

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 testDevDebugUnitTest on this branch's commit, locally on JDK 17: 4,850 tests, 0 failures.

Gaps

  • The failure depends on timing, so one green run doesn't prove it on its own; the 7 branches above should stop seeing it once they include this change.

Models used

  • Planning/scoping: claude-opus-5-5 (reasoning: low)
  • Implementation: claude-opus-5-5 (reasoning: low)
  • Review: Not performed

@ovitrif ovitrif self-assigned this Nov 4, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T19:41:27.538948Z 3b32a12 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ovitrif
ovitrif requested review from a team, coreyphillips and pwltr and removed request for a team November 4, 2026 19:40
@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] This test-only change appears safe to merge.

Summary

Adds robolectric.properties so Robolectric tests use android.app.Application by default.

  • Robolectric tests use a plain application unless they choose another.

Reviews (1) · Last reviewed commit: "fix: unit tests no longer race the app's..." · Reviewed by Greptile

@pwltr pwltr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 3b32a12 (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.onCreate side effects: the only uses of App in those 18 classes set the static App.currentActivity, which needs no App instance.
  • Env.initAppStoragePath no longer runs, so Env.logDir or a storage path throws: AppLogger wraps session path creation in runCatching, and the two tests that touch storage paths (TrezorRepoTest, LightningServiceTest) call initAppStoragePath themselves.
  • WorkManager not configured without App as Configuration.Provider: the scheduler tests inject fake or mocked work clients, InitializationProvider is already removed in the manifest, and AppDb's seed enqueue is wrapped in a catch.
  • testDebug source set (SheetDeepLinksTest) misses the file: src/test/resources is 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 jvsena42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at 3b32a12.

Checked and clean:

  • robolectric.properties sets application=android.app.Application, which only applies to tests that name no application in @Config. Tests that need Hilt already name HiltTestApplication.
  • No unit test at this head casts the application to App or reads it through getApplicationContext<App>(), so switching the default to a plain Application breaks none of them. build-and-test is 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 coreyphillips left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two independent reviews, nothing blocking a merge.

@ovitrif

ovitrif commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator Author

Merged: approved by @pwltr, @jvsena42 and @coreyphillips, all checks green, no open threads.

@ovitrif
ovitrif merged commit 21f0b40 into master Nov 4, 2026
24 checks passed
@ovitrif
ovitrif deleted the fix/unit-tests-plain-application branch November 4, 2026 20:07
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.

5 participants