♻️ Functional decomposition: build-manager tests + auth-service refactor#129
Conversation
The build-manager already had pure functions exported - just needed to remove unnecessary mocks (crypto, VizzlyError) and test the real behavior. - 42 tests, zero vi.mock - Net reduction of 64 lines
- Extract pure functions to src/auth/core.js (headers, payloads, validation) - Create src/auth/client.js HTTP client factory with DI - Create src/auth/operations.js with dependency-injected auth operations - AuthService class becomes thin wrapper for backwards compatibility - New tests use in-memory token store and mock HTTP client (no vi.mock) - 46 new auth tests, all 987 tests pass
Code Review: Functional Decomposition - build-manager tests + auth-service refactorExcellent work on progressing the functional decomposition roadmap! This PR demonstrates strong architectural improvements with clean separation of concerns. Here's my detailed feedback: ✅ Strengths1. Excellent Test Quality Improvements
2. Clean Functional ArchitectureThe new
3. Backwards CompatibilityThe 4. Strong Documentation
🔍 Code Quality ObservationsMinor: Error Handling in
|
## Summary - Extract pure functions from `ConfigService` into `src/config/core.js` (deepMerge, serialization, validation, config building) - Create `src/config/operations.js` with dependency-injected I/O operations (getConfig, updateConfig, etc.) - Add 91 new tests using simple input/output assertions instead of vi.mock - Keep `ConfigService` class as thin backwards-compatible wrapper, marked `@deprecated` This follows the established pattern from #125 (TddService), #127 (ApiService), and #129 (auth-service). ## Test plan - [x] All 1078 existing tests pass - [x] 91 new tests for config module (57 core + 34 operations) - [x] No `vi.mock` in new tests - [x] Build succeeds - [x] Lint passes
Summary
Progress on the functional decomposition roadmap (#128):
vi.mockcalls - tests now exercise real behavior with 42 tests passingsrc/auth/moduleChanges
build-manager.spec.js
vi.mockforcrypto(was mocking UUID generation)vi.mockforVizzlyError(unnecessary)New
src/auth/modulecore.js- Pure functions for headers, payloads, validation, error parsingclient.js- HTTP client factory with dependency injectionoperations.js- Auth operations takinghttpClientandtokenStoreas parametersindex.js- Public exportsauth-service.js
New tests in
tests/auth/core.spec.js- 29 tests for pure functionsoperations.spec.js- 17 tests using in-memory token store and mock HTTP clienttest-helpers.js- ReusablecreateInMemoryTokenStore()andcreateMockHttpClient()vi.mockusageTest plan