Skip to content

test(frontend): add vitest unit tests for the /api/health route handler#88

Open
Moonwalker-rgb wants to merge 1 commit into
VertexChainLabs:mainfrom
Moonwalker-rgb:test/frontend-health-route
Open

test(frontend): add vitest unit tests for the /api/health route handler#88
Moonwalker-rgb wants to merge 1 commit into
VertexChainLabs:mainfrom
Moonwalker-rgb:test/frontend-health-route

Conversation

@Moonwalker-rgb

Copy link
Copy Markdown
Contributor

Summary

Adds vitest unit tests for `Frontend/src/app/api/health/route.ts` as a follow-up to PR #87.

The /api/health endpoint is consumed by the Docker HEALTHCHECK directive in `docker/frontend.Dockerfile`, so these tests pin down the contract that the liveness probe depends on. They cover:

  1. GET() returns status 200
  2. GET() returns Content-Type: application/json
  3. JSON body has status: "ok" plus a strict ISO 8601 UTC timestamp
  4. Module-level dynamic = "force-dynamic" is exported (so the route is never pre-rendered into static output)

Validation performed locally

  • `npx vitest run` -> 9 test files, 48 tests pass (was 44; +4 new)
  • `npx vitest run --coverage` -> src/app/api/health/route.ts at 100% statements/branches/functions/lines; project overall coverage stays well above the 70% thresholds in vitest.config.ts
  • `npx tsc --noEmit` -> clean

Refs #87

Follow-up to PR VertexChainLabs#87 (docker: add multi-stage frontend Dockerfile with Next.js standalone output) to ensure the App Router liveness endpoint matches the Docker HEALTHCHECK expectations in docker/frontend.Dockerfile.

- Assert GET returns status 200 and application/json content type

- Assert the JSON body has status: ok plus an ISO 8601 UTC timestamp

- Assert module-level dynamic = force-dynamic export so Next.js does not pre-render the route

Refs VertexChainLabs#87
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.

1 participant