Skip to main content

Testing, Verification & Quality Assurance

This document provides a comprehensive technical audit of the verification strategies, static analysis suites, operational test scripts, and manual test harnesses currently implemented in the HiTech Insurance codebase, accompanied by an actionable roadmap for automated testing expansion.


1. Static Verification Pipeline​

The codebase enforces a multi-tier static validation pipeline executed locally and in continuous integration environments:

1. Strict TypeScript Compiler Verification​

npm run type-check

Executes tsc --noEmit against tsconfig.json. Enforces strict type inference, zero unchecked index access, explicit function returns, and prevents invalid props from reaching React components.

2. ESLint 9 Code Quality Inspection​

npm run lint
npm run lint:fix

Runs ESLint with Next.js core Web Vitals plugins and TypeScript-ESLint. Enforces React Hooks dependency rules (react-hooks/exhaustive-deps), accessibility rules, and identifies dead code.

3. Prettier Formatting Validation​

npm run format:check
npm run format

Validates consistent code formatting across all .ts, .tsx, .json, and .md files.


2. Operational Testing Scripts (scripts/)​

The repository includes specialized CLI test harnesses in scripts/ designed to verify critical backend subsystems without running the full Next.js development server:

ScriptExecution CommandPurpose & Verification Scope
Rate Limiter Testnpx tsx scripts/test-rate-limiter.tsSimulates high-velocity concurrent requests against the sliding-window rate limiter, testing TTL key eviction, window expiration, and 429 Too Many Requests enforcement.
OpenAPI Spec Auditornode scripts/check-spec.jsInspects all registered routes and verifies that endpoint definitions align with the OpenAPI 3.0 specification in openapi.json.
Email Dispatch Probenode scripts/send-test-email.jsTests Azure Email Microservice connectivity and verifies automatic fallback to Nodemailer SMTP.
File-Based Email Probenode scripts/send-test-from-file.jsParses an external HTML template file and dispatches a test payload to verify image rendering and CSS inlining.
Super Admin Provisionernpm run seed:super-adminVerifies database connectivity and idempotently inserts or updates the root super_admin role user.
Admin Seed Suitenpm run seed:adminsProvisions regional admin and claims manager accounts.

3. Visual & In-Browser Test Harnesses​

To facilitate visual quality assurance and partner integration testing:

1. Partner Widget Sandbox (public/widget-test.html)​

A standalone HTML test harness located at http://localhost:3000/widget-test.html. It tests the Shadow DOM partner web widget across:

  • Dark vs. Light theme rendering.
  • Card vs. Pill vs. Floating docked badge variants.
  • Custom UTM attribute inheritance.
  • Responsive container resizing down to mobile viewports.

2. Live Email Template Studio (/email-preview)​

An internal development route accessible at http://localhost:3000/email-preview. It renders all 11 transactional HTML email templates (Quote Confirmations, Welcome Emails, Password Resets, Claim Submissions, Referral Receipts) in real time with hot-reload support, allowing designers to inspect responsive layout rendering across mobile and desktop frames.

3. Real-Time System Health Diagnostics (/admin/system-health)​

A diagnostics dashboard monitoring:

  • Database round-trip ping latency (ms).
  • Node.js runtime uptime.
  • V8 Heap memory distribution (heapUsed, heapTotal, external, rss).
  • Active sliding-window rate limit document counts.

4. Health Check Probe (/api/health)​

An automated health check route returning JSON status indicators:

curl -f http://localhost:3000/api/health
{
"status": "healthy",
"database": "connected",
"timestamp": "2026-11-03T08:45:00.000Z",
"uptime": 86400
}

Current Codebase Assessment​

An exhaustive inspection of the source repository reveals that automated unit, integration, and end-to-end test runners (e.g. Jest, Vitest, Playwright, Cypress) are not currently installed or configured in package.json. While static typing and standalone operational scripts provide baseline safety, the introduction of automated suites is strongly recommended as the platform scales.

Phase 1: Unit Testing Core Algorithms (Vitest)​

Install and configure Vitest to provide zero-configuration unit testing for pure business logic:

  • Rate Limiter Logic: Test window calculation and sliding timestamp math.
  • HMAC Signature Generation: Test canonical payload sorting and timing-safe comparison.
  • Reading Time Calculator: Verify word-count parsing across English and Spanish blog articles.
  • Data Transformers: Validate conversion of commercial trucking payloads into HTI CRM format.

Phase 2: Integration Testing for Server Actions & APIs​

  • Integrate mongodb-memory-server to run in-memory MongoDB instances during test execution.
  • Write integration tests for:
    • createBlog, updateBlog, and scheduled publishing auto-transitions.
    • Quote draft autosaving (/api/forms/quote/draft) and atomic completion (/api/forms/quote/complete).
    • reCAPTCHA quarantine routing when scores fall below 0.5.

Phase 3: End-to-End Browser Automation (Playwright)​

Deploy Playwright to execute automated headless browser simulations in CI:

  • 16-Step Personal Auto Funnel: Verify user progression from Step 1 through Step 16 with field validation.
  • Commercial Trucking Funnel: Verify USDOT, MC#, and fleet input masks.
  • Admin Control Center: Test role-based access restrictions and tab navigation across all 20 tabs.