fix: unable to cancel a seated event as a host#24426
Conversation
WalkthroughThe change updates apps/web/components/booking/bookingActions.ts to compute seatReferenceUid once per usage context via getSeatReferenceUid() and store it in a local variable. getCancelEventAction and getEditEventActions now reference this local seatReferenceUid instead of calling getSeatReferenceUid() inline. Inclusion of the seatReferenceUid in cancel and reschedule URLs is now gated by the presence of booking.seatsReferences and the computed seatReferenceUid, with reschedule additionally checking attendee status. No exported/public declarations were altered. Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
apps/web/components/booking/bookingActions.ts(2 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.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/web/components/booking/bookingActions.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/web/components/booking/bookingActions.ts
**/*.{ts,tsx,js,jsx}
⚙️ CodeRabbit configuration file
Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.
Files:
apps/web/components/booking/bookingActions.ts
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Install dependencies / Yarn install & cache
🔇 Additional comments (2)
apps/web/components/booking/bookingActions.ts (2)
67-67: LGTM! Fix properly guards against undefined seatReferenceUid.Computing
seatReferenceUidonce and storing it locally is efficient. The defensive check on line 74 ensures the query parameter is only appended when bothseatsReferencesexist and a validseatReferenceUidis available, preventing malformed URLs when hosts (who lack seat references) cancel seated events.Also applies to: 74-74
110-110: LGTM! Appropriate guard with isAttendee check for reschedule action.The local
seatReferenceUidcomputation and the three-part guard on line 118 are correct. TheisAttendeecheck is particularly appropriate here: attendees need the seat reference to reschedule their specific seat, while hosts reschedule the entire event without requiring a seat-specific reference.Also applies to: 118-118
|
|
||
| export function getCancelEventAction(context: BookingActionContext): ActionType { | ||
| const { booking, isTabRecurring, isRecurring, getSeatReferenceUid, t } = context; | ||
| const seatReferenceUid = getSeatReferenceUid(); |
There was a problem hiding this comment.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
Verify test coverage for the fix.
The PR description states that automated tests should exist to prove the fix. Please ensure tests cover the scenario where hosts cancel seated events (where getSeatReferenceUid() returns undefined) and verify the generated URLs are correct.
Also applies to: 110-110
🏁 Script executed:
#!/bin/bash
# Description: Search for test files covering booking actions and seat reference handling
# Find test files related to booking actions
fd -e test.ts -e test.tsx -e spec.ts -e spec.tsx . | xargs rg -l "bookingActions|getCancelEventAction|getEditEventActions" -C 2
# Search for tests covering seat reference scenarios
rg -n "seatReferenceUid|seatsReferences" --type=ts --type=tsx -g "*test*" -g "*spec*" -C 3Length of output: 78
Add tests for undefined seatReferenceUid scenario.
apps/web/components/booking/bookingActions.test.ts doesn’t cover the case when getSeatReferenceUid() returns undefined. Add tests that simulate a host canceling a seated event and verify the generated URLs.
🤖 Prompt for AI Agents
In apps/web/components/booking/bookingActions.ts around line 67, the call to
getSeatReferenceUid() can return undefined but there are no tests covering that
branch; update apps/web/components/booking/bookingActions.test.ts to add a test
that stubs/mocks getSeatReferenceUid() to return undefined, simulates a host
canceling a seated event, invokes the action that builds the cancellation URLs,
and asserts the generated URLs match the expected fallback behavior (e.g., omit
seat reference or use alternative query parameters). Ensure the test resets the
mock after running and includes both URL structure and query param assertions.
E2E results are ready! |
What does this PR do?
unable to cancel a seated event as a host from booking action