| Category | Current State | Projected State | Impact |
|---|---|---|---|
| Core Service Coverage | 22.4% | >95% | Critical: Fixes blind spots in Cost/Price engine. |
| Isolation Coverage | ~0% | 100% | Critical: Proves cross-tenant data leaks are impossible. |
| Soft-Delete Coverage | <10% | 100% | High: Ensures deleted data is hidden from all UIs. |
| Action Redundancy | High | Low | Medium: Leaner, faster, more maintainable test suite. |
- Unit Level: 77% of Cost Calculation logic is untested. Brittle mocking (
as unknown as) hides type errors. - Integration Level: Tests only verify "Happy Path". No "Negative Tests" for cross-tenant isolation.
- Architectural Slop: Business logic is being tested twice (once in Action, once in Service).
- Consolidate JSONB condition logic into
condition-evaluator.ts. - Reach >95% coverage in
CostCalculationService&PricingCalculationService. - Replace brittle mocks with typed factories.
- Add mandatory Negative Tests to all Repository integration tests (Org A vs Org B).
- Verify Soft Delete behavior (Entities with
deletedAtmust be excluded from lists).
- Refactor Actions to be "Lean Gatekeepers" (Auth + Validation only).
- Move business logic verification from
actions.test.tstoservices.test.ts.
- Add Service-level integration tests for complex workflows (e.g., Quotation β Shipment conversion).
- Verify database rollbacks on failure.
- Methodology: Use
pnpm test:coveragefor logical cold spots +bd listfor architectural context. - AI Hint: Prioritize the "Money Engine" (Costs/Prices) and the "Security Layer" (Multi-Tenancy).
- AI Hint: If a test doesn't explicitly verify
organizationId, it is a Weak Approach.