Repository navigation
Conversation
On a macOS host the exporter takes the Apple path, whose nap writer reads SharedPreferences. The test never mocked it, so every day hit MissingPluginException, reported "export incomplete", and the first pass exported 0 days instead of 2. CI runs on Linux (Health Connect path), so only local macOS runs failed. Mocking prefs keeps the host's own path under test instead of pinning one platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters: 1
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including
|
Reviewer's GuideTestsMock SharedPreferences in the churn test so the macOS Apple export path can read its nap settings.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="test/health_export_finalized_churn_test.dart" line_range="32" />
<code_context>
+ // MissingPluginException on a macOS host (where the exporter takes the
+ // Apple path), every day reported "export incomplete", and the first
+ // pass exported 0 instead of 2.
+ SharedPreferences.setMockInitialValues({});
sqfliteFfiInit();
databaseFactory = databaseFactoryFfi;
</code_context>
<issue_to_address>
**Apple nap regressions go undetected**
When the test runs with the newly mocked empty preference store, `HealthNapExporter._defaultHealthSyncEnabled` reads the unset sync preference as false, so `exportDayNaps` returns successfully before scanning nap rows or reaching the Apple nap writer; this test passes without exercising enabled nap export.
If this test is intended to cover enabled Apple nap export, set `kHealthSyncPref` to true and add a confirmed nap fixture with the writer mocked.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: test/health_export_finalized_churn_test.dart:32
|
@coderabbitai full review |
Action not completed
|
|
@coderabbitai full review |
Action not completed
|
Summary
test/health_export_finalized_churn_test.dartfails on every local macOS run (Expected: <2> Actual: <0>) and passes in CI.Cause.
HealthExporter.isAppleisPlatform.isIOS || Platform.isMacOS, so on a Mac host the exporter takes the Apple path. Apple nap export readsSharedPreferences, which this test never mocked. Each day therefore loggedMissingPluginException, thenwrite Apple naps returned falseandexport incomplete, and the first pass exported 0 days. CI runs on Linux (Health Connect path, no nap prefs read), so only local runs failed.Fix.
SharedPreferences.setMockInitialValues({})insetUpAll. I chose this over pinningisApple: false(the #685 approach) because it keeps the host's own path under test.Test-only change; no product code touched.
Testing
flutter test test/health_export_finalized_churn_test.darton macOS: was 1 failure, now passes.isApple: trueand toisApple: false(throwaway copies, not committed): both pass.flutter analyzeon the file: no issues.Risks and rollback
None for the app. Revert the commit to roll back.
Not in this PR
TZ=UTC flutter test test/whoop_freeze_golden_test.dartalso fails locally on this Mac (macOS 27):dyn_p90differs in the last digit (0.016617360477042792vs golden0.0166173604770428). The goldens compare exactly only on macOS, so this looks like libm last-bit drift on the newer OS. The golden README says not to regenerate without owner approval, so I left it alone. Does it reproduce on another Mac?🤖 Generated with Claude Code
Summary by Sourcery
Make the Health export finalized-churn test reliable across host platforms by providing mocked preferences for Apple-specific settings.
Bug Fixes:
Tests: