Skip to content

Instantly share code, notes, and snippets.

@panchicore
Last active February 21, 2026 17:25
Show Gist options
  • Select an option

  • Save panchicore/b7bcddbf86f47fdb17b7b208115ac504 to your computer and use it in GitHub Desktop.

Select an option

Save panchicore/b7bcddbf86f47fdb17b7b208115ac504 to your computer and use it in GitHub Desktop.
TLC Transport TMS - Test Quality & Optimization Audit

TLC Transport TMS - "Mental Peace" Testing Plan

πŸ“Š Projected Metrics (Production-Grade)

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.

πŸ” Audit Findings (Summary)

  1. Unit Level: 77% of Cost Calculation logic is untested. Brittle mocking (as unknown as) hides type errors.
  2. Integration Level: Tests only verify "Happy Path". No "Negative Tests" for cross-tenant isolation.
  3. Architectural Slop: Business logic is being tested twice (once in Action, once in Service).

πŸš€ The Big Plan: 4 Phases to Mental Peace

Phase 1: Financial Integrity (Unit)

  • Consolidate JSONB condition logic into condition-evaluator.ts.
  • Reach >95% coverage in CostCalculationService & PricingCalculationService.
  • Replace brittle mocks with typed factories.

Phase 2: Data Isolation Shield (Integration)

  • Add mandatory Negative Tests to all Repository integration tests (Org A vs Org B).
  • Verify Soft Delete behavior (Entities with deletedAt must be excluded from lists).

Phase 3: Layer Discipline (Refactor)

  • Refactor Actions to be "Lean Gatekeepers" (Auth + Validation only).
  • Move business logic verification from actions.test.ts to services.test.ts.

Phase 4: Transactional Safety (Integration)

  • Add Service-level integration tests for complex workflows (e.g., Quotation β†’ Shipment conversion).
  • Verify database rollbacks on failure.

πŸ› οΈ Methodology & AI Hints

  • Methodology: Use pnpm test:coverage for logical cold spots + bd list for 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment