fix: use stable test dates in duplicate API calls E2E tests (#26349)
The tests were failing on December 31 because they used new Date() which caused month boundary issues with the prefetch logic. This change uses a fixed future date (July 2030) to ensure consistent test behavior regardless of when the tests are run. Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI
parent
16f6099e46
commit
59ba1754fe
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user