import {render, screen} from '@testing-library/react' import userEvent from '@testing-library/user-event' import {describe, expect, test, vi} from 'vitest' import {CodeDeployCreatePanel} from './CodeDeployPanel' describe('CodeDeployCreatePanel', () => { test('preserves the Lambda creation flow by default', async () => { const user = userEvent.setup() const onSubmit = vi.fn() render() await user.type(screen.getByLabelText(/^Application name/), 'orders') await user.type(screen.getByLabelText(/^Deployment group name/), 'production') await user.type(screen.getByLabelText(/^Service role ARN/), 'role-arn') await user.click(screen.getByRole('button', {name: 'Create deployment group'})) expect(screen.queryByLabelText(/^Cluster name/)).not.toBeInTheDocument() expect(onSubmit).toHaveBeenCalledWith({applicationName: 'orders', deploymentGroupName: 'production', computePlatform: 'Lambda', serviceRoleArn: 'role-arn', deploymentConfig: 'AllAtOnce', rollbackOnFailure: true}) }) test('submits ECS blue-green deployment group inputs', async () => { const user = userEvent.setup() const onSubmit = vi.fn() render() await user.selectOptions(screen.getByLabelText('Compute platform'), 'ECS') await user.type(screen.getByLabelText(/^Application name/), 'orders') await user.type(screen.getByLabelText(/^Deployment group name/), 'production') await user.type(screen.getByLabelText(/^Service role ARN/), 'role-arn') await user.type(screen.getByLabelText(/^Cluster name/), 'orders-cluster') await user.type(screen.getByLabelText(/^Service name/), 'orders-service') await user.type(screen.getByLabelText(/Current production target group/), 'orders-blue') await user.type(screen.getByLabelText(/Replacement target group/), 'orders-green') await user.type(screen.getByLabelText(/^Production listener ARN/), 'listener-arn') await user.selectOptions(screen.getByLabelText('Traffic configuration'), 'Linear10PercentEvery3Minutes') await user.click(screen.getByLabelText(/Automatic rollback/)) await user.click(screen.getByRole('button', {name: 'Create deployment group'})) expect(onSubmit).toHaveBeenCalledWith({applicationName: 'orders', deploymentGroupName: 'production', computePlatform: 'ECS', serviceRoleArn: 'role-arn', clusterName: 'orders-cluster', serviceName: 'orders-service', blueTargetGroupName: 'orders-blue', greenTargetGroupName: 'orders-green', productionListenerArn: 'listener-arn', deploymentConfig: 'Linear10PercentEvery3Minutes', rollbackOnFailure: false}) }) })