Skip to content

test(app): add regression test for toggleApp failed-install branch - #10121

Merged
Git-on-my-level merged 3 commits into
mainfrom
test/toggle-app-regression-guard
Jul 21, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
test/toggle-app-regression-guard

Conversation

@undivisible

@undivisible undivisible commented Jul 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a regression test for the failed-install branch that PR #10100 fixed. The PR changed toggleApp from Future<void> → Future<bool> and routed the create-template sheet through it. The reviewer requested a test covering the failure path so the false-success regression cannot silently return.

Changes

app/lib/providers/app_provider.dart (+10/-3)

Adds two minimal test seams:

Seam Purpose
enableAppOverride Mocks enableAppServer in tests for the failed-install branch
disableAppOverride Mocks disableAppServer for the disable path

Both fall through to the real functions when null — existing callers unaffected.

app/lib/utils/alerts/app_dialog.dart (+3/-1)

Makes AppDialog.show() null-safe: returns early when no navigator is mounted. Prevents a hard crash on the failure path in edge-case production scenarios and in tests without a widget tree.

app/test/providers/app_provider_toggle_test.dart (new, ~85 lines)

Three tests, all pure test() (no widget tree needed):

Test What it covers
returns false when enableAppServer fails (regression guard) The exact regression #10100 fixed — toggleApp must surface failure to its caller
returns true when enableAppServer succeeds Happy path — the override is plumbed correctly and success propagates
does not call enableAppOverride when disabling Disable path uses its own override, not the enable one

Verification

$ flutter test test/providers/app_provider_toggle_test.dart
00:00 +3: All tests passed!

Existing provider tests also pass (no regressions):

$ flutter test test/widget_test.dart test/providers/add_app_provider_test.dart
00:00 +20: All tests passed!

pre-push checks: 10/10 passed.

Failure-Class: none

@Git-on-my-level

Copy link
Copy Markdown
Member

Solid regression guard for the #10100 fix — the failure-path test is exactly the coverage that was requested, and the three cases (fail / succeed / disable) cleanly pin the Future<bool> contract.

Two small notes, neither blocking:

  • The seams (enableAppOverride/disableAppOverride) are clean: nullable, null-fallthrough to the real server calls, so production behavior is unchanged. Since they are test-only, consider annotating them @visibleForTesting — it is already idiomatic in sibling providers (device_provider, sync_provider, …) and signals intent to future readers.
  • The AppDialog.show() null-safety guard is a nice belt-and-suspenders touch for the failure-path crash in tests without a widget tree.

CI on this head looks green on the material checks (Flutter Tests, Dart Analyze ratchet, Generated Files, Android Compile Smoke, PR Preflight all pass). Left un-approved only because the test seams + dialog guard touch provider/dialog surfaces I want a human maintainer to eyeball before merge — happy to convert to an approval once that is confirmed.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level
Git-on-my-level force-pushed the test/toggle-app-regression-guard branch from 5116cbe to 1af99d8 Compare July 21, 2026 01:02
@undivisible

Copy link
Copy Markdown
Collaborator Author

Marked both override seams @visibleForTesting in 68bd562. The focused regression test and analyzer ratchet pass.

Follow-up to #10100 which changed toggleApp from Future<void> to
Future<bool> routed the create-template sheet through it. The
reviewer requested a test covering the failure path so the
false-success regression cannot return silently.

Adds a minimal test seam (enableAppOverride) to AppProvider to
allow mocking enableAppServer without a mocking library.

Test: app/test/providers/app_provider_toggle_test.dart
- toggleApp returns false when enableAppServer fails
- toggleApp returns true when enableAppServer succeeds
- Make AppDialog.show() safe when no navigator is mounted
  (globalNavigatorKey.currentState is null), preventing a crash on the
  failure path in tests and edge-case production scenarios.
- Add disableAppOverride seam to AppProvider for symmetric testability.
- Convert toggleApp tests from testWidgets to pure test() — no widget
  tree needed. Restructure: regression guard + success + disable path.
- Add disable path test: confirms disableAppOverride is called and
  enableAppOverride is not.
@Git-on-my-level
Git-on-my-level force-pushed the test/toggle-app-regression-guard branch from 68bd562 to 867ed2b Compare July 21, 2026 04:20

@Git-on-my-level Git-on-my-level 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.

Approved after independent gpt-5.6-terra review of the post-feedback source, rebase onto current main, and passing fresh Flutter CI: 921 tests, Dart Analyze, Generated Files, formatting, Android smoke, and hygiene.

@Git-on-my-level
Git-on-my-level merged commit ef37a15 into main Jul 21, 2026
28 checks passed
@Git-on-my-level
Git-on-my-level deleted the test/toggle-app-regression-guard branch July 21, 2026 04:39
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.

2 participants