> [!WARNING] > Live readiness checks require [CTRL-2277](https://linear.app/supabase/issue/CTRL-2277) in the target environment; production deployment is pending. ## Problem Trusted Partner consent must explain direct database access and project blockers before authorisation. [DEPR-732](https://linear.app/supabase/issue/DEPR-732) ## Solution - Show Direct database access alongside the requested permissions. - Check selected projects, or every project page for organisation-wide grants. - Separate blocking issues from SSL notices; block authorisation during loading or errors and offer retry. | After | | --- | | <img width="1280" height="1323" alt="Authorize API Access Supabase" src="https://github.com/user-attachments/assets/adb6367a-bace-4b62-81b5-68ba4c11396c" /> | | Consent screen with Direct database access (previously “Table data”) and Database management | | <img width="1280" height="1323" alt="Authorize API Access Supabase" src="https://github.com/user-attachments/assets/0c35900c-1059-49cd-b1c5-4e0cf5441b9b" /> | | Selected-project blockers and the separate SSL notice | | <img width="1280" height="1323" alt="95741" src="https://github.com/user-attachments/assets/1fbef4f0-0433-4c93-b390-84d210dfb665" /> | | Organisation-wide blockers _without_ project-removal actions | ## Review instructions 1. Open the [staging consent screen](https://studio-staging-git-dnywh-depr-732-trusted-partn-f24cfb-supabase.vercel.app/dashboard/authorize?auth_id=11666aa8-7f7e-4705-b33a-981903fd682e). Enable `enableScopedOAuthConsent` in the dev toolbar’s **Flags** tab if needed. 2. Open Chrome DevTools → **Network** and reload. Select the **GET** request ending in `/platform/oauth/authorizations/{id}`. 3. Right-click that request → **Override content**. Choose a local folder and click **Allow**. Add `database_token_access:read` and `database_token_access:write` to `scopes`. Use only the read scope to check read-only access. Keep every other field, save with **Cmd/Ctrl+S**, then reload with DevTools open. 4. Select projects. Override each **GET** request ending in `/platform/organizations/{slug}/oauth/authorizations/{id}/projects/{ref}/database-access`. Use `{"issues":[],"enables_ssl":false}` for ready projects, then `{"issues":[],"enables_ssl":true}` for an SSL notice. Save and reload after each change. Check Direct database access and Database management are separate, and SSL alone allows authorisation. 5. Change a readiness response to `{"issues":["postgres_upgrade_required","platform_unsupported"],"enables_ssl":true}`. Save and reload. Check blockers prevent authorisation, SSL stays separate, and removing a blocked project clears its blockers. 6. Set `project_scoping_mode: false` in the authorisation override. Save and reload. Check any blocked project prevents organisation-wide authorisation, with no project-removal actions. 7. Block a database-access request in Network and reload. Check authorisation stays disabled. Unblock it and choose **Retry checks**. 8. For a returning app, override `existing_grant.approved_scopes` in the request ending in `/preflight`. Save and reload. Check added, removed and unchanged permissions. 9. Disable **Sources → Overrides → Enable Local Overrides**. Repeat ready and blocked project checks with a real staging authorisation before approving live readiness behaviour. --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
UI Testing Notes
Rules
-
All tests should be run consistently (avoid situations whereby tests fails "sometimes")
-
Group tests in folders based on the feature they are testing. Avoid file/folder based folder names since those can change and we will forget to update the tests.
Examples: /logs /reports /projects /database-settings /auth
Custom Render and Custom Render Hook
customRender and customRenderHook are wrappers around render and renderHook that add some necessary providers like QueryClientProvider, TooltipProvider and NuqsTestingAdapter.
Generally use those instead of the default render and renderHook functions.
import { customRender, customRenderHook } from 'tests/lib/custom-render'
customRender(<MyComponent />)
customRenderHook(() => useMyHook())
Mocking API Requests
To mock API requests, we use the msw library.
Global mocks can be found in tests/lib/msw-global-api-mocks.ts.
To mock the current user's FGA permissions, use mockPermissions (with allPermissionsFor or NO_PERMISSIONS from tests/lib/permissions-fixtures.ts) or mockPermissionsError from tests/lib/msw-permissions.ts.
To mock an endpoint you can use the addAPIMock function. Make sure to add the mock in the beforeEach hook. It won't work with beforeAll if you have many tests.
beforeEach(() => {
addAPIMock({
method: 'get',
path: '/api/my-endpoint',
response: {
data: { foo: 'bar' },
},
})
})
API Mocking Tips:
- Keep mocks in the same folder as the tests that use them
- Add a test to verify the mock is working
This will make debugging and updating the mocks easier.
test('mock is working', async () => {
const response = await fetch('/api/my-endpoint')
expect(response.json()).resolves.toEqual({ data: { foo: 'bar' } })
})
Mocking Nuqs URL Parameters
To render a component that uses Nuqs with some predefined query parameters, you can use customRender with the nuqs prop.
customRender(<MyComponent />, {
nuqs: {
searchParams: {
search: 'hello world',
},
},
})
<Popover> vs <Dropdown>
When simulating clicks on these components, do the following:
// for Popovers
import userEvent from '@testing-library/user-event'
await userEvent.click('Hello world')
// for Dropdowns
import clickDropdown from 'tests/helpers'
clickDropdown('Hello world')