Files
Charis 9391f60ec9 test(studio): add shared permissions mocks and testGrant helper (#52312)
## Problem

Components and fetchers are moving to endpoint-bound FGA grants, so more
tests need to mock `/platform/profile/permissions/v2` and mint grants.
Each test file currently defines its own permissions response type and
mock, and `testGrant` lives inside `guarded-fetch.test.ts`.

Resolves
[FE-4692](https://linear.app/supabase/issue/FE-4692/test-infra-global-msw-handler-for-v2-permissions-and-testgrant).

## Solution

* `tests/lib/permissions-fixtures.ts`: shared `PermissionsV2Response`
type, `ALL_FGA_PERMISSIONS`, `allPermissionsFor(slugs)` (grants
everything at the org level), and `NO_PERMISSIONS`.
* `tests/lib/msw-permissions.ts`: `mockPermissions(response)` and
`mockPermissionsError({ status, message })` on top of `addAPIMock`.
* `tests/lib/test-grant.ts`: `testGrant(endpoint, { variant,
organizationSlug, projectRef, permissionsProjectRef })` for unit tests
of fetchers and query options, moved out of `guarded-fetch.test.ts`.
* Existing tests that mocked the v2 endpoint now use the shared helpers.
`IndirectTaxDeclarationModal.test.tsx` keeps its own `addAPIMock`
because a test asserts the request was served.
* Documented in `apps/studio/tests/README.md` and the
`studio-mock-api-tests` skill.
2026-10-26 10:51:20 -04:00
..