test(ensemble): cover ensemble.storage.clear dispatch key selection#2228
Merged
Conversation
Extract ensembleStorageClearDispatchKeys so the enc_ prefix contract used when clearing public storage and notifying bindings is unit-tested without touching global GetStorage (full clear would wipe the shared test box). Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
sharjeelyunus
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds regression coverage for which public storage keys receive binding notifications when
ensemble.storage.clear()runs, matching theenc_prefix contract used byStorageManager.clearPublicStorage().Related Issue
Regression test coverage (cron automation).
Type of Change
What Has Changed
@visibleForTestinghelperensembleStorageClearDispatchKeysindata_context.dartand wiredEnsembleStorage.clear()to use it (same behavior as before).ensemble_storage_clear_test.dartwith unit tests for the dispatch key list.Risky behavior now covered
ScreenController().dispatchStorageChangesafter a clear diverges from what was actually removed, widgets bound to storage would not refresh or could refresh incorrectly.enc_namespace: Only theenc_prefix is treated as encrypted storage; keys likeenc2must not be misclassified (regression guard for prefix logic).Test files added/updated
modules/ensemble/test/ensemble_storage_clear_test.dart(new)modules/ensemble/lib/framework/data_context.dart(minimal refactor to share the key-selection logic)Why these tests materially reduce regression risk
ensemble.storage.clear()clears the global publicGetStoragebox, so an integration test that calls the real method would wipe shared state for the entire test isolate. The extracted helper pins the contract between “which keys are cleared” and “which keys get a null storage binding event” in fast, deterministic unit tests without touchingGetStorage.How to Test
modules/ensemble:flutter test test/ensemble_storage_clear_test.dartChecklist
flutter analyzeand addressed any new warningsflutter testand all tests passAutomation note: The cloud agent environment did not have the Flutter/Dart SDK on
PATH, soflutter test/flutter analyzewere not executed here. Please run the command above locally or in CI to confirm.