fix: consolidate booking access checks into doesUserIdHaveAccessToBooking (#28071)

* fix: align checkBookingAccessWithPBAC with listing logic for personal event types

Co-Authored-By: [email protected] <[email protected]>

* fix: align permission strings with doesUserIdHaveAccessToBooking granular permissions

Co-Authored-By: [email protected] <[email protected]>

* change implementation

* remove unused code

* test: add getBookingDetails tests for personal event type booking access

Co-Authored-By: [email protected] <[email protected]>

* fix: remove unused MembershipRole import

Co-Authored-By: [email protected] <[email protected]>

* test: convert BookingDetailsService tests to integration tests

Replace unit tests with mocks by integration tests using real database.
Tests verify org/team admin access to personal event type bookings.

- Org admin viewing team member's personal event booking (fails on main, passes on PR)
- Team admin viewing team member's personal event booking (fails on main, passes on PR)
- Non-admin denied access (passes on both)
- Owner viewing own booking (passes on both)
- Non-existent booking returns Forbidden (passes on both)

Co-Authored-By: [email protected] <[email protected]>

* test: refactor integration tests to use repositories instead of direct prisma calls

Co-Authored-By: [email protected] <[email protected]>

* test: replace direct prisma usage with TestXXXRepository pattern in integration tests

Co-Authored-By: [email protected] <[email protected]>

* test: use production repositories (OrganizationRepository, BookingRepository, UserRepository) instead of test repos for setup

Co-Authored-By: [email protected] <[email protected]>

* test: inline test repository logic into integration test file

The TestXXXRepository classes were thin wrappers around single prisma
calls with barely any logic, so the indirection wasn't justified.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-03-11 14:46:57 -03:00
1 parent d3dad196d6
commit 7ff2eaf293
6 files changed
+284 -108

No files matched your search

-30
View File
@@ -13,36 +13,6 @@ export const bookingMinimalSelect = {
createdAt: true,
} satisfies Prisma.BookingSelect;
export const bookingAuthorizationCheckSelect = {
userId: true,
eventType: {
select: {
teamId: true,
users: {
select: {
id: true,
email: true,
},
},
hosts: {
select: {
user: {
select: {
id: true,
email: true,
},
},
},
},
},
},
attendees: {
select: {
email: true,
},
},
} satisfies Prisma.BookingSelect;
export const bookingDetailsSelect = {
uid: true,
rescheduled: true,