Skip to content

fix: Flutter & Dart SDKs - all tests passing (405/405 unit, 138/138 cross-SDK)#7

Open
joalves wants to merge 28 commits intomainfrom
fix/all-tests-passing
Open

fix: Flutter & Dart SDKs - all tests passing (405/405 unit, 138/138 cross-SDK)#7
joalves wants to merge 28 commits intomainfrom
fix/all-tests-passing

Conversation

@joalves
Copy link
Contributor

@joalves joalves commented Feb 21, 2026

Summary

  • Flutter SDK: 158/158 unit tests passing, exit code 0
  • Dart SDK: 247/247 unit tests passing, exit code 0
  • Cross-SDK tests: 138/138 scenarios passing for both Flutter and Dart wrappers

Flutter SDK fix

  • Fixed platform_test.dart line 481: throwsException -> throwsStateError
  • Context.peekTreatment throws StateError (extends Error), not Exception -- these are separate hierarchies in Dart

Dart SDK fixes

  • Changed Exception to ArgumentError for unit validation errors (proper Dart semantics)
  • Changed Exception to StateError for context state errors (closed/closing/not ready)
  • Fixed track() to use the properties parameter correctly (was always passing empty {})
  • Fixed getUnits() to return actual units map (was returning empty map)
  • Added attribute name validation (reject empty names)
  • Added catchError handlers for timer-based flush() and refresh() to prevent unhandled async errors

Monorepo restructure (included in this PR)

  • Split into packages/dart_sdk (pure Dart) and packages/flutter_sdk (Flutter widgets)
  • Added Flutter-specific widgets: Treatment, TreatmentBuilder, TreatmentSwitch, VariableValue, ABSmartlyProvider
  • Comprehensive test coverage: integration tests, performance tests, error recovery tests, widget tests

Test plan

  • dart test in packages/dart_sdk -- 247/247 passed, exit code 0
  • flutter test in packages/flutter_sdk -- 158/158 passed, exit code 0
  • Cross-SDK Docker test suite -- 138/138 scenarios passed for both wrappers
  • Docker wrapper builds and responds on health endpoint

… tests

- Add optional httpClient parameter to DefaultHTTPClient for dependency injection
- Rewrite tests to use Mockito mocks instead of real HTTP calls to jsonplaceholder.typicode.com
- Add comprehensive test coverage for retry logic (502/503), error handling (4xx), and connection failures
- Tests are now deterministic and don't depend on external services
- Add attrsSeq tracking to detect attribute changes after assignment
- Add audienceMatches() method to check if audience match status changed
- Clear assignment cache when audience mismatch status changes
- Update example pubspec.lock
Add absmartly_dart.dart as the main entry point that exports all public
APIs including SDK classes, configurations, providers, handlers, and
JSON models.
- Copy all tests from Flutter SDK to dart_sdk package
- Update imports from package:absmartly_sdk to package:absmartly_dart/src/
- Replace flutter_test with test package
- Remove Flutter-specific bindings (WidgetsFlutterBinding)
- Update test_utils.dart to use dart:io instead of Flutter's rootBundle
- Copy test resources (JSON fixtures) for tests
- Regenerate mockito mocks for new package structure
- All 215 tests pass
Move the example Flutter app from the root example/ directory to
packages/flutter_sdk/example/. Also simplify imports to use the
single barrel file import instead of individual file imports.
Add declarative widgets for A/B testing in Flutter:
- ABSmartlyProvider: InheritedWidget for context propagation
- Treatment: Map-based variant rendering
- TreatmentBuilder: Builder pattern with variables access
- TreatmentSwitch/TreatmentVariant: Declarative child-based variants
- LoadingBehavior: Configurable loading state handling

All widgets support:
- Custom loading widgets
- Timeout-based fallback to control
- Silent error handling (fallback to control on failure)
- Optional custom context override

Includes 62 passing tests covering all widget functionality.
- Add VariableValue widget export to flutter_sdk
- Fix context assignment cache clearing on refresh
- Remove duplicate unit handling in context
- Enhance audience_matcher tests with comprehensive coverage
- Add Flutter widget integration tests
- Add error recovery scenario tests
- Add platform-specific edge case tests
- Add performance tests
- Add integration scenario tests

Total: 130 new tests added, all 158 tests pass
Add 22 context tests covering refresh state preservation,
exposure queuing after peek, variable value deduplication,
close/publish error handling, post-close exceptions, and
unknown experiment/variable handling. Fix 9 pre-existing
refresh test failures caused by assignmentCache clearing.
…platform_test

Context.peekTreatment throws StateError (not Exception) when the context
is not ready. StateError extends Error, not Exception, so throwsException
matcher was incorrect. This fix aligns the test with the actual error type.

Result: 158/158 flutter_sdk unit tests passing, exit code 0.
…ility

- Change exceptions to ArgumentError/StateError for proper Dart semantics
- Fix track() to use properties parameter correctly (was always empty {})
- Fix getUnits() to return actual units (was returning empty map)
- Add attribute name validation
- Add catchError handlers for timer-based flush/refresh
- Update tests for new error types and behavior

Result: 247/247 dart_sdk unit tests passing, exit code 0.
138/138 cross-SDK tests passing.
@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

Important

Review skipped

Too many files!

This PR contains 221 files, which is 71 over the limit of 150.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/all-tests-passing

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant