TL;DR: Add unit tests for the three load-bearing, currently untested service/permission/preset modules, so the rest of the service-layer epic can refactor with a safety net.
Context
Sub-issue of #79 (service-layer hardening). api-client.ts (865 lines), usePermissionChecks.ts (210), and useUserPresets.ts (371) have zero unit tests, while they handle API transport, permission gating, and persistence of all user UI state. RelationChecker is the only tested service and can serve as the pattern.
Acceptance Criteria
Scope
In Scope:
- Test files for the three modules, with mocked SDK/transport
- Test fixtures/mocks reusable by later sub-issues
Out of Scope:
Technical Implementation
- Targets:
src/services/api-client.ts, src/composables/usePermissionChecks.ts, src/composables/useUserPresets.ts
- Pattern: mirror the existing
RelationChecker spec; mock the Directus SDK (useApi/useStores) and the transport
- Tests live under the existing
test/ directory; reuse test/setup.ts
Architecture Reference
Dependencies
TL;DR: Add unit tests for the three load-bearing, currently untested service/permission/preset modules, so the rest of the service-layer epic can refactor with a safety net.
Context
Sub-issue of #79 (service-layer hardening).
api-client.ts(865 lines),usePermissionChecks.ts(210), anduseUserPresets.ts(371) have zero unit tests, while they handle API transport, permission gating, and persistence of all user UI state.RelationCheckeris the only tested service and can serve as the pattern.Acceptance Criteria
DirectusApiClientcore paths (success + error/retry) with a mocked transportusePermissionChecks(role resolution, allow/deny outcomes)useUserPresets(load, save, defaults)Scope
In Scope:
Out of Scope:
Technical Implementation
src/services/api-client.ts,src/composables/usePermissionChecks.ts,src/composables/useUserPresets.tsRelationCheckerspec; mock the Directus SDK (useApi/useStores) and the transporttest/directory; reusetest/setup.tsArchitecture Reference
Dependencies