Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+43
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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 200 `{ ok: true }` 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 "./auth.password-policy-remind";
|
||||
|
||||
describe("auth.password-policy-remind", () => {
|
||||
it("returns ok:true and a Set-Cookie that places the snooze in the future", async () => {
|
||||
const req = new Request("https://app.example.com/auth/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(200);
|
||||
await expect(response.json()).resolves.toEqual({ ok: true });
|
||||
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