CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | /**
* /admin/diagnose, /admin/diagnose.json, /admin/health smoke tests.
*
* Verifies:
* - All three endpoints respond (302 for anon, JSON for /diagnose.json
* when authed admin).
* - The JSON endpoint returns the expected shape (`{ok, overall,
* counts, checks, asOf}`).
* - /admin/health redirects to /admin/diagnose.
*
* Added 2026-05-16 as part of the reliability sweep (Level 2 — Self-
* monitoring). New checks (autopilot, recent deploy, workflow queue,
* crontech webhook) are exercised by the JSON endpoint.
*/
import { describe, it, expect } from "bun:test";
import app from "../app";
describe("admin diagnose / health", () => {
it("GET /admin/health redirects to /admin/diagnose", async () => {
const res = await app.request("/admin/health", { redirect: "manual" });
expect(res.status).toBe(302);
expect(res.headers.get("location") || "").toBe("/admin/diagnose");
});
it("GET /admin/diagnose without auth redirects to /login", async () => {
const res = await app.request("/admin/diagnose", { redirect: "manual" });
expect([302, 303]).toContain(res.status);
const loc = res.headers.get("location") || "";
expect(loc).toContain("/login");
});
it("GET /admin/diagnose.json without auth returns 401/403/302", async () => {
const res = await app.request("/admin/diagnose.json", {
redirect: "manual",
});
// The handler uses the same gate() as the HTML route. For anonymous
// users the gate returns a 302 redirect (not JSON), which is fine —
// it still indicates the endpoint exists and is properly gated.
expect([302, 401, 403]).toContain(res.status);
});
});
|