fix: Flutter & Dart SDKs - all tests passing (405/405 unit, 138/138 cross-SDK)#7
fix: Flutter & Dart SDKs - all tests passing (405/405 unit, 138/138 cross-SDK)#7joalves wants to merge 28 commits into
Conversation
… 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.
|
Important Review skippedToo many files! This PR contains 221 files, which is 71 over the limit of 150. You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Pedro-Revez-Silva
left a comment
There was a problem hiding this comment.
Approved per request. This older all-tests-passing PR still has the same audit gaps as the newer audit-fix branch: the transport tests stop at mocked http.Client and do not exercise a real local server for Dart refresh/publish. Widget wrapper coverage is broad, but the production transport path still needs deterministic integration coverage. Please also reconcile this with PR #8, where the Analyze check is currently failing.
Summary
Flutter SDK fix
platform_test.dartline 481:throwsException->throwsStateErrorContext.peekTreatmentthrowsStateError(extendsError), notException-- these are separate hierarchies in DartDart SDK fixes
ExceptiontoArgumentErrorfor unit validation errors (proper Dart semantics)ExceptiontoStateErrorfor context state errors (closed/closing/not ready)track()to use thepropertiesparameter correctly (was always passing empty{})getUnits()to return actual units map (was returning empty map)catchErrorhandlers for timer-basedflush()andrefresh()to prevent unhandled async errorsMonorepo restructure (included in this PR)
packages/dart_sdk(pure Dart) andpackages/flutter_sdk(Flutter widgets)Treatment,TreatmentBuilder,TreatmentSwitch,VariableValue,ABSmartlyProviderTest plan
dart testinpackages/dart_sdk-- 247/247 passed, exit code 0flutter testinpackages/flutter_sdk-- 158/158 passed, exit code 0