fix: add 'is' wrapper for organizationSettings filter in isAdmin guard #24975
+3
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes integration test failures by correcting the Prisma filter syntax in the
isAdminguard for checking organization admin permissions.The issue was that the guard was filtering on the one-to-one
organizationSettingsrelation without using the requirediswrapper, causing the query to return no matches even when valid org admins withisAdminAPIEnabled: trueexisted.Root cause: Prisma requires the
iswrapper when filtering on one-to-one relations. The query was using:But should be:
Impact: This fixes 5 failing integration tests:
apps/api/v1/test/lib/utils/isAdmin.integration-test.ts- Org admin recognitionapps/api/v1/test/lib/utils/retrieveScopedAccessibleUsers.integration-test.ts- User scoping (2 tests)apps/api/v1/test/lib/bookings/_get.integration-test.ts- Org admin booking accessapps/api/v1/test/lib/bookings/[id]/_patch.integration-test.ts- Booking modification permissionsLink to Devin run: https://app.devin.ai/sessions/fe59aee7f5494dc888ecbd3299e65b63
Requested by: eunjae@cal.com (@eunjae-lee)
How should this be tested?
Run the integration tests to verify they now pass:
TZ=UTC yarn test --project=IntegrationTestsSpecifically check that these tests pass:
isAdminAPIEnabled: trueMandatory Tasks
Checklist
Important Notes for Reviewers
organizationSettingsis a one-to-one relationiswrapper for one-to-one relation filtersisAdminAPIEnabled: truein fixturesPlease verify:
iswrapper is correct for one-to-one relations