Skip to content

Conversation

@AdaInTheLab
Copy link
Owner

Summary

This PR stabilizes the API’s core wiring and restores trust in the test suite by eliminating divergent app initialization paths and enforcing a single, canonical test app factory.

What began as intermittent 404s and “missing initializer” errors was ultimately a systems-boundary issue: tests, runtime, and environment configuration had quietly drifted out of alignment. This PR realigns them.


Key Changes

🧪 Test Infrastructure

  • Introduces a single JS-only createTestApp helper used by all test suites
  • Eliminates TypeScript syntax leakage into JS execution contexts
  • Ensures deterministic test fixtures (explicit seeding for Lab Note detail routes)
  • Centralizes API prefix handling via shared api() helper
  • Restores full green test matrix (6/6 suites, 10/10 tests)

🧬 Application Wiring

  • Initializes Express with core middleware:
    • CORS
    • Session management
    • Passport authentication
  • Centralizes database connection and schema bootstrapping
    • Optional development seeding supported
  • Registers all routes in one place:
    • Health
    • Admin
    • Lab Notes
    • OpenAPI / spec validation
  • Aligns test app initialization with production wiring

⚙️ Environment Configuration

  • Sets default UI base URL to port 8001 via environment configuration
  • Removes implicit assumptions between frontend, API, and test environments

Why This Matters

The issue was not failing logic, but incoherent system boundaries.

Multiple app instantiation paths, inconsistent route registration, and implicit test data assumptions produced failures that looked chaotic but were actually structural.

This PR does not merely “fix tests” — it:

  • Re-establishes a single source of truth for app construction
  • Locks in API contracts
  • Makes test results reliable signals again
  • Future-proofs CI against routing, prefix, and environment drift

Status

  • 🧪 Tests: PASS (6/6 suites, 10/10 tests)
  • 🧭 Routing: Canonical
  • 🧬 API contracts: Stable
  • 🌱 System: Ready for versioning and documentation

Initializes the Express application with essential middleware for CORS, session management, and Passport authentication.

Sets up database connection and schema bootstrapping, including optional seeding for development environments.
Also configures OpenAPI validation and route registration for health, admin, lab notes, and OpenAPI specifications.

The changes include an environment variable update to set the default UI base URL to port 8001.
@AdaInTheLab AdaInTheLab merged commit a50700d into main Dec 30, 2025
1 check passed
@AdaInTheLab AdaInTheLab deleted the fix/api-tests-unhaunted branch December 30, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants