[CAL-4531] Take into account guest's availability when resch...#28074
[CAL-4531] Take into account guest's availability when resch...#28074SolariSystems wants to merge 3 commits intocalcom:mainfrom
Conversation
|
|
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
Graphite Automations"Send notification to Community team when bounty PR opened" took an action on this PR • (02/19/26)2 teammates were notified to this PR based on Keith Williams's automation. |
There was a problem hiding this comment.
5 issues found across 14 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/web/lib/pages/auth/verify-email.ts">
<violation number="1" location="apps/web/lib/pages/auth/verify-email.ts:43">
P1: Test `it(...)` block was inserted into production runtime code, causing a ReferenceError (and recursive call) whenever `moveUserToMatchingOrg` runs.</violation>
</file>
<file name="apps/web/pages/reschedule/[uid].tsx">
<violation number="1" location="apps/web/pages/reschedule/[uid].tsx:10">
P2: pages/reschedule/[uid].tsx does not default export a React component. Next.js requires a default export for every file under pages/, so this route will fail to build or render.</violation>
</file>
<file name="packages/trpc/server/routers/viewer/slots/getSchedule.handler.test.ts">
<violation number="1" location="packages/trpc/server/routers/viewer/slots/getSchedule.handler.test.ts:17">
P3: Test is flaky because expected Date objects are created separately from the mocked response; millisecond differences will make toEqual fail.</violation>
</file>
<file name="packages/platform/constants/api.ts">
<violation number="1" location="packages/platform/constants/api.ts:4">
P2: The availability endpoint constant was changed to "availability", but server routes still expose schedules under /v2/schedules and client hooks build paths from this constant. This will make availability requests hit /availability instead of /schedules, causing 404s unless the server routes were updated in tandem.</violation>
</file>
<file name="packages/trpc/server/routers/viewer/slots/getSchedule.handler.ts">
<violation number="1" location="packages/trpc/server/routers/viewer/slots/getSchedule.handler.ts:16">
P2: Access-denied branch throws a generic Error instead of a TRPCError with UNAUTHORIZED, which will surface as INTERNAL_SERVER_ERROR/500 and inconsistent error shape for tRPC clients.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| }); | ||
|
|
||
| // Add test case for moveUserToMatchingOrg | ||
| it("should move user to matching organization", async () => { |
There was a problem hiding this comment.
P1: Test it(...) block was inserted into production runtime code, causing a ReferenceError (and recursive call) whenever moveUserToMatchingOrg runs.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/lib/pages/auth/verify-email.ts, line 43:
<comment>Test `it(...)` block was inserted into production runtime code, causing a ReferenceError (and recursive call) whenever `moveUserToMatchingOrg` runs.</comment>
<file context>
@@ -38,6 +38,13 @@ export async function moveUserToMatchingOrg({ email }: { email: string }) {
});
+
+ // Add test case for moveUserToMatchingOrg
+ it("should move user to matching organization", async () => {
+ const mockEmail = "test@example.com";
+ await moveUserToMatchingOrg({ email: mockEmail });
</file context>
| @@ -0,0 +1,13 @@ | |||
| import User from "@prisma/client"; // Add this line | |||
There was a problem hiding this comment.
P2: pages/reschedule/[uid].tsx does not default export a React component. Next.js requires a default export for every file under pages/, so this route will fail to build or render.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/web/pages/reschedule/[uid].tsx, line 10:
<comment>pages/reschedule/[uid].tsx does not default export a React component. Next.js requires a default export for every file under pages/, so this route will fail to build or render.</comment>
<file context>
@@ -0,0 +1,13 @@
+
+import type { GetScheduleOptions } from "./types";
+
+export const getScheduleHandler = async ({ ctx, input }: GetScheduleOptions) => {
+ const availableSlotsService = getAvailableSlotsService();
+ return await availableSlotsService.getAvailableSlots({ ctx, input });
</file context>
| export const V2_ENDPOINTS = { | ||
| me: "me", | ||
| availability: "schedules", | ||
| availability: "availability", |
There was a problem hiding this comment.
P2: The availability endpoint constant was changed to "availability", but server routes still expose schedules under /v2/schedules and client hooks build paths from this constant. This will make availability requests hit /availability instead of /schedules, causing 404s unless the server routes were updated in tandem.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/platform/constants/api.ts, line 4:
<comment>The availability endpoint constant was changed to "availability", but server routes still expose schedules under /v2/schedules and client hooks build paths from this constant. This will make availability requests hit /availability instead of /schedules, causing 404s unless the server routes were updated in tandem.</comment>
<file context>
@@ -1,9 +1,10 @@
export const V2_ENDPOINTS = {
me: "me",
- availability: "schedules",
+ availability: "availability",
eventTypes: "event-types",
bookings: "bookings",
</file context>
| availability: "availability", | |
| availability: "schedules", |
| if (user && user.type === "USER") { | ||
| return await availableSlotsService.getAvailableSlots({ ctx, input }); | ||
| } else { | ||
| throw new Error("Attendee is not a Cal.com user"); |
There was a problem hiding this comment.
P2: Access-denied branch throws a generic Error instead of a TRPCError with UNAUTHORIZED, which will surface as INTERNAL_SERVER_ERROR/500 and inconsistent error shape for tRPC clients.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/slots/getSchedule.handler.ts, line 16:
<comment>Access-denied branch throws a generic Error instead of a TRPCError with UNAUTHORIZED, which will surface as INTERNAL_SERVER_ERROR/500 and inconsistent error shape for tRPC clients.</comment>
<file context>
@@ -1,8 +1,18 @@
+ if (user && user.type === "USER") {
+ return await availableSlotsService.getAvailableSlots({ ctx, input });
+ } else {
+ throw new Error("Attendee is not a Cal.com user");
+ }
};
</file context>
|
|
||
| const mockAvailableSlotsService = { | ||
| getAvailableSlots: jest.fn().mockResolvedValue([ | ||
| { start: new Date(), end: new Date(new Date().getTime() + 60 * 60 * 1000) }, |
There was a problem hiding this comment.
P3: Test is flaky because expected Date objects are created separately from the mocked response; millisecond differences will make toEqual fail.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/trpc/server/routers/viewer/slots/getSchedule.handler.test.ts, line 17:
<comment>Test is flaky because expected Date objects are created separately from the mocked response; millisecond differences will make toEqual fail.</comment>
<file context>
@@ -0,0 +1,54 @@
+
+ const mockAvailableSlotsService = {
+ getAvailableSlots: jest.fn().mockResolvedValue([
+ { start: new Date(), end: new Date(new Date().getTime() + 60 * 60 * 1000) },
+ ]),
+ };
</file context>
Summary
[CAL-4531] Take into account guest's availability when rescheduling.
Testing
Note: Some tests may need attention. See CI results.
/claim #16378
Resolves: #16378