Files
copilotkit__copilotkit/showcase/scripts/__tests__/deploy-to-railway.healthcheck.test.ts
Jordan Ritter 59e18693eb feat(showcase): honest promote-notify message + durable healthcheckPath SSOT tracking
Promote-notify Slack message: name the promoted AND failed services (one
Failed: header + bullets), legible "(N): <names>" count, real wall-clock
elapsed (integer-coerced), and drop the constant verify-prod legend line.

Durable healthcheckPath: track it per-service/env in the SSOT (railway-envs),
re-assert it on the promote pin path (omit-when-absent, never null), and route
deploy-to-railway provisioning through isTrackedService/resolveProvisionHealthcheck
so a tracked-null service omits the healthcheck while an untracked one keeps the
/api/health default — fixing the silent prod-healthcheck drift that refused aimock.

Tests: ruby pin-reassert spec + deploy-to-railway healthcheck spec + emit/golden/accessor.
2026-06-23 16:56:16 -07:00

68 lines
2.7 KiB
TypeScript

/**
* Tests for healthcheck-path resolution during provisioning in
* `deploy-to-railway.ts` (`resolveProvisionHealthcheck`).
*
* Contract under test: `healthcheckPathFor` returns undefined for TWO distinct
* reasons, and conflating them wedges deploys:
*
* 1. The service is NOT tracked in the SSOT at all (brand-new/unknown
* service this script is onboarding) → fall back to the agent-class
* default `/api/health`.
* 2. The service IS tracked but deliberately has a null/omitted
* healthcheckPath (dashboard, docs, dojo, webhooks, pocketbase) → it has
* no HTTP health endpoint, so the healthcheck MUST be omitted. Forcing
* `/api/health` onto it yields a 404 that wedges the deploy (the bug this
* test guards against).
*
* Pure SSOT lookups — no network I/O, no aimock (no LLM surface here).
*/
import { describe, it, expect } from "vitest";
import { resolveProvisionHealthcheck } from "../deploy-to-railway";
describe("resolveProvisionHealthcheck", () => {
it("OMITS the healthcheck for a TRACKED service with a null healthcheckPath (docs)", () => {
// RED before fix: `healthcheckPathFor("docs") ?? "/api/health"` wrongly
// returned "/api/health" for this tracked-null service.
expect(resolveProvisionHealthcheck("docs")).toEqual({ kind: "omit" });
});
it("OMITS the healthcheck for other tracked-null services (dashboard, dojo, webhooks, pocketbase)", () => {
for (const svc of ["dashboard", "dojo", "webhooks", "pocketbase"]) {
expect(resolveProvisionHealthcheck(svc)).toEqual({ kind: "omit" });
}
});
it("SETS the SSOT healthcheckPath verbatim for a tracked service that defines one (aimock → /health)", () => {
expect(resolveProvisionHealthcheck("aimock")).toEqual({
kind: "set",
path: "/health",
});
});
it("SETS /api/health for a tracked agent service (showcase-langgraph-python)", () => {
expect(resolveProvisionHealthcheck("showcase-langgraph-python")).toEqual({
kind: "set",
path: "/api/health",
});
});
it("FALLS BACK to /api/health for an UNTRACKED brand-new service", () => {
expect(resolveProvisionHealthcheck("totally-new-unknown-service")).toEqual({
kind: "set",
path: "/api/health",
});
});
it("does NOT treat inherited Object.prototype keys as tracked services", () => {
// Own-property semantics: "constructor"/"toString" are not SSOT members,
// so they take the untracked fallback rather than resolving to a prototype.
for (const key of ["constructor", "toString", "hasOwnProperty"]) {
expect(resolveProvisionHealthcheck(key)).toEqual({
kind: "set",
path: "/api/health",
});
}
});
});