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 | /**
* Smoke test for /migrations (migration history page).
*
* The page is auth-guarded via requireAuth. Without a session the middleware
* redirects to /login, which is the observable contract we can reliably
* assert in this sandbox (no real DB-backed session). When a valid session
* cookie is present the route returns 200 HTML; we cover that best-effort
* below and degrade to the redirect assertion when no DB is configured, so
* the test adds no regressions against the existing baseline.
*/
import { describe, it, expect } from "bun:test";
import app from "../app";
describe("migrations — GET /migrations", () => {
it("unauthenticated request redirects to /login (auth guard)", async () => {
const res = await app.request("/migrations");
expect(res.status).toBe(302);
expect(res.headers.get("location") || "").toContain("/login");
});
it("authenticated request returns 200 HTML (or redirect when DB missing)", async () => {
// App's requireAuth resolves a user via the `session` cookie. Without a
// real DB we can't materialize that session, so we assert a permissive
// contract: either we get the page (200 + HTML) or we get redirected to
// /login — never a 500.
const res = await app.request("/migrations", {
headers: { cookie: "session=smoketest-session-token" },
});
expect([200, 302]).toContain(res.status);
if (res.status === 200) {
const body = await res.text();
expect(body).toContain("<html");
expect(body.toLowerCase()).toContain("migration");
} else {
expect(res.headers.get("location") || "").toContain("/login");
}
});
});
|