Skip to content

Conversation

@keithwillcode
Copy link
Contributor

What does this PR do?

Fixes flaky E2E tests in booking-duplicate-api-calls.e2e.ts that were failing on December 31 due to month boundary issues.

The tests were using new Date() and then setting the day to 5 or 20, which caused issues when the prefetch logic in isMonthViewPrefetchEnabled evaluated the current date against month boundaries. On certain dates (like end of month/year), this could trigger additional API calls, causing the tests to fail with "Expected <= 1, Received 2".

This PR introduces a getStableTestDate() helper function that returns a fixed future date (July 2030) to ensure consistent test behavior regardless of when the tests are run.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - test-only change.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Run the E2E tests: PLAYWRIGHT_HEADLESS=1 yarn e2e booking-duplicate-api-calls.e2e.ts
  2. All 6 tests should pass regardless of the current date

Human Review Checklist

  • Verify that using a fixed future date (July 2030) doesn't change the fundamental behavior being tested
  • Confirm the hypothesis that month boundary prefetch logic was causing the extra API calls
  • Consider if there's a more robust approach (e.g., more comprehensive date mocking)

Note: Local testing was blocked by environment issues (Internal Server Error), so this fix is based on code analysis of the prefetch logic in isMonthViewPrefetchEnabled.ts. CI will verify the fix.


Link to Devin run: https://app.devin.ai/sessions/b1ce96e74aa14104aa9eb14f5e3449f6
Requested by: keith@cal.com (@keithwillcode)

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: keith@cal.com <keithwillcode@gmail.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@anikdhabal anikdhabal marked this pull request as ready for review December 31, 2025 16:04
@graphite-app graphite-app bot added foundation core area: core, team members only labels Dec 31, 2025
@graphite-app graphite-app bot requested a review from a team December 31, 2025 16:04
@volnei volnei enabled auto-merge (squash) December 31, 2025 16:04
@volnei volnei merged commit 59ba175 into main Dec 31, 2025
71 of 72 checks passed
@volnei volnei deleted the devin/1767195713-fix-duplicate-api-calls-test branch December 31, 2025 16:05
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants