test: implement integration test with RemoteConfig class#9
Conversation
|
Warning Review limit reached
Next review available in: 36 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughFlutterSkin.init and FskinRemoteConfig.init now accept optional injectable dependencies (remoteConfig and skinService, respectively) for testability. FskinRemoteConfig.init also validates apiKey via regex. Tests migrated from mockito to mocktail, and a new integration test file was added. ChangesTestable Initialization Flow
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lib/flutter_skin.dart (1)
115-118: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
resetInstance()leaksWidgetsBindingObserver— addremoveObserverbefore nulling the instance.
FlutterSkin.initcallsWidgetsBinding.instance.addObserver(_instance!)when creating a new instance, butresetInstance()only sets_instance = nullwithout callingremoveObserver. In the integration test suite,setUpcallsresetInstanceand each test callsinit, so observers accumulate — 4 tests produce 4 registered observers referencing stale instances. IfdidChangeAppLifecycleStatefires on an old observer, it operates on a detachedremoteConfigandapiKey.🔒 Proposed fix
`@visibleForTesting` static void resetInstance() { + if (_instance != null) { + WidgetsBinding.instance.removeObserver(_instance!); + } _instance = null; }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/flutter_skin.dart` around lines 115 - 118, `FlutterSkin.resetInstance()` is clearing `_instance` without unregistering the existing `WidgetsBindingObserver`, so update it to remove the current instance from `WidgetsBinding.instance` before setting the singleton to null. Use the `FlutterSkin.init`/`_instance` pairing to locate the lifecycle registration and ensure `removeObserver` is called only when an instance exists, preventing stale observers from accumulating across tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/remote/fskin_remote_config.dart`:
- Around line 49-55: The null check after `_instance ??= FskinRemoteConfig._()`
in `FskinRemoteConfig.init()` is unreachable because the assignment always
initializes the singleton. Remove the dead `if (_instance == null)`/throw block
and keep the method focused on ensuring `_instance` is created via
`FskinRemoteConfig._()`, so the initialization contract is clear and consistent.
In `@test/flutter_skin/flutter_skin_init_test.dart`:
- Around line 22-28: The test setup in FlutterSkin.init is reusing singleton
state, which can leak observers and instance data across cases. Update the setUp
block to call FlutterSkin.resetInstance() and FskinRemoteConfig.resetInstance()
before invoking FlutterSkin.init, matching the isolation pattern used in the
integration tests. Keep the reset calls in the test lifecycle setup so each test
starts from a clean FlutterSkin._instance state.
In `@test/flutter_skin/flutter_skin_integration_with_service.dart`:
- Line 18: The shared group-level MockSkinService instance in
flutter_skin_integration_with_service.dart can leak stubs between tests because
mocktail does not clear them automatically. Move MockSkinService creation into
each individual test (or set it up in per-test setup) so every test gets a fresh
instance, and keep the fetchData stubbing local to the test that uses it. Use
the MockSkinService variable near the integration test setup to locate and
update the shared fixture.
---
Outside diff comments:
In `@lib/flutter_skin.dart`:
- Around line 115-118: `FlutterSkin.resetInstance()` is clearing `_instance`
without unregistering the existing `WidgetsBindingObserver`, so update it to
remove the current instance from `WidgetsBinding.instance` before setting the
singleton to null. Use the `FlutterSkin.init`/`_instance` pairing to locate the
lifecycle registration and ensure `removeObserver` is called only when an
instance exists, preventing stale observers from accumulating across tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0f111aa0-d956-4885-8301-83eb6294c8d0
📒 Files selected for processing (5)
lib/flutter_skin.dartlib/remote/fskin_remote_config.dartpubspec.yamltest/flutter_skin/flutter_skin_init_test.darttest/flutter_skin/flutter_skin_integration_with_service.dart
333bd2f to
e3b898d
Compare
Summary by CodeRabbit
New Features
Bug Fixes
Tests