Files
floci-ui/packages/frontend/src/components/CloudFormationCreatePanel.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

23 lines
1.6 KiB
TypeScript

import {fireEvent, render, screen, waitFor} from '@testing-library/react'
import {describe, expect, test, vi} from 'vitest'
import {CloudFormationCreatePanel} from './CloudFormationCreatePanel'
describe('CloudFormationCreatePanel', () => {
test('loads a YAML template file into the template editor', async () => {
render(<CloudFormationCreatePanel isSubmitting={false} submitError={null} onCancel={vi.fn()} onSubmit={vi.fn()}/>)
const input = document.querySelector('input[type="file"]') as HTMLInputElement
fireEvent.change(input, {target: {files: [new File(['Resources:\n Queue:\n Type: AWS::SQS::Queue\n'], 'queue.yaml', {type: 'text/yaml'})]}})
await waitFor(() => expect(screen.getByLabelText('Template')).toHaveValue('Resources:\n Queue:\n Type: AWS::SQS::Queue\n'))
expect(screen.getByText('Loaded queue.yaml')).toBeInTheDocument()
})
test('submits a stack with an S3 template URL without inline content', () => {
const onSubmit = vi.fn()
render(<CloudFormationCreatePanel isSubmitting={false} submitError={null} onCancel={vi.fn()} onSubmit={onSubmit}/>)
fireEvent.change(screen.getByPlaceholderText('orders-stack'), {target: {value: 'orders-stack'}})
fireEvent.change(screen.getByLabelText('Template S3 URL'), {target: {value: 'http://templates.localhost:4566/orders.yaml'}})
fireEvent.click(screen.getByRole('button', {name: 'Create stack'}))
expect(onSubmit).toHaveBeenCalledWith({stackName: 'orders-stack', templateBody: '', templateUrl: 'http://templates.localhost:4566/orders.yaml', parameters: '{}', capabilities: ''})
})
})