Scheduling infrastructure for absolutely everyone.
fix: use stable test dates in duplicate API calls E2E tests (#26349)
Keith Williams59ba1754fe0d
diff --git a/apps/web/playwright/booking-duplicate-api-calls.e2e.ts b/apps/web/playwright/booking-duplicate-api-calls.e2e.tsindex 41ce78aa489..4003f5bcb7b 100644--- a/apps/web/playwright/booking-duplicate-api-calls.e2e.ts+++ b/apps/web/playwright/booking-duplicate-api-calls.e2e.ts@@ -36,6 +36,18 @@ async function testDuplicateAPICalls(};}+/**+ * Creates a stable test date that avoids month boundary issues.+ * Uses a fixed date in the middle of a month to ensure consistent behavior+ * regardless of when the test is run.+ * @param dayOfMonth - The day of the month to use (5 for beginning, 20 for end)+ */+function getStableTestDate(dayOfMonth: number): Date {+ // Use a fixed future date to avoid any issues with past dates or month boundaries+ // July 2030 is chosen as it's far in the future and has no special calendar quirks+ return new Date(2030, 6, dayOfMonth, 12, 0, 0);+}+test.describe("Duplicate API Calls Prevention", () => {test.afterEach(({ users }) => users.deleteAll());@@ -45,8 +57,7 @@ test.describe("Duplicate API Calls Prevention", () => {}) => {const user = await users.create();const eventType = user.eventTypes.find((e) => e.slug === "30-min");- const beginningOfMonth = new Date();- beginningOfMonth.setDate(5);+ const beginningOfMonth = getStableTestDate(5);const { totalCalls, trpcCalls, apiV2Calls } = await testDuplicateAPICalls(page,@@ -66,8 +77,7 @@ test.describe("Duplicate API Calls Prevention", () => {}) => {const user = await users.create();const eventType = user.eventTypes.find((e) => e.slug === "30-min");- const endOfMonth = new Date();- endOfMonth.setDate(20);+ const endOfMonth = getStableTestDate(20);const { totalCalls, trpcCalls, apiV2Calls } = await testDuplicateAPICalls(page,@@ -92,8 +102,7 @@ test.describe("Duplicate API Calls Prevention", () => {teammates: [{ name: "teammate-1" }],});- const beginningOfMonth = new Date();- beginningOfMonth.setDate(5);+ const beginningOfMonth = getStableTestDate(5);const { team } = await teamOwner.getFirstTeamMembership();const teamEvent = await createTeamEventType(@@ -132,8 +141,7 @@ test.describe("Duplicate API Calls Prevention", () => {{ id: team.id },{ teamEventSlug: "team-event-test", teamEventTitle: "Team Event Test" });- const endOfMonth = new Date();- endOfMonth.setDate(20);+ const endOfMonth = getStableTestDate(20);const { totalCalls, trpcCalls, apiV2Calls } = await testDuplicateAPICalls(page,@@ -169,8 +177,7 @@ test.describe("Duplicate API Calls Prevention", () => {{ id: team.id },{ teamEventSlug: "org-team-event", teamEventTitle: "Org Team Event" });- const beginningOfMonth = new Date();- beginningOfMonth.setDate(5);+ const beginningOfMonth = getStableTestDate(5);const { totalCalls, trpcCalls, apiV2Calls } = await testDuplicateAPICalls(page,@@ -206,8 +213,7 @@ test.describe("Duplicate API Calls Prevention", () => {{ id: team.id },{ teamEventSlug: "org-team-event", teamEventTitle: "Org Team Event" });- const endOfMonth = new Date();- endOfMonth.setDate(20);+ const endOfMonth = getStableTestDate(20);const { totalCalls, trpcCalls, apiV2Calls } = await testDuplicateAPICalls(page,