/route-test

Development L2+ Production medium usage

/route-test

Overview

/route-test is a production command in the Development category of the Prismatic Platform. It provides comprehensive HTTP route testing and endpoint verification for Phoenix applications within the umbrella, systematically exercising every defined route to verify correct responses, status codes, content types, and rendering behavior. The command catches routing regressions, dead endpoints, broken LiveView mounts, and misconfigured plugs before they reach production.

This command operates under the L2+ authority level and is executed by the route-test-specialist agent. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. The route-test-specialist has deep knowledge of Phoenix routing conventions, plug pipelines, and LiveView lifecycle, enabling it to generate meaningful test scenarios for each endpoint type.

In a platform with multiple Phoenix applications (prismatic_web on port 4000, prismatic_api on port 4004), each with dozens of routes including LiveView pages, REST endpoints, health checks, and static assets, manual route verification is impractical. /route-test automates this process, providing a single command that exercises the entire routing surface and reports any anomalies.

Architecture

The route testing system operates as a three-phase pipeline: route discovery, request generation, and response validation.

Route Test Architecture

             /route-test
                   |
          Route Discoverer
                   |
          +--------+--------+
          |        |        |
       Phoenix   LiveView   API
       Router    Routes     Routes
          |        |        |
          +--------+--------+
                   |
          Request Generator
                   |
          +--------+--------+
          |        |        |
       HTTP      WebSocket  Health
       Requests  Connections Checks
          |        |        |
          +--------+--------+
                   |
          Response Validator
                   |
          +--------+--------+
          |        |        |
       Status   Content   Performance
       Codes    Types     Metrics
          |        |        |
          +--------+--------+
                   |
           Test Report

Route Categories

CategoryDiscovery MethodTest Strategy
Static Routesmix phx.routesGET request, verify 200 status
LiveView RoutesRouter analysis, live macro detectionMount verification, socket connection
API EndpointsOpenApiSpex schema inspectionGET/POST with sample payloads
Health ChecksConvention (/health, /ready)Response time < 10ms
Static AssetsPlug.Static configurationAsset existence and MIME type
RedirectsRoute analysisFollow chain, verify final destination
Error PagesConvention (/404, /500)Correct error rendering

Usage

# Test all routes across all applications
/route-test

# Test routes for specific application
/route-test --app prismatic_web

# Test specific route pattern
/route-test --path "/perimeter/*"

# Test only LiveView routes
/route-test --type liveview

# Test API endpoints with sample payloads
/route-test --type api --with-payloads

# Verify performance thresholds
/route-test --check-performance

# Output results as JSON
/route-test --format json

# Test with verbose output (request/response details)
/route-test --verbose

# Dry run showing discovered routes
/route-test --dry-run

# Test and compare against baseline
/route-test --compare-baseline

Practical Examples

# Full route verification before deployment
/route-test --check-performance --format json --report ./route-health.json

# Verify Perimeter EASM routes after changes
/route-test --app prismatic_web --path "/perimeter/*" --verbose

# Check all API endpoints respond correctly
/route-test --app prismatic_api --type api --with-payloads

# LiveView mount verification across all pages
/route-test --type liveview --verbose --check-performance

# Quick health check verification
/route-test --type health --timeout 5s

Options

OptionTypeDefaultDescription
--appstringallSpecific Phoenix application to test
--pathstring*Route path pattern (supports wildcards)
--typeenumallRoute type: static, liveview, api, health, assets, redirects, errors, all
--methodstringautoHTTP method filter: get, post, put, delete, all
--with-payloadsflagfalseSend sample payloads to POST/PUT endpoints
--check-performanceflagfalseVerify response times against thresholds
--formatenumtextOutput format: text, json, markdown, junit
--reportpathnoneExport test report to file
--verboseflagfalseShow request/response details
--dry-runflagfalseDiscover routes without testing
--compare-baselineflagfalseCompare against saved baseline
--timeoutduration30sMaximum time per route test
--parallelinteger5Number of parallel test workers
--authstringnoneAuthentication token for protected routes
--excludestringnoneRoute patterns to exclude

Execution Flow

Phase 1: Route Discovery

The command introspects Phoenix routers to discover all defined routes. For each application, it extracts the route table including path, HTTP method, controller/LiveView module, action, and pipeline (plug stack).

Phase 2: Test Plan Generation

Each discovered route is mapped to a test scenario based on its type:

Route TypeTest Scenario
GET staticSingle GET request, verify 200
GET with paramsGenerate sample params from path segments
POST/PUT/DELETEGenerate sample payloads from schema (if available)
LiveViewHTTP GET + WebSocket mount verification
Health checkGET with strict timing requirements
RedirectFollow redirect chain, verify terminal response

Phase 3: Request Execution

Test requests are dispatched in parallel using configurable worker count. Each request is timed and its response captured for validation.

Phase 4: Response Validation

Responses are validated against expected criteria:

CriterionExpectedFailure Threshold
Status Code200 for GET, 2xx for mutationsAny non-2xx (except redirects)
Content-TypeMatches route pipeline (html, json, etc.)Mismatch
Response Time< 250ms total, < 100ms server> threshold
Body PresentNon-empty for content routesEmpty body
LiveView MountWebSocket upgrade succeedsConnection failure

Phase 5: Report Generation

Results are aggregated into a test report showing: routes tested, pass/fail counts, performance metrics, and detailed failure information for any failing routes.

Integration Points

ComponentIntegration TypeDescription
/testPeerRoute tests complement unit/integration tests
/quality-gatesEnforcementRoute health is a quality gate check
/security-auditPeerSecurity audit includes route analysis
/svihadloDownstreamNew features validated through route tests
Prismatic APITargetAPI endpoints are primary test targets
TelemetryMonitoringRoute performance metrics

Best Practices

Pre-Deployment Verification

Run /route-test --check-performance before every deployment. This catches routing regressions and performance degradation that unit tests may miss.

LiveView-Specific Testing

LiveView routes require special attention because they involve both HTTP rendering and WebSocket connections. Use --type liveview --verbose to verify both the initial page load and the socket mount.

API Contract Testing

For API endpoints, always use --with-payloads to verify that endpoints accept and correctly process request bodies. The command generates sample payloads from OpenApiSpex schemas when available.

Baseline Comparison

Maintain a route test baseline and use --compare-baseline to detect newly broken routes. This is especially valuable in CI/CD pipelines where route changes may be unintentional side effects of other modifications.

Error Handling

Error CodeDescriptionResolution
ROUTE_NOT_FOUNDExpected route returns 404Check router configuration for the route
TIMEOUT_EXCEEDEDRoute response exceeded timeoutInvestigate slow controller/LiveView; optimize
MOUNT_FAILURELiveView WebSocket mount failedCheck LiveView module for mount/3 errors
STATUS_UNEXPECTEDUnexpected HTTP status codeReview controller action and plug pipeline
CONTENT_TYPE_MISMATCHResponse content type does not match expectedCheck pipeline content type configuration
SERVER_ERRORRoute returned 500Check server logs for the underlying error
AUTH_REQUIREDRoute requires authenticationProvide --auth token or exclude route

Advanced Usage

Custom Payload Files

Provide custom request payloads for specific endpoints:

/route-test --app prismatic_api --payloads-dir ./test-payloads/

JUnit Report for CI

Generate JUnit XML reports for CI pipeline integration:

/route-test --format junit --report ./test-results/route-tests.xml

Continuous Route Monitoring

Set up periodic route testing for production monitoring:

/route-test --app prismatic_web --type health,liveview --check-performance --interval 5m

Doctrine Compliance

All commands operate under the NO MERCY, NO DOUBTS doctrine:

  • NO MERCY: Zero tolerance for incomplete execution or quality violations. Every defined route must respond correctly or be reported as a failure.
  • NO DOUBTS: Full investigation before action, evidence-based results. Route health is verified through actual HTTP requests, not configuration inspection alone.
  • /test - Comprehensive test generation and verification
  • /code - Core coding implementation and feature development
  • /svihadlo - Ultra-fast visible feature implementation in 5-15 minutes
  • /security-audit - Comprehensive application security audit and vulnerability scan
  • /quality-gates - Enforce quality gate checkpoints with zero-warning compilation validation
  • /fix - Bug fix implementation with mandatory regression tests
  • /regression-check - Execute 25 custom Credo regression checks preventing 700+ violations

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL