Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Phase 01 / #27 — resource-route test for the password-policy "Remind me
|
||||
* in 7 days" cookie roundtrip.
|
||||
*
|
||||
* The handler must:
|
||||
* - require an authenticated session
|
||||
* - return 204 with a Set-Cookie header that the banner-decision helper
|
||||
* can parse back into a future timestamp
|
||||
* - reject GET requests with 405
|
||||
*/
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("~/utils/session.server", () => ({
|
||||
requireUserId: vi.fn().mockResolvedValue("u1"),
|
||||
}));
|
||||
|
||||
import {
|
||||
PASSWORD_POLICY_REMIND_COOKIE,
|
||||
readRemindAfterCookie,
|
||||
} from "~/services/auth/password-policy-banner.server";
|
||||
import { action, loader } from "./api.password-policy-remind";
|
||||
|
||||
describe("api.password-policy-remind", () => {
|
||||
it("returns 204 and a Set-Cookie that places the snooze in the future", async () => {
|
||||
const req = new Request("https://app.example.com/api/password-policy-remind", { method: "POST" });
|
||||
const before = Date.now();
|
||||
const response = (await action({ request: req, params: {}, context: {} } as Parameters<typeof action>[0])) as Response;
|
||||
expect(response.status).toBe(204);
|
||||
const setCookie = response.headers.get("Set-Cookie");
|
||||
expect(setCookie).toBeTruthy();
|
||||
expect(setCookie).toContain(PASSWORD_POLICY_REMIND_COOKIE);
|
||||
const parsed = readRemindAfterCookie(setCookie!.split(";")[0]);
|
||||
expect(parsed).toBeDefined();
|
||||
expect(parsed!).toBeGreaterThan(before);
|
||||
});
|
||||
|
||||
it("rejects GET requests with 405", async () => {
|
||||
const response = loader() as Response;
|
||||
expect(response.status).toBe(405);
|
||||
expect(response.headers.get("Allow")).toBe("POST");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user