integratedhub/tests/e2e/auth/logout.spec.ts
2026-02-14 02:20:19 +00:00

27 lines
976 B
TypeScript

import { expect, test } from "@playwright/test";
import { getSetCookies } from "../helpers/auth-assertions.ts";
test.describe("Logout Route", () => {
test("GET /auth/logout always redirects home and clears cookies", async ({ request }) => {
const response = await request.get("/auth/logout", { maxRedirects: 0 });
expect(response.status()).toBe(302);
expect(response.headers()["location"]).toBe("/");
const cookies = getSetCookies(response).join("\n");
expect(cookies).toContain("session=");
expect(cookies).toContain("xx_state_id=");
});
test("POST /auth/logout matches GET behavior", async ({ request }) => {
const response = await request.post("/auth/logout", { maxRedirects: 0 });
expect(response.status()).toBe(302);
expect(response.headers()["location"]).toBe("/");
const cookies = getSetCookies(response).join("\n");
expect(cookies).toContain("session=");
expect(cookies).toContain("xx_state_id=");
});
});