-
Notifications
You must be signed in to change notification settings - Fork 3
[Refactor] Extract AddNodesService and AddWiredNodesService from Notifiers #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Create AddNodesService with JNAP communication logic - setAutoOnboardingSettings(): Enable auto-onboarding - getAutoOnboardingSettings(): Fetch settings as bool - pollAutoOnboardingStatus(): Stream-based status polling - startAutoOnboarding(): Initiate onboarding process - pollForNodesOnline(): Poll for nodes coming online - pollNodesBackhaulInfo(): Poll backhaul info for nodes - collectChildNodeData(): Merge backhaul info into devices - Refactor AddNodesNotifier to delegate to service - Remove JNAP imports (actions, models, result, repository) - Add service getter for dependency injection - Simplify provider to orchestration and state management only - Add comprehensive test suites - AddNodesService tests (17 tests): JNAP calls, error mapping - AddNodesProvider tests (10 tests): Service delegation - AddNodesState tests (15 tests): copyWith, equality, serialization - AddNodesTestData builder for reusable mock responses Architecture compliance: Provider no longer imports JNAP models/result
- Create AddWiredNodesService for wired auto-onboarding JNAP communication - Add BackhaulInfoUIModel to replace BackHaulInfoData in State/Provider layers - Refactor AddWiredNodesNotifier to delegate all JNAP operations to service - Update AddWiredNodesState to use BackhaulInfoUIModel instead of JNAP model Service methods implemented: - setAutoOnboardingEnabled(bool): Enable/disable wired auto-onboarding - getAutoOnboardingEnabled(): Get current setting status - pollBackhaulChanges(snapshot): Stream of BackhaulPollResult for new node detection - fetchNodes(): Get list of LinksysDevice nodes Architecture compliance achieved: - AddWiredNodesNotifier no longer imports jnap/models, jnap/actions, jnap/result - AddWiredNodesState no longer imports jnap/models (uses BackhaulInfoUIModel) - All JNAP errors mapped to ServiceError in service layer Tests added: - BackhaulInfoUIModel: 10 tests (Equatable, toMap/fromMap, toJson/fromJson) - AddWiredNodesService: 14 tests (all public methods) - AddWiredNodesState: 9 tests (BackhaulInfoUIModel integration) - AddWiredNodesProvider: 12 tests (service delegation, error propagation)
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||||||||
User description
Summary
AddNodesServiceandAddWiredNodesServicefrom their respective Notifiers to enforce three-layer architecture compliancejnap/models,jnap/result, orjnap/actionsdirectlyBackhaulInfoUIModelto replace JNAP modelBackHaulInfoDatain State layerChanges
New Files
lib/page/nodes/services/add_nodes_service.dart- Service for wireless node onboardinglib/page/nodes/services/add_wired_nodes_service.dart- Service for wired node onboardinglib/page/nodes/models/backhaul_info_ui_model.dart- UI model replacing JNAP BackHaulInfoDataRefactored Files
lib/page/nodes/providers/add_nodes_provider.dart- Now delegates to AddNodesServicelib/page/nodes/providers/add_wired_nodes_provider.dart- Now delegates to AddWiredNodesServicelib/page/nodes/providers/add_wired_nodes_state.dart- Uses BackhaulInfoUIModel instead of BackHaulInfoDataTest Files
test/page/nodes/services/add_nodes_service_test.dart- 21 teststest/page/nodes/services/add_wired_nodes_service_test.dart- 14 teststest/page/nodes/providers/add_nodes_provider_test.dart- 20 teststest/page/nodes/providers/add_wired_nodes_provider_test.dart- 12 teststest/page/nodes/providers/add_nodes_state_test.dart- 13 teststest/page/nodes/providers/add_wired_nodes_state_test.dart- 9 teststest/page/nodes/models/backhaul_info_ui_model_test.dart- 10 teststest/mocks/test_data/add_nodes_test_data.dart- Test data builderstest/mocks/test_data/add_wired_nodes_test_data.dart- Test data buildersArchitecture Compliance
✅ Provider imports NO
jnap/actions(PASS)✅ Provider imports NO
jnap/models(PASS)✅ Provider imports NO
jnap/result(PASS)✅ Service imports RouterRepository (PASS)
✅ Service maps JNAPError → ServiceError (PASS)
Test plan
flutter test test/page/nodes/)flutter analyze lib/page/nodes/- No issuesPR Type
Enhancement, Tests, Documentation
Description
Extracts
AddNodesServiceandAddWiredNodesServicefrom their respective Notifiers to enforce three-layer architecture complianceServices encapsulate all JNAP communication; Providers delegate to Services
Providers no longer import
jnap/models,jnap/result, orjnap/actionsdirectlyCreates
BackhaulInfoUIModelto replace JNAP modelBackHaulInfoDatain State layerAdds comprehensive test coverage: 119 tests across services, providers, states, and models
Includes detailed specification documentation with contracts, data models, research findings, and implementation quickstart
All architecture compliance checks pass; no direct JNAP imports in Provider layer
Diagram Walkthrough
File Walkthrough
3 files
add_nodes_service.dart
Add Nodes Service Layer for Bluetooth Onboardinglib/page/nodes/services/add_nodes_service.dart
auto-onboarding
detection, and backhaul info
collectChildNodeDatato merge backhaul info into deviceobjects
add_wired_nodes_service.dart
Add Wired Nodes Service Layer for Wired Onboardinglib/page/nodes/services/add_wired_nodes_service.dart
pollBackhaulChangeswith timestamp-based new node detectionfetchNodesto retrieve device list filtered by nodeTypeBackhaulPollResultcontaining found count and onboarded statusbackhaul_info_ui_model.dart
Create BackhaulInfoUIModel for State Layerlib/page/nodes/models/backhaul_info_ui_model.dart
BackHaulInfoDatain state/provider layersdeviceUUID,connectionType,timestampcomparison
5.3.1
3 files
add_nodes_provider.dart
Refactor Add Nodes Provider to Use Service Layerlib/page/nodes/providers/add_nodes_provider.dart
AddNodesServicejnap/actions,jnap/models,jnap/resultadd_wired_nodes_provider.dart
Refactor Wired Nodes Provider to Use Service Layerlib/page/nodes/providers/add_wired_nodes_provider.dart
AddWiredNodesServicejnap/actions,jnap/models,jnap/result_checkBackhaulChangesto use service polling withBackhaulInfoUIModeladd_wired_nodes_state.dart
Update Wired Nodes State to Use BackhaulInfoUIModellib/page/nodes/providers/add_wired_nodes_state.dart
backhaulSnapshotfield type fromListtoListcopyWithand serialization methods to use new UI modelBackHaulInfoDatamodel11 files
add_nodes_service_test.dart
Add Nodes Service Unit Teststest/page/nodes/services/add_nodes_service_test.dart
setAutoOnboardingSettings,getAutoOnboardingSettings,pollAutoOnboardingStatuspollForNodesOnline,pollNodesBackhaulInfo, andcollectChildNodeDataadd_wired_nodes_service_test.dart
Add Wired Nodes Service Unit Teststest/page/nodes/services/add_wired_nodes_service_test.dart
setAutoOnboardingEnabled,getAutoOnboardingEnabled,pollBackhaulChangesfetchNodeswith various scenarios including error handlingadd_nodes_provider_test.dart
Add Nodes Provider Unit Teststest/page/nodes/providers/add_nodes_provider_test.dart
setAutoOnboardingSettings,getAutoOnboardingSettings,startAutoOnboardingstartRefreshand state management with mocked serviceadd_wired_nodes_provider_test.dart
Add Wired Nodes Provider Unit Teststest/page/nodes/providers/add_wired_nodes_provider_test.dart
startAutoOnboardingflow with mocked serviceBackhaulInfoUIModelparameter handlingadd_nodes_state_test.dart
Add Nodes State Unit Teststest/page/nodes/providers/add_nodes_state_test.dart
AddNodesStateimmutability andserialization
copyWith, equality, andtoJson/fromJsonmethodsadd_wired_nodes_state_test.dart
Add Wired Nodes State Unit Teststest/page/nodes/providers/add_wired_nodes_state_test.dart
AddWiredNodesStatewithBackhaulInfoUIModelbackhaulSnapshotfield accepting UI model listscopyWith, serialization, and Equatable behaviorbackhaul_info_ui_model_test.dart
Backhaul Info UI Model Unit Teststest/page/nodes/models/backhaul_info_ui_model_test.dart
BackhaulInfoUIModelserialization andequality
toMap/fromMapandtoJson/fromJsonmethodsadd_nodes_test_data.dart
Add Nodes Test Data Builderstest/mocks/test_data/add_nodes_test_data.dart
responses
and error responses
maintainability
add_wired_nodes_test_data.dart
Add Wired Nodes Test Data Builderstest/mocks/test_data/add_wired_nodes_test_data.dart
responses, and error scenarios
backhaul_info_ui_model_test.dart
BackhaulInfoUIModel serialization and equality teststest/page/nodes/models/backhaul_info_ui_model_test.dart
BackhaulInfoUIModelwith 10 test casescovering Equatable equality, toMap/fromMap roundtrip, and
toJson/fromJson serialization
have matching hash codes
serialization
defaults
add_wired_nodes_test_data.dart
Test data builders for wired nodes service testingtest/mocks/test_data/add_wired_nodes_test_data.dart
mock responses used in AddWiredNodesService tests
backhaul info, and device lists
createBackhaulDevice()generates backhaul device mapscompatible with
BackHaulInfoData.fromMap()createDevice()creates complete device maps with nestedstructures (connections, properties, unit, model, knownInterfaces)
9 files
tasks.md
Complete task breakdown for nodes service extractionspecs/001-add-nodes-service/tasks.md
Bluetooth (AddNodesService) and wired (AddWiredNodesService)
implementations
tasks marked complete
for UI model, service implementation, state updates, and provider
refactoring
and implementation strategies for single developers
spec.md
Feature specification for nodes service extractionspecs/001-add-nodes-service/spec.md
(Bluetooth) and AddWiredNodesService (wired) from their respective
Notifiers
operations, polling, testability, and state model compliance
(SC-001 to SC-011)
implementations
quickstart.md
Implementation quickstart guide for nodes servicesspecs/001-add-nodes-service/quickstart.md
6 steps covering service creation, test data builder, tests, provider
refactoring, and architecture verification
steps including BackhaulInfoUIModel creation, service implementation,
state updates, and compliance verification
test data builders, and refactoring patterns
data-model.md
Data models and architecture flow documentationspecs/001-add-nodes-service/data-model.md
AddNodesService (Bluetooth) with data flow diagrams
BackhaulInfoUIModelentity with fieldsdeviceUUID,connectionType,timestampextending EquatableBackhaulPollResultclass containingbackhaulList,foundCounting, andanyOnboardedfor stream emissionsAddWiredNodesStatereplacingListwithListresearch.md
Design research and decision documentationspecs/001-add-nodes-service/research.md
patterns, error mapping, UI models, and timestamp comparison logic
strategy, LinksysDevice location, and BackhaulInfoUIModel design
AddWiredNodesService as data transformation responsibility
router_password_service.dartandconstitution articles
add_wired_nodes_service_contract.md
AddWiredNodesService method contracts and specificationsspecs/001-add-nodes-service/contracts/add_wired_nodes_service_contract.md
AddWiredNodesServicewith providerdefinition and class structure
setAutoOnboardingEnabled(),getAutoOnboardingEnabled(),pollBackhaulChanges(), andfetchNodes()configurations, and error handling patterns
BackhaulInfoUIModel,BackhaulPollResult),usage examples, and testing contract
add_nodes_service_contract.md
AddNodesService method contracts and specificationsspecs/001-add-nodes-service/contracts/add_nodes_service_contract.md
AddNodesService(Bluetooth) withprovider definition and class structure
setAutoOnboardingSettings(),getAutoOnboardingSettings(),pollAutoOnboardingStatus(),startAutoOnboarding(),pollForNodesOnline(), andpollNodesBackhaulInfo()configurations with specific retry counts and delays
requirements
plan.md
Implementation plan and constitution compliancespecs/001-add-nodes-service/plan.md
AddWiredNodesService (wired) from their respective Notifiers
framework, and performance goals
VII, XI, XIII) are satisfied
and documentation
requirements.md
Specification quality and completeness checklistspecs/001-add-nodes-service/checklists/requirements.md
checkpoints across content quality, requirement completeness, and
feature readiness
testable requirements, and measurable success criteria
violations, new functional requirements (FR-015 to FR-028), and new
success criteria (SC-007 to SC-011)