Skip to content

Comments

fix: get organization bookings bookingUid parameter#23186

Merged
supalarry merged 4 commits intomainfrom
lauris/cal-6277-fix-managed-orgs-bookings-by-bookinguid
Aug 19, 2025
Merged

fix: get organization bookings bookingUid parameter#23186
supalarry merged 4 commits intomainfrom
lauris/cal-6277-fix-managed-orgs-bookings-by-bookinguid

Conversation

@supalarry
Copy link
Contributor

Linear CAL-6277

@supalarry supalarry requested a review from a team August 19, 2025 10:46
@supalarry supalarry requested a review from a team as a code owner August 19, 2025 10:46
@vercel
Copy link

vercel bot commented Aug 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Aug 19, 2025 0:45am
cal-eu Ignored Ignored Aug 19, 2025 0:45am

@linear
Copy link

linear bot commented Aug 19, 2025

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 19, 2025

Walkthrough

This 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

Objective Addressed Explanation
Pass bookingUid from input query param to service (CAL-6277)
Add bookingUid tests in organizations-bookings.controller.e2e-spec.ts (CAL-6277)

Out-of-scope changes

Code Change (file_path) Explanation
Dependency version bump of @calcom/platform-libraries (apps/api/v2/package.json) Not required by CAL-6277; unrelated dependency update included in PR.
Removal of inline comments in managed-user-bookings E2E spec (apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/managed-user-bookings.e2e-spec.ts) Only comment cleanup; unrelated to bookingUid fix.

Possibly related PRs

  • fix: managed organization bookings #23078 — Modifies organizations bookings tests and fixtures (managed-organization bookings), touching the same booking retrieval/test paths and likely related to bookingUid filtering.

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 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.

📥 Commits

Reviewing files that changed from the base of the PR and between f34592a and 2af08db.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • apps/api/v2/package.json (1 hunks)
⏰ 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: Install dependencies / Yarn install & cache
  • GitHub Check: Atoms E2E Tests
🔇 Additional comments (2)
apps/api/v2/package.json (2)

41-41: Dependency bump to platform-libraries 0.0.318 looks appropriate

This aligns with the PR’s change that starts passing bookingUid through the input service; presumably 0.0.318 contains the corresponding helpers/types. No concerns on this line.


41-41: Workspace consistency verified for @calcom/platform-libraries

– Scanned all package.json files: only apps/api/v2 pins @calcom/platform-libraries to npm:@calcom/platform-libraries@0.0.318.
– Yarn lockfile entries confirm the alias resolved to version 0.0.318.
– The workspace package remains at its local version (0.0.0-use.local) as expected.

No version skew detected.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch lauris/cal-6277-fix-managed-orgs-bookings-by-bookinguid

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app graphite-app bot requested a review from a team August 19, 2025 10:46
@keithwillcode keithwillcode added core area: core, team members only platform Anything related to our platform plan labels Aug 19, 2025
@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking organizations area: organizations, orgs 🐛 bug Something isn't working labels Aug 19, 2025
@graphite-app
Copy link

graphite-app bot commented Aug 19, 2025

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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.

collectiveOrgBookingUid depends on a previous test. This introduces ordering dependency and potential flakiness. Prefer creating the booking in a beforeAll within 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.

📥 Commits

Reviewing files that changed from the base of the PR and between f9e24f5 and f34592a.

📒 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.ts or .repository.ts for new files; reserve .test.ts, .spec.ts, .types.ts for 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 use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/services/input.service.ts
  • apps/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.ts
  • apps/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 confirmed

Verified that GetBookingsInput_2024_08_13 declares bookingUid?: string and that transformGetBookingsFilters now passes this singular string. Downstream EE service and Prisma repository layers consistently apply it via where: { uid: bookingUid } (no array of UIDs). No array-based bookingUids handling 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 createdByOAuthClient to oAuthClient.id ensures 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.uid is appropriate for later retrieval tests.


716-731: Non-existent UID case is covered well.

Asserting an empty array on 200 OK for unknown bookingUid is the right contract.

ibex088
ibex088 previously approved these changes Aug 19, 2025
Copy link
Contributor

@ibex088 ibex088 left a comment

Choose a reason for hiding this comment

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

🚀

@github-actions
Copy link
Contributor

github-actions bot commented Aug 19, 2025

E2E results are ready!

@ibex088 ibex088 self-requested a review August 19, 2025 12:43
@supalarry supalarry merged commit 3d778ba into main Aug 19, 2025
39 of 40 checks passed
@supalarry supalarry deleted the lauris/cal-6277-fix-managed-orgs-bookings-by-bookinguid branch August 19, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working core area: core, team members only organizations area: organizations, orgs platform Anything related to our platform plan ready-for-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants