import { screen } from '@testing-library/react' import { describe, expect, test } from 'vitest' import { ScopeGroupCard } from './ScopeGroupCard' import type { OAuthScope } from '@/data/oauth-apps/types' import { customRender } from '@/tests/lib/custom-render' const SCOPE_GROUPS: OAuthScope[] = [ 'database:read', 'database:write', 'environment:read', 'environment:write', 'projects:read', 'edge_functions:read', 'storage:read', ] describe('ScopeGroupCard', () => { test('renders Read only and Read and write headings', () => { customRender() expect(screen.getByText('Read and write')).toBeInTheDocument() expect(screen.getByText('Read only')).toBeInTheDocument() }) test('renders a Write heading for a write-only group', () => { customRender() expect(screen.getByText('Write')).toBeInTheDocument() }) test('groups direct database read-write access with the requested database management permission', () => { customRender() const databaseManagement = screen.getByRole('button', { name: 'Database management' }) const directDatabaseAccess = screen.getByRole('button', { name: 'Database token access' }) expect(databaseManagement.parentElement).toContainElement(directDatabaseAccess) }) test('renders no over-role annotation', () => { customRender() expect(screen.queryByText('Read-only for your role')).not.toBeInTheDocument() }) })