fix: get organization bookings bookingUid parameter#23186
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
WalkthroughThis PR passes bookingUid from the GET query into transformGetBookingsFilters in apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts, enabling filtering by booking UID. It adds E2E tests in apps/api/v2/src/modules/organizations/bookings/organizations-bookings.controller.e2e-spec.ts that exercise ?bookingUid= behavior (success, not-found, cross-organization). Test setup was adjusted to create and attach an OAuth client to a team and capture a collectiveOrgBookingUid for assertions. A separate E2E file had only comment removals. package.json dependency for @calcom/platform-libraries was bumped. Assessment against linked issues
Out-of-scope changes
Possibly related PRs
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (2)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (08/19/25)1 reviewer was added to this PR based on Keith Williams's automation. "Add ready-for-e2e label" took an action on this PR • (08/19/25)1 label was added to this PR based on Keith Williams's automation. |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
apps/api/v2/src/modules/organizations/bookings/organizations-bookings.controller.e2e-spec.ts (3)
69-70: Avoid cross-test coupling by deriving the UID within this suite.
collectiveOrgBookingUiddepends on a previous test. This introduces ordering dependency and potential flakiness. Prefer creating the booking in abeforeAllwithin the "get by bookingUid param" suite or fetching a known booking from fixtures there. At minimum, assert it's defined to fail fast.Example guard (minimal):
describe("get by bookingUid param", () => { + // Sanity check: ensure UID was set earlier (avoid silent false positives) + it("precondition: collectiveOrgBookingUid is defined", () => { + expect(collectiveOrgBookingUid).toBeDefined(); + });
681-714: Solid e2e coverage for bookingUid filter; avoid assumptions about attendees ordering.The test is strong and validates key fields. Minor: indexing into
attendees[0]assumes a stable order. Use a find by email to reduce brittleness.- expect(booking.attendees.length).toEqual(2); - expect(booking.attendees[0].name).toEqual("alice"); - expect(booking.attendees[0].email).toEqual("alice@gmail.com"); + expect(booking.attendees.length).toEqual(2); + const alice = booking.attendees.find((a) => a.email === "alice@gmail.com"); + expect(alice).toBeDefined(); + expect(alice?.name).toEqual("alice");
734-797: Ensure cleanup for ad-hoc user/event/booking to prevent test pollution.You create a standalone user, event type, and booking. Only the user is deleted at the end; depending on FK constraints, bookings/event types might remain or block deletion. Recommend explicit cleanup of created booking(s) (and event type if needed) to keep the test idempotent.
Minimal, using an existing helper already used in afterAll:
expect(responseBody.data.length).toEqual(0); - await userRepositoryFixture.delete(regularUser.id); + // Cleanup the ad-hoc booking(s) associated with the temporary user + await bookingsRepositoryFixture.deleteAllBookings(regularUser.id, "regular@example.com"); + // Optionally also remove the event type if the fixture exposes a delete method: + // await eventTypesRepositoryFixture.delete(regularUserEventType.id); + await userRepositoryFixture.delete(regularUser.id);Optionally, convert this test to async/await with a try/finally for guaranteed cleanup if an assertion fails. Would you like a refactor patch for that?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/managed-user-bookings.e2e-spec.ts(0 hunks)apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts(1 hunks)apps/api/v2/src/modules/organizations/bookings/organizations-bookings.controller.e2e-spec.ts(4 hunks)
💤 Files with no reviewable changes (1)
- apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/managed-user-bookings.e2e-spec.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{service,repository}.ts
📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)
Avoid dot-suffixes like
.service.tsor.repository.tsfor new files; reserve.test.ts,.spec.ts,.types.tsfor their specific purposes
Files:
apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts
**/*.ts
📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)
**/*.ts: For Prisma queries, only select data you need; never useinclude, always useselect
Ensure thecredential.keyfield is never returned from tRPC endpoints or APIs
Files:
apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.tsapps/api/v2/src/modules/organizations/bookings/organizations-bookings.controller.e2e-spec.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)
Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js
.utc()in hot paths like loops
Files:
apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.tsapps/api/v2/src/modules/organizations/bookings/organizations-bookings.controller.e2e-spec.ts
🧬 Code Graph Analysis (1)
apps/api/v2/src/modules/organizations/bookings/organizations-bookings.controller.e2e-spec.ts (2)
packages/platform/constants/api.ts (5)
CAL_API_VERSION_HEADER(72-72)VERSION_2024_08_13(59-59)X_CAL_CLIENT_ID(50-50)X_CAL_SECRET_KEY(49-49)SUCCESS_STATUS(9-9)packages/platform/types/bookings/2024-08-13/outputs/booking.output.ts (3)
BookingOutput_2024_08_13(280-306)RecurringBookingOutput_2024_08_13(308-323)GetSeatedBookingOutput_2024_08_13(325-331)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Check for E2E label
- GitHub Check: Atoms E2E Tests
🔇 Additional comments (4)
apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts (1)
705-706: BookingUid filter — singular string usage confirmedVerified that GetBookingsInput_2024_08_13 declares
bookingUid?: stringand thattransformGetBookingsFiltersnow passes this singular string. Downstream EE service and Prisma repository layers consistently apply it viawhere: { uid: bookingUid }(no array of UIDs). No array-basedbookingUidshandling was found. Change is safe to approve.apps/api/v2/src/modules/organizations/bookings/organizations-bookings.controller.e2e-spec.ts (3)
96-106: Linking team to the OAuth client at creation time looks correct.Connecting
createdByOAuthClienttooAuthClient.idensures subsequent OAuth-authenticated org requests operate under the expected client context.
323-326: Persisting the created booking UID for follow-up assertions — LGTM.Capturing
collectiveOrgBookingUid = data.uidis appropriate for later retrieval tests.
716-731: Non-existent UID case is covered well.Asserting an empty array on 200 OK for unknown
bookingUidis the right contract.
E2E results are ready! |
Linear CAL-6277