Blame · Line-by-line history
insights-hub.test.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 6a645f0 | 1 | /** |
| 2 | * Regression coverage for the Insights tab. | |
| 3 | * | |
| 4 | * The repo-nav "Insights" tab links to /:owner/:repo/insights, but NOTHING | |
| 5 | * served that path — it 404'd on every repo (found by pressing every nav tab | |
| 6 | * on the real logged-in session, not by a curl status sweep, which had | |
| 7 | * mis-triaged the 404 as "expected"). A hub page now serves it. | |
| 8 | * | |
| 9 | * The hub route is greedy (`/:owner/:repo/insights` matches `/orgs/:slug/insights` | |
| 10 | * with owner="orgs"), so it MUST be mounted after org-insights or it shadows | |
| 11 | * it. These tests lock both invariants. | |
| 12 | */ | |
| 13 | import { describe, it, expect } from "bun:test"; | |
| 14 | import app from "../app"; | |
| 15 | ||
| 16 | describe("insights hub", () => { | |
| 17 | it("route is registered + gated: unknown repo → 404 (not a fall-through)", async () => { | |
| 18 | const res = await app.request("/nobody-xyz/nothing-xyz/insights"); | |
| 19 | expect(res.status).toBe(404); | |
| 20 | }); | |
| 21 | ||
| 22 | it("does NOT shadow /orgs/:slug/insights — that still routes to org-insights (302 login)", async () => { | |
| 23 | const res = await app.request("/orgs/some-slug/insights"); | |
| 24 | expect(res.status).toBe(302); | |
| 25 | expect(res.headers.get("location") || "").toContain("/login"); | |
| 26 | }); | |
| 27 | }); |