Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

test(frontend): pin email rate limit window (#15636)

Anshaj Kumar1fca29152256
diff --git a/autogpt_platform/frontend/src/lib/auth/__tests__/email-verification-flow.test.ts b/autogpt_platform/frontend/src/lib/auth/__tests__/email-verification-flow.test.ts
index 2afb52bddf..ff8bb5f5f6 100644
--- a/autogpt_platform/frontend/src/lib/auth/__tests__/email-verification-flow.test.ts
+++ b/autogpt_platform/frontend/src/lib/auth/__tests__/email-verification-flow.test.ts
@@ -114,6 +114,11 @@ function expireCooldowns(db: TestDB) {
}
}
+function pinRateLimitWindow() {
+ vi.useFakeTimers({ toFake: ["Date"] });
+ vi.setSystemTime(new Date("2026-01-01T00:05:00.000Z"));
+}
+
// A send can queue another (the repeat sign-up's reset email), so drain until
// nothing is left.
async function emailsSent() {
@@ -214,6 +219,7 @@ beforeEach(() => {
});
afterEach(() => {
+ vi.useRealTimers();
vi.unstubAllEnvs();
});
@@ -725,6 +731,7 @@ describe("with AUTH_REQUIRE_EMAIL_VERIFICATION=true", () => {
});
it("lets one IP have only a few addresses emailed through the sign-up page", async () => {
+ pinRateLimitWindow();
const { api } = await createAuthHandler(true);
// The page's server action calls auth.api, which Better Auth's own per-IP
@@ -763,6 +770,7 @@ describe("with AUTH_REQUIRE_EMAIL_VERIFICATION=true", () => {
});
it("counts the resend button against the same per-IP cap", async () => {
+ pinRateLimitWindow();
const { handler } = await createAuthHandler(true);
await signUp(handler, "[email protected]");