feat(frontend): manage Cognito users and groups, and test sign-in
CI / checks (pull_request) Failing after 12m24s
CI / checks (pull_request) Failing after 12m24s
The Cognito panel gains a test sign-in that shows the decoded ID and access token claims, a groups section, and a per-user panel to enable or disable, confirm, sign out everywhere, reset or set a password and change group membership. Delete confirmations (row and bulk) now say what else goes, driven by the schema's deleteImpact, and the inspector follows list refreshes instead of the click-time snapshot.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import {render, screen} from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import {expect, test, vi} from 'vitest'
|
||||
import {ResourceTable} from './ResourceTable'
|
||||
import type {CloudResource} from '@/types/resource'
|
||||
import type {ServiceSchema} from '@/types/schema'
|
||||
|
||||
const schema: ServiceSchema = {
|
||||
cloud: 'aws',
|
||||
service: 'userpools',
|
||||
displayName: 'Cognito',
|
||||
fields: [],
|
||||
actions: ['list', 'delete'],
|
||||
filters: [],
|
||||
columns: [{name: 'name', label: 'Name'}],
|
||||
deleteImpact: [
|
||||
{path: 'metadata.userCount', singular: 'user', plural: 'users'},
|
||||
{path: 'metadata.appClients', singular: 'app client', plural: 'app clients'},
|
||||
],
|
||||
}
|
||||
|
||||
const pool: CloudResource = {
|
||||
id: 'us-east-1_abc', name: 'orders-users', cloud: 'aws', service: 'userpools', type: 'user-pool',
|
||||
region: 'us-east-1', createdAt: null, metadata: {userCount: 2, appClients: [{clientId: 'c1'}]},
|
||||
}
|
||||
|
||||
test('the row delete confirmation says what else is deleted', async () => {
|
||||
const user = userEvent.setup()
|
||||
const onDelete = vi.fn()
|
||||
render(<ResourceTable schema={schema} resources={[pool]} onSelect={vi.fn()} onDelete={onDelete}/>)
|
||||
|
||||
await user.click(screen.getByRole('button', {name: 'Delete orders-users'}))
|
||||
expect(screen.getByRole('status')).toHaveTextContent('This also deletes 2 users and 1 app client.')
|
||||
|
||||
await user.click(screen.getByRole('button', {name: 'Confirm'}))
|
||||
expect(onDelete).toHaveBeenCalledWith(pool)
|
||||
})
|
||||
Reference in New Issue
Block a user