Files
floci-ui/packages/frontend/src/components/CodeDeployPanel.test.tsx
T
Zakaria b171f745db test: bring stale tests and lint in line with the current UI
- CodeDeploy: query the redesigned form's labels.
- CloudFormation: expect the parameters and capabilities fields the form
  now submits.
- ALB listeners: advance the five-second minimum create state before
  deleting, since row actions are disabled while it is pending.
- Lightsail: cast the fetch mock as a whole so it type-checks.
- TargetGroupPanel: depend on the stable refetch function to satisfy
  react-hooks/exhaustive-deps.
2026-10-23 11:12:51 -04:00

42 lines
2.8 KiB
TypeScript

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(<CodeDeployCreatePanel isSubmitting={false} submitError={null} onCancel={vi.fn()} onSubmit={onSubmit}/>)
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(<CodeDeployCreatePanel isSubmitting={false} submitError={null} onCancel={vi.fn()} onSubmit={onSubmit}/>)
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})
})
})