Skip to content

test(ensemble): cover ensemble.storage.clear dispatch key selection#2228

Merged
sharjeelyunus merged 1 commit into
mainfrom
cursor/regression-test-coverage-9c58
May 21, 2026
Merged

test(ensemble): cover ensemble.storage.clear dispatch key selection#2228
sharjeelyunus merged 1 commit into
mainfrom
cursor/regression-test-coverage-9c58

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 21, 2026

Description

Adds regression coverage for which public storage keys receive binding notifications when ensemble.storage.clear() runs, matching the enc_ prefix contract used by StorageManager.clearPublicStorage().

Related Issue

Regression test coverage (cron automation).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

  • Introduced @visibleForTesting helper ensembleStorageClearDispatchKeys in data_context.dart and wired EnsembleStorage.clear() to use it (same behavior as before).
  • Added ensemble_storage_clear_test.dart with unit tests for the dispatch key list.

Risky behavior now covered

  • Binding notifications after clear: If the set of keys passed to ScreenController().dispatchStorageChanges after a clear diverges from what was actually removed, widgets bound to storage would not refresh or could refresh incorrectly.
  • enc_ namespace: Only the enc_ prefix is treated as encrypted storage; keys like enc2 must 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 public GetStorage box, 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 touching GetStorage.

How to Test

  1. From modules/ensemble: flutter test test/ensemble_storage_clear_test.dart

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors

Automation note: The cloud agent environment did not have the Flutter/Dart SDK on PATH, so flutter test / flutter analyze were not executed here. Please run the command above locally or in CI to confirm.

Open in Web View Automation 

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 sharjeelyunus marked this pull request as ready for review May 21, 2026 13:25
@sharjeelyunus sharjeelyunus merged commit a591636 into main May 21, 2026
5 checks passed
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.

2 participants