Skip to content

Pin the Health Connect delete-gate test to Health Connect (fails on macOS) - #685

Closed
kurexw wants to merge 1 commit into
OpenStrap:mainfrom
kurexw:fix/health-export-test-macos
Closed

kurexw wants to merge 1 commit into
OpenStrap:mainfrom
kurexw:fix/health-export-test-macos

Conversation

@kurexw

@kurexw kurexw commented Nov 10, 2026 •

Copy link
Copy Markdown

Why

health_workout_export_delete_gate_test ("a failed delete does not write a duplicate on top of it") fails on every Mac and passes in CI.

The exportWorkout delete-then-write group tests the Health Connect reading of a false delete, and its comment assumed "the host VM is neither iOS nor macOS". But HealthExporter.isApple is Platform.isIOS || Platform.isMacOS, and flutter test on a Mac runs on a macOS host VM. There isApple is true, the exporter takes the HealthKit branch (where a false delete is the documented empty-range answer and the write goes ahead, by design), and the test's Health Connect expectation fails. CI runs on ubuntu-latest, so it never sees it; a contributor on a Mac sees a red test unrelated to their change.

The app is fine on both platforms. Only the test was host-dependent.

What changes

  • lib/health/health_export.dart: a @visibleForTesting static bool? isAppleOverride, read first by isApple. null (the default, and always in the app) keeps the real platform check, so production behaviour is unchanged. Same pattern as ScreenWake.platformOverride in lib/gps/screen_wake.dart.
  • test/health_workout_export_delete_gate_test.dart: the group pins isAppleOverride = false in setUp and resets it in tearDown, so it tests Health Connect on every host.

Tests

  • test/health_workout_export_delete_gate_test.dart: 11/11 pass on macOS (was 10/11).
  • flutter analyze: no issues.
  • flutter test --concurrency=1: 7010 passed, 28 skipped, 8 failed. The 8 are the ones fix main's test run: missing translations and gallery case #683 fixes (ui2_tokens gallery, russian_localization, russian_review_findings, settings_report_l10n es/fr/hi/zh, thai_l10n); this test is no longer among them.

Not related to #683, which fixes the other red tests on main (translations, gallery); this one is a macOS-only failure #683 doesn't cover.

🤖 Generated with Claude Code

Summary by Sourcery

Stabilize Health Connect delete-gate coverage across development and CI environments.

Bug Fixes:

  • Make the Health Connect delete-gate test pass consistently on macOS by preventing host-platform-dependent behavior.

Enhancements:

  • Add a test-only override for platform-store selection while preserving production platform detection.

Tests:

  • Pin the delete-then-write tests to Health Connect and restore the platform selection after each test.

Summary by CodeRabbit

  • Chores
    • No user-facing changes in this release. Apple-platform detection behavior remains unchanged in normal use; the update only affects how that behavior can be overridden during testing.

The `exportWorkout delete-then-write` group tests the Health Connect
reading of a false delete, and assumed a non-Apple host. flutter test
on a Mac runs on a macOS host VM, where HealthExporter.isApple is true:
the exporter takes the HealthKit branch (a false delete is the
documented empty-range answer and the write proceeds, by design) and
"a failed delete does not write a duplicate" fails. CI runs on Linux,
so only contributors on a Mac saw it.

Add a @VisibleForTesting HealthExporter.isAppleOverride (null = the
real platform, so the app is unchanged), the same pattern as
ScreenWake.platformOverride, and pin it to false in that group.
@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

HealthExporter.isApple now uses a nullable test override when set. Otherwise, it checks whether the platform is iOS or macOS.

Changes: Apple platform detection

Layer / File(s) Summary
Apple platform override
lib/health/health_export.dart
isApple returns the test override when it is set. A new nullable, visible-for-testing field provides the override. When it is null, the platform check uses the iOS and macOS platform values.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Suggested labels: Review effort 5/5

Suggested reviewers: abdulsaheel

Merge Risk: Minimal · up to 7382f

The test now selects the Health Connect behavior on macOS without changing the default platform check. No merge-blocking risk was identified.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the host-dependent Health Connect test fix and identifies the macOS failure it addresses.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: OpenStrap/edge
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 69341a6
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ebad7965-dbc2-49fc-b116-60378cd89731
Commits

Reviewing files that changed from the base of the PR and between 69341a6 and 7382f7e.

Files ignored due to path filters: 1

  • test/health_workout_export_delete_gate_test.dart is excluded by !test/**
Files selected for processing: 1

  • lib/health/health_export.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@sourcery-ai

sourcery-ai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Add a test-only override for the Apple-platform check while preserving the real platform check by default.

  • lib/health/health_export.dart L628-635

Tests

Pin the delete-gate test group to Health Connect and reset the override after each test so behavior is consistent across hosts.

  • test/health_workout_export_delete_gate_test.dart L88-97

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@kurexw
kurexw marked this pull request as ready for review November 10, 2026 15:52

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@kurexw

kurexw commented Nov 11, 2026

Copy link
Copy Markdown
Author

Closing this myself: it only matters when running the suite on macOS, which CI doesn't do. Glad to reopen if it's wanted.

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.

1 participant