|
1 | 1 | import { describe, expect, test } from "bun:test"; |
2 | | -import { deriveStartupHealth, startupHealthSummary } from "../src/codex/autostart-health"; |
| 2 | +import { deriveStartupHealth, formatStartupRoutingDetail, startupHealthSummary } from "../src/codex/autostart-health"; |
| 3 | +import { unusedProxyWarningLines } from "../src/cli/status"; |
3 | 4 | import { classifyCodexRouting, hasInjectedCodexRouting } from "../src/codex/inject"; |
4 | 5 | import { handleManagementAPI } from "../src/server/management-api"; |
5 | 6 | import { invalidateStartupHealthCache, markStartupHealthDiagnosticStale } from "../src/server/startup-health-cache"; |
@@ -231,3 +232,36 @@ describe("Codex startup health", () => { |
231 | 232 | }, 40_000); |
232 | 233 | }); |
233 | 234 | import { ManagementRequest as Request } from "./helpers/management-auth"; |
| 235 | + |
| 236 | +describe("routing visibility (#2411)", () => { |
| 237 | + test("formatStartupRoutingDetail renders the token doctor already prints", () => { |
| 238 | + expect(formatStartupRoutingDetail(deriveStartupHealth({ ...base, routingKind: "native" }))) |
| 239 | + .toBe("routing=native, service=absent, shim=absent"); |
| 240 | + expect(formatStartupRoutingDetail(deriveStartupHealth({ |
| 241 | + ...base, |
| 242 | + serviceInstalled: true, |
| 243 | + serviceViable: true, |
| 244 | + shimInstalled: true, |
| 245 | + shimHealthy: true, |
| 246 | + }))).toBe("routing=opencodex-local, service=viable, shim=healthy"); |
| 247 | + expect(formatStartupRoutingDetail(deriveStartupHealth({ ...base, serviceInstalled: true }))) |
| 248 | + .toBe("routing=opencodex-local, service=installed-but-unhealthy, shim=absent"); |
| 249 | + expect(formatStartupRoutingDetail(deriveStartupHealth({ ...base, shimInstalled: true }))) |
| 250 | + .toBe("routing=opencodex-local, service=absent, shim=stale"); |
| 251 | + }); |
| 252 | + |
| 253 | + // A healthy proxy paired with native routing is the state #2411 reports: the |
| 254 | + // process answers /healthz truthfully while no Codex request reaches it. |
| 255 | + // custom-local and unknown stay silent on purpose — startupHealthSummary |
| 256 | + // already renders both as AT RISK with a remedy, so a second warning would |
| 257 | + // train operators to ignore this one. |
| 258 | + test("unusedProxyWarningLines fires only for a live proxy on native routing", () => { |
| 259 | + expect(unusedProxyWarningLines({ proxyUp: true, routingKind: "native" }).length).toBeGreaterThan(0); |
| 260 | + expect(unusedProxyWarningLines({ proxyUp: true, routingKind: "native" }).join(" ")).toContain("unused"); |
| 261 | + expect(unusedProxyWarningLines({ proxyUp: false, routingKind: "native" })).toEqual([]); |
| 262 | + expect(unusedProxyWarningLines({ proxyUp: true, routingKind: "opencodex-local" })).toEqual([]); |
| 263 | + expect(unusedProxyWarningLines({ proxyUp: true, routingKind: "custom-remote" })).toEqual([]); |
| 264 | + expect(unusedProxyWarningLines({ proxyUp: true, routingKind: "custom-local" })).toEqual([]); |
| 265 | + expect(unusedProxyWarningLines({ proxyUp: true, routingKind: "unknown" })).toEqual([]); |
| 266 | + }); |
| 267 | +}); |
0 commit comments