-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
refactor: removed isNotAnApiCall #13568
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
6 Ignored Deployments
|
Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link. |
📦 Next.js Bundle Analysis for @calcom/webThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
Current Playwright Test Results Summary✅ 440 Passing - Run may still be in progress, this comment will be updated as current testing workflow or job completes... (Last updated on 02/06/2024 11:27:31pm UTC) Run DetailsRunning Workflow PR Update on Github Actions Commit: 074e7bb Started: 02/06/2024 11:18:42pm UTC
|
|
2 Test Cases Affected |
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
pro user -- future Time slots should be reserved when selected
Retry 1 • Initial Attempt |
0.76% (2)2 / 264 runsfailed over last 7 days |
5.68% (15)15 / 264 runsflaked over last 7 days |
pro user -- legacy Time slots should be reserved when selected
Retry 1 • Initial Attempt |
0% (0)0 / 258 runsfailed over last 7 days |
4.26% (11)11 / 258 runsflaked over last 7 days |
📄 apps/web/playwright/booking/longTextQuestion.e2e.ts • 4 Flakes
Top 1 Common Error Messages
|
4 Test Cases Affected |
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Booking With Long Text Question and Each Other Question Booking With Long Text Question and multiselect Question Long Text required and multiselect text not required
Retry 1 • Initial Attempt |
0% (0)0 / 300 runsfailed over last 7 days |
3% (9)9 / 300 runsflaked over last 7 days |
Booking With Long Text Question and Each Other Question Booking With Long Text Question and Number Question Long Text and Number required
Retry 1 • Initial Attempt |
0.33% (1)1 / 300 runfailed over last 7 days |
4.33% (13)13 / 300 runsflaked over last 7 days |
Booking With Long Text Question and Each Other Question Long Text required and Number not required
Retry 1 • Initial Attempt |
0% (0)0 / 300 runsfailed over last 7 days |
5% (15)15 / 300 runsflaked over last 7 days |
Booking With Long Text Question and Each Other Question Booking With Long Text Question and Short text question Long Text required and Short text not required
Retry 1 • Initial Attempt |
0% (0)0 / 294 runsfailed over last 7 days |
4.42% (13)13 / 294 runsflaked over last 7 days |
📄 apps/web/playwright/booking/selectQuestion.e2e.ts • 2 Flakes
Top 1 Common Error Messages
|
2 Test Cases Affected |
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Booking With Phone Question and Each Other Question Booking With Select Question and Multi email Question Select and Multi email not required
Retry 1 • Initial Attempt |
0.35% (1)1 / 283 runfailed over last 7 days |
2.83% (8)8 / 283 runsflaked over last 7 days |
Booking With Phone Question and Each Other Question Booking With Select Question and Number Question Select and Number not required
Retry 1 • Initial Attempt |
0% (0)0 / 282 runsfailed over last 7 days |
3.90% (11)11 / 282 runsflaked over last 7 days |
📄 apps/web/playwright/booking/responsiveBooking.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Booking page with no questions Booking page with 1920x1080 resolution
Retry 1 • Initial Attempt |
0.35% (1)1 / 289 runfailed over last 7 days |
3.46% (10)10 / 289 runsflaked over last 7 days |
📄 apps/web/playwright/organization/organization-invitation.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Organization Email matching orgAutoAcceptEmail and a Verified Organization Org Invitation
Retry 2 • Retry 1 • Initial Attempt |
12.70% (40)40 / 315 runsfailed over last 7 days |
6.98% (22)22 / 315 runsflaked over last 7 days |
📄 apps/web/playwright/booking/phoneQuestion.e2e.ts • 3 Flakes
Top 1 Common Error Messages
|
3 Test Cases Affected |
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Booking With Phone Question and Each Other Question Booking With Phone Question and Address Question Booking With Phone Question and Number Question Phone and Number required
Retry 1 • Initial Attempt |
0.65% (2)2 / 310 runsfailed over last 7 days |
6.13% (19)19 / 310 runsflaked over last 7 days |
Booking With Phone Question and Each Other Question Booking With Phone Question and Address Question Booking With Phone Question and Number Question Phone required and Number not required
Retry 1 • Initial Attempt |
0.32% (1)1 / 310 runfailed over last 7 days |
6.13% (19)19 / 310 runsflaked over last 7 days |
Booking With Phone Question and Each Other Question Booking With Phone Question and Address Question Booking With Phone Question and Short text question Phone required and Short text not required
Retry 1 • Initial Attempt |
0% (0)0 / 308 runsfailed over last 7 days |
6.82% (21)21 / 308 runsflaked over last 7 days |
📄 apps/web/playwright/event-types.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Event Types tests -- future user can add multiple organizer address
Retry 1 • Initial Attempt |
0.60% (2)2 / 335 runsfailed over last 7 days |
17.91% (60)60 / 335 runsflaked over last 7 days |
📄 packages/app-store/routing-forms/playwright/tests/basic.e2e.ts • 1 Flake
Test Case Results
Test Case | Last 7 days Failures | Last 7 days Flakes |
---|---|---|
Routing Forms Seeded Routing Form Router URL should work
Retry 2 • Retry 1 • Initial Attempt |
1.83% (6)6 / 327 runsfailed over last 7 days |
13.15% (43)43 / 327 runsflaked over last 7 days |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self review done
@@ -206,7 +207,7 @@ async function handler(req: NextApiRequest) { | |||
const { userId, isAdmin } = req; | |||
if (isAdmin) req.userId = req.body.userId || userId; | |||
|
|||
return await handleNewBooking(req); | |||
return await handleNewBooking(req, getBookingDataSchemaForApi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the API handler is the odd one out. It should only pass the desired schema instead of doing isNotAnApiCall: true
in all other calls.
eventType: event?.data, | ||
bookingFields: event.data.bookingFields, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just need bookingFields in here so there's no need to pass the whole eventType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great fix for Law of Demeter here 🙏🏼
: bookingCreateBodySchemaForApi | ||
.merge( | ||
z.object({ | ||
responses: responsesSchema.optional(), | ||
}) | ||
) | ||
.superRefine((val, ctx) => { | ||
if (val.responses && val.customInputs) { | ||
ctx.addIssue({ | ||
code: "custom", | ||
message: | ||
"Don't use both customInputs and responses. `customInputs` is only there for legacy support.", | ||
}); | ||
return; | ||
} | ||
const legacyProps = Object.keys(bookingCreateSchemaLegacyPropsForApi.shape); | ||
|
||
if (val.responses) { | ||
const unwantedProps: string[] = []; | ||
legacyProps.forEach((legacyProp) => { | ||
if (typeof val[legacyProp as keyof typeof val] !== "undefined") { | ||
console.error( | ||
`Deprecated: Unexpected falsy value for: ${unwantedProps.join( | ||
"," | ||
)}. They can't be used with \`responses\`. This will become a 400 error in the future.` | ||
); | ||
} | ||
if (val[legacyProp as keyof typeof val]) { | ||
unwantedProps.push(legacyProp); | ||
} | ||
}); | ||
if (unwantedProps.length) { | ||
ctx.addIssue({ | ||
code: "custom", | ||
message: `Legacy Props: ${unwantedProps.join(",")}. They can't be used with \`responses\``, | ||
}); | ||
return; | ||
} | ||
} else if (val.customInputs) { | ||
const { success } = bookingCreateSchemaLegacyPropsForApi.safeParse(val); | ||
if (!success) { | ||
ctx.addIssue({ | ||
code: "custom", | ||
message: `With \`customInputs\` you must specify legacy props ${legacyProps.join(",")}`, | ||
}); | ||
} | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split API specific schema to packages/features/bookings/lib/getBookingDataSchemaForApi.ts
import type { getBookingFieldsWithSystemFields } from "./getBookingFields"; | ||
import getBookingResponsesSchema from "./getBookingResponsesSchema"; | ||
|
||
const getBookingDataSchemaForApi = ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self explanatory
@@ -990,25 +990,23 @@ describe("getBookingResponsesSchema", () => { | |||
describe("getBookingResponsesPartialSchema - Prefill validation", () => { | |||
test(`should be able to get fields prefilled even when name is empty string`, async ({}) => { | |||
const schema = getBookingResponsesPartialSchema({ | |||
eventType: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Denesting as well
}; | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Elses are unnecessary with early returns
{ | ||
isNotAnApiCall = false, | ||
}: { | ||
isNotAnApiCall?: boolean; | ||
} = { | ||
isNotAnApiCall: false, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your service 🙏🏽
} = { | ||
isNotAnApiCall: false, | ||
} | ||
bookingDataSchemaGetter: BookingDataSchemaGetter = getBookingDataSchema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there no schema getter we fallback to the default one.
const bookingDataSchema = bookingDataSchemaGetter({ | ||
view: req.body?.rescheduleUid ? "reschedule" : "booking", | ||
bookingFields: eventType.bookingFields, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we retrieve the schema
const bookingData = await getBookingData({ | ||
req, | ||
eventType, | ||
schema: bookingDataSchema, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And pass it to getBookingData
What does this PR do?
isNotAnApiCall: true
in all other calls.isNotAnApiCall
in code it makes the logic unnecessarily harder to read.handleNewBooking
to receive an optional schema for the request body. Fallbacks to the default one if none is passed.Type of change
How should this be tested?
Mandatory Tasks