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() 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) })