Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/modules/auth/login-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export default function Login({
<div className="flex flex-col gap-2">
{isGoogleLoginEnabled && (
<Button
className="w-full"
className="w-full py-1"
disabled={formState.isSubmitting}
data-testid="google"
onClick={async (e) => {
Expand All @@ -236,7 +236,7 @@ export default function Login({
{isOutlookLoginEnabled && (
<Button
variant="outline"
className="w-full"
className="w-full py-1"
data-testid="microsoft"
onClick={async (e) => {
e.preventDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ vi.mock("@calcom/features/notifications/sendNotification", () => ({
sendNotification: vi.fn(),
}));

vi.mock("@calcom/app-store/feishucalendar/lib/CalendarService", () => ({
default: class MockFeishuCalendarService {},
}));

vi.mock("@calcom/features/conferencing/lib/videoClient", () => ({
createInstantMeetingWithCalVideo: vi.fn().mockResolvedValue({
type: "daily_video",
Expand Down
17 changes: 17 additions & 0 deletions packages/lib/checkRateLimitAndThrowError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,21 @@ describe("checkRateLimitAndThrowError", () => {

await expect(checkRateLimitAndThrowError({ rateLimitingType, identifier })).resolves.not.toThrow();
});
it("should not return negative wait time when reset is in the past", async () => {
vi.mocked(rateLimiter).mockReturnValue(() => {
return {
limit: 10,
remaining: -1,
reset: Date.now() - 5000, // past time
success: false,
} as RatelimitResponse;
});

const identifier = "test-identifier";
const rateLimitingType = "core";

await expect(
checkRateLimitAndThrowError({ rateLimitingType, identifier })
).rejects.toThrow("0 seconds");
});
});
2 changes: 1 addition & 1 deletion packages/lib/checkRateLimitAndThrowError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export async function checkRateLimitAndThrowError({
const { success, reset } = response;
if (!success) {
const convertToSeconds = (ms: number) => Math.floor(ms / 1000);
const secondsToWait = convertToSeconds(reset - Date.now());
const secondsToWait = Math.max(0, convertToSeconds(reset - Date.now()));
throw new HttpError({
statusCode: 429,
message: `Rate limit exceeded. Try again in ${secondsToWait} seconds.`,
Expand Down
Loading