-
Notifications
You must be signed in to change notification settings - Fork 11.7k
test: add E2E test to verify no RSC prefetch on team page load #27263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
emrysal
wants to merge
8
commits into
main
Choose a base branch
from
devin/1769464095-team-page-prefetch-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+104
−0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
59b4379
fix: disable prefetch on team page event type links to prevent Google…
devin-ai-integration[bot] b68802f
test: add E2E test to verify no getSchedule calls on team page load
devin-ai-integration[bot] 56ce358
test: check for RSC prefetch requests instead of getSchedule calls
devin-ai-integration[bot] c6db00b
test: update to check RSC prefetch requests on hover
devin-ai-integration[bot] 77e398e
Merge branch 'main' into devin/1769464095-team-page-prefetch-test
emrysal 32cb126
test: change to check RSC prefetch on page load instead of hover
devin-ai-integration[bot] 486b9b5
fix: narrow test to only check event type prefetch requests
devin-ai-integration[bot] 9a52852
fix: add URL assertion after navigation per E2E best practices
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import { expect } from "@playwright/test"; | ||
| import type { Page } from "@playwright/test"; | ||
|
|
||
| import { SchedulingType } from "@calcom/prisma/enums"; | ||
|
|
||
| import { test } from "./lib/fixtures"; | ||
|
|
||
| /** | ||
| * Tests that the team page does not prefetch event type pages on page load. | ||
| * In production, Next.js prefetches links when they enter the viewport. | ||
| * When prefetch={false} is NOT set, page load triggers RSC requests | ||
| * with `_rsc` query parameter, which causes server-side rendering and API calls | ||
| * (like Google Calendar), causing rate limits for teams with many event types. | ||
| */ | ||
|
|
||
| async function countEventTypePrefetchRequests( | ||
| page: Page, | ||
| url: string, | ||
| teamSlug: string | ||
| ): Promise<{ eventTypePrefetchCalls: string[] }> { | ||
| const eventTypePrefetchCalls: string[] = []; | ||
|
|
||
| await page.route("**/*", async (route) => { | ||
| const requestUrl = route.request().url(); | ||
| // Check if this is an RSC prefetch request for a team event type page | ||
| // Event type URLs follow pattern: /team/{teamSlug}/{eventTypeSlug} | ||
| if (requestUrl.includes("_rsc=") && !requestUrl.includes("/api/")) { | ||
| const urlPath = new URL(requestUrl).pathname; | ||
| // Only match event type URLs: /team/{teamSlug}/{eventTypeSlug} | ||
| // This regex ensures we have exactly: /team/slug/eventSlug (3 segments after splitting) | ||
| const teamEventTypePattern = new RegExp(`^/team/${teamSlug}/[^/]+$`); | ||
| if (teamEventTypePattern.test(urlPath)) { | ||
| eventTypePrefetchCalls.push(requestUrl); | ||
| } | ||
| } | ||
| await route.continue(); | ||
| }); | ||
|
|
||
| await page.goto(url); | ||
| await page.waitForLoadState("networkidle"); | ||
|
|
||
| // Assert URL to fail fast on unexpected redirects | ||
| await expect(page).toHaveURL(url); | ||
|
|
||
| // Wait for page to fully load and any prefetch requests to complete | ||
| await page.waitForTimeout(3000); | ||
|
|
||
| return { eventTypePrefetchCalls }; | ||
| } | ||
|
|
||
| test.describe("Team Page No Prefetch", () => { | ||
| test.afterEach(({ users }) => users.deleteAll()); | ||
|
|
||
| test("should not prefetch event type pages on page load", async ({ page, users }) => { | ||
| const teamOwner = await users.create( | ||
| { name: "Team Owner" }, | ||
| { | ||
| hasTeam: true, | ||
| teammates: [{ name: "teammate-1" }, { name: "teammate-2" }], | ||
| schedulingType: SchedulingType.COLLECTIVE, | ||
| } | ||
| ); | ||
|
|
||
| const { team } = await teamOwner.getFirstTeamMembership(); | ||
|
|
||
| const { eventTypePrefetchCalls } = await countEventTypePrefetchRequests( | ||
| page, | ||
| `/team/${team.slug}`, | ||
| team.slug | ||
| ); | ||
|
|
||
| // With prefetch={false}, no RSC prefetch requests should be made for event type pages | ||
| expect(eventTypePrefetchCalls.length).toBe(0); | ||
| }); | ||
|
|
||
| test("should not prefetch event type pages on page load with many event types", async ({ | ||
| page, | ||
| users, | ||
| }) => { | ||
| const teamOwner = await users.create( | ||
| { name: "Team Owner" }, | ||
| { | ||
| hasTeam: true, | ||
| teammates: [ | ||
| { name: "teammate-1" }, | ||
| { name: "teammate-2" }, | ||
| { name: "teammate-3" }, | ||
| { name: "teammate-4" }, | ||
| ], | ||
| schedulingType: SchedulingType.ROUND_ROBIN, | ||
| } | ||
| ); | ||
|
|
||
| const { team } = await teamOwner.getFirstTeamMembership(); | ||
|
|
||
| const { eventTypePrefetchCalls } = await countEventTypePrefetchRequests( | ||
| page, | ||
| `/team/${team.slug}`, | ||
| team.slug | ||
| ); | ||
|
|
||
| expect(eventTypePrefetchCalls.length).toBe(0); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.