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 | /**
* Regression coverage for the Insights tab.
*
* The repo-nav "Insights" tab links to /:owner/:repo/insights, but NOTHING
* served that path — it 404'd on every repo (found by pressing every nav tab
* on the real logged-in session, not by a curl status sweep, which had
* mis-triaged the 404 as "expected"). A hub page now serves it.
*
* The hub route is greedy (`/:owner/:repo/insights` matches `/orgs/:slug/insights`
* with owner="orgs"), so it MUST be mounted after org-insights or it shadows
* it. These tests lock both invariants.
*/
import { describe, it, expect } from "bun:test";
import app from "../app";
describe("insights hub", () => {
it("route is registered + gated: unknown repo → 404 (not a fall-through)", async () => {
const res = await app.request("/nobody-xyz/nothing-xyz/insights");
expect(res.status).toBe(404);
});
it("does NOT shadow /orgs/:slug/insights — that still routes to org-insights (302 login)", async () => {
const res = await app.request("/orgs/some-slug/insights");
expect(res.status).toBe(302);
expect(res.headers.get("location") || "").toContain("/login");
});
});
|