feat: Support passing appGroupId directly with functions#416
Conversation
|
To view this pull requests documentation preview, visit the following URL: docs.page/abausg/home_widget~416 Documentation is deployed and generated using docs.page. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughAdds optional per-call ChangesPer-Call App Group ID Support
Sequence Diagram(s)sequenceDiagram
participant Flutter as Flutter (HomeWidget)
participant Channel as MethodChannel
participant Plugin as iOS HomeWidgetPlugin
participant UD as UserDefaults / FileSystem
Flutter->>Channel: saveWidgetData(id, data, appGroupId?)
Channel->>Plugin: invokeMethod("saveWidgetData", {id, data, appGroupId?})
Plugin->>Plugin: resolvedId = resolvedAppGroupId(from: call) // arg or global
Plugin->>UD: UserDefaults(suiteName: resolvedId).set(...)/write file
UD-->>Plugin: ack
Plugin-->>Channel: result(success)
Channel-->>Flutter: result
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #416 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 3 3
Lines 167 175 +8
=========================================
+ Hits 167 175 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/home_widget/test/home_widget_test.dart (1)
181-198: ⚡ Quick winTest path
/widget/file.bindoesn't exercise the managed-file deletion branch withappGroupId.
_isHomeWidgetManagedFilePath('/widget/file.bin')returnsfalse(no/home_widget/segment), so this test validatesappGroupIdforwarding through both channel calls but not the actual file-deletion sub-path. The iOS integration test (saveFile and clear with appGroupId override) covers that end-to-end; consider adding an analogue here using a path like/app/home_widget/file.binto close the unit-test gap on the deletion branch.✏️ Suggested addition to cover the managed-path + appGroupId deletion branch
test('delete flow forwards appGroupId to get and save', () async { getWidgetDataReturn = '/widget/file.bin'; // ...existing assertions... }); + + test('managed path deletion forwards appGroupId', () async { + getWidgetDataReturn = '/app/home_widget/file.bin'; + const id = 'fileKey'; + const appGroupId = 'group.test.per.call'; + final file = MockFile(); + when(() => file.exists()).thenAnswer((_) async => true); + when(() => file.delete()).thenAnswer((_) async => file); + + await IOOverrides.runZoned( + () async { + expect( + await HomeWidget.saveWidgetData(id, null, appGroupId: appGroupId), + true, + ); + }, + createFile: (path) { + when(() => file.path).thenReturn(path); + return file; + }, + ); + expect(invocations[0].arguments['appGroupId'], appGroupId); + expect(invocations[1].arguments['appGroupId'], appGroupId); + verify(() => file.delete()).called(1); + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/home_widget/test/home_widget_test.dart` around lines 181 - 198, The test uses getWidgetDataReturn = '/widget/file.bin' which does not trigger the managed-file deletion branch because _isHomeWidgetManagedFilePath returns false; update the test (the one named "delete flow forwards appGroupId to get and save") to use a managed path such as '/app/home_widget/file.bin' for getWidgetDataReturn so that HomeWidget.saveWidgetData exercises the deletion sub-path, and keep asserting that both platform channel invocations (getWidgetData and saveWidgetData) include the appGroupId as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/home_widget/test/home_widget_test.dart`:
- Around line 181-198: The test uses getWidgetDataReturn = '/widget/file.bin'
which does not trigger the managed-file deletion branch because
_isHomeWidgetManagedFilePath returns false; update the test (the one named
"delete flow forwards appGroupId to get and save") to use a managed path such as
'/app/home_widget/file.bin' for getWidgetDataReturn so that
HomeWidget.saveWidgetData exercises the deletion sub-path, and keep asserting
that both platform channel invocations (getWidgetData and saveWidgetData)
include the appGroupId as before.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a48fb1e9-0d17-451d-ba1b-1f3d01b33e19
📒 Files selected for processing (4)
packages/home_widget/example/integration_test/ios_test.dartpackages/home_widget/ios/home_widget/Sources/home_widget/HomeWidgetPlugin.swiftpackages/home_widget/lib/src/home_widget.dartpackages/home_widget/test/home_widget_test.dart
Co-authored-by: Cursor <cursoragent@cursor.com>
Description
Support providing an
appGroupIddirectly in invocations ofsaveWidgetData,updateWidgetetc to not rely on storing it globally for the whole plugin staticallyChecklist
exampleor documentation.Breaking Change?
Related Issues