Skip to content

Automated Smoke Tests

Continuous system health monitoring through automated database and API testing

Overview

BlueClerk runs automated smoke tests every 30 minutes to ensure core operations are working correctly. These tests create real database records (tickets, jobs, invoices), verify they're readable, test read performance with parallel queries, then clean up automatically. If any test fails, the system logs the error for admin review.

What Gets Tested

Core Operations

The smoke test verifies:

  • Ticket creation - Creates a test ticket and verifies it's readable
  • Job creation - Creates a test job and verifies it's readable
  • Invoice creation - Creates a test invoice and verifies it's readable
  • Database read performance - Runs parallel count queries to check response times

Automatic Cleanup

All test records are deleted using belt-and-suspenders deletion:

  • By record ID
  • By description match (__SMOKE_TEST__ prefix)

This ensures no test data pollutes your production database.

How It Works

Scheduled Execution

  • Runs every 30 minutes via Vercel cron
  • Protected by CRON_SECRET - Only authorized requests execute tests
  • Maximum 30 second runtime - Fails fast if something hangs

Test Flow

  1. Find test data - Locates a contractor company, admin user, and property to use for testing
  2. Run each test - Creates records, verifies reads, measures timing
  3. Log failures - Any failure logs error details to SystemHealthLog
  4. Clean up - Deletes all test records, whether tests passed or failed

Results Tracking

Each test tracks:

  • Name - Which operation was tested
  • Pass/fail status - Did it succeed?
  • Execution time - How long it took in milliseconds
  • Error details - If failed, what went wrong

What Admins See

SystemHealthLog

Failed tests create SystemHealthLog entries with:

  • Which test failed
  • Error message
  • Stack trace for debugging
  • Timestamp of failure

When Tests Are Skipped

If no test data exists (no contractor company, admin user, or property), the smoke test returns:

status: "SKIP"
message: "No test data (company/member/property) — skipping smoke test"

This prevents false alarms in empty or sandbox environments.

Why Smoke Tests Matter

Early Detection

Catch database or API problems before customers do. If ticket creation breaks, you'll know within 30 minutes.

System Confidence

Continuous testing means you can trust core operations are working, even after deployments or infrastructure changes.

Real-World Testing

These aren't mocked tests - they use real database operations identical to what your users experience daily.

Was this article helpful?

Still need help?

Contact Support →