mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 15:39:13 +00:00
## Problem When a returning app changes its permissions, the consent screen mixes old and new access levels in a list of parenthetical labels. ## Solution Show added, removed and unchanged permissions in their access groups. A level change appears in both the old and new groups. Green comes from the success token so it stays green across accent settings. | Before | After | | --- | --- | | <img width="868" height="2164" alt="CleanShot 2026-11-20 at 12 40 23@2x" src="https://github.com/user-attachments/assets/74e8462c-60eb-44c5-be25-7e683083be8d" /> | <img width="866" height="1986" alt="CleanShot 2026-11-20 at 12 38 47@2x" src="https://github.com/user-attachments/assets/a739e619-8fc7-4a91-9a28-4b3c176b882b" /> | ## Review instructions 1. **Before:** Open the [Scoped OAuth tester](https://api.supabase.green/v1/oauth/authorize?response_type=code&client_id=a3999bfe-cfc7-4584-9c5a-ab6828d35aa3&redirect_uri=http%3A%2F%2Flocalhost%3A8765%2Foauth%2Fcallback) and leave consent open. 2. **After:** Open the [deploy preview consent screen](https://studio-staging-git-dnywh-oauth-permission-diff-supabase.vercel.app/dashboard/authorize?auth_id=606dbb8e-60ea-4155-bb36-70a7d31378dd). **What to check** 1. Open Chrome DevTools → **Network** → **Fetch/XHR**, filter by the `auth_id` in the consent URL, and reload. Right-click each of these two **GET** requests and select **Override content**. Choose a local Overrides folder if Chrome prompts you. - `/api/platform/oauth/authorizations/<auth_id>` is the new request. Set its top-level `scopes` to `["database:read","database:write","projects:read","storage:read"]`. - `/api/platform/organizations/<org-slug>/oauth/authorizations/<auth_id>/preflight` is the existing grant check. In that response, replace `"existing_grant": null` with this field and leave the rest of the response intact. ```json "existing_grant": { "grant_id": "00000000-0000-4000-8000-000000000001", "approved_scopes": ["database:read", "projects:read", "secrets:read"], "project_refs": null, "approved_at": "2026-11-19T00:00:00.000Z" }, ``` 2. Keep the other fields as returned. Save both overrides and reload with DevTools open. 3. Check that Database management is removed from **Read only** and added to **Read and write**, Projects is unchanged, Storage is added, and Secrets is struck through. Clear the overrides when done.
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
import { screen, within } from '@testing-library/react'
|
|
import { describe, expect, test } from 'vitest'
|
|
|
|
import { ScopeGroupCardWithDiff } from './ScopeGroupCardWithDiff'
|
|
import { customRender } from '@/tests/lib/custom-render'
|
|
|
|
describe('<ScopeGroupCardWithDiff>', () => {
|
|
const getPermissionGroup = (name: string) => within(screen.getByRole('list', { name }))
|
|
|
|
test('shows new, upgraded, downgraded, removed, and unchanged permissions', async () => {
|
|
customRender(
|
|
<ScopeGroupCardWithDiff
|
|
previousScopes={[
|
|
'database:read',
|
|
'domains:read',
|
|
'domains:write',
|
|
'projects:read',
|
|
'organizations:read',
|
|
]}
|
|
scopes={[
|
|
'database:read',
|
|
'database:write',
|
|
'domains:read',
|
|
'analytics:write',
|
|
'projects:read',
|
|
]}
|
|
/>
|
|
)
|
|
|
|
expect(getPermissionGroup('Write').getByText('Analytics').closest('li')).toHaveTextContent(
|
|
'Added'
|
|
)
|
|
const readWrite = getPermissionGroup('Read and write')
|
|
expect(readWrite.getByText('Database management').closest('li')).toHaveTextContent('Added')
|
|
expect(readWrite.getByText('Domains').closest('li')).toHaveTextContent('Removed')
|
|
const read = getPermissionGroup('Read only')
|
|
expect(read.getByText('Database management').closest('li')).toHaveTextContent('Removed')
|
|
expect(read.getByText('Domains').closest('li')).toHaveTextContent('Added')
|
|
expect(read.getByText('Organizations').closest('li')).toHaveTextContent('Removed')
|
|
expect(read.getByText('Projects').closest('li')).toHaveTextContent('Unchanged')
|
|
})
|
|
|
|
test('hides unchanged permissions if empty', async () => {
|
|
customRender(
|
|
<ScopeGroupCardWithDiff
|
|
previousScopes={['database:read']}
|
|
scopes={['database:read', 'database:write']}
|
|
/>
|
|
)
|
|
|
|
expect(getPermissionGroup('Read and write').getByText('Added')).toBeInTheDocument()
|
|
expect(getPermissionGroup('Read only').getByText('Removed')).toBeInTheDocument()
|
|
expect(screen.queryByText('Unchanged')).not.toBeInTheDocument()
|
|
expect(screen.queryByRole('button', { name: /Already granted/ })).not.toBeInTheDocument()
|
|
})
|
|
})
|