feat(capa): proof form for owners and photo gallery for HSE
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import { SubmitVerificationForm } from '@/components/capa/submit-verification-form'
|
||||
|
||||
vi.mock('next/navigation', () => ({
|
||||
useRouter: () => ({ refresh: vi.fn() }),
|
||||
}))
|
||||
|
||||
function button() {
|
||||
return screen.getByRole('button', { name: 'Submit for Verification' }) as HTMLButtonElement
|
||||
}
|
||||
|
||||
describe('SubmitVerificationForm', () => {
|
||||
it('is disabled until a note and a photo are provided', () => {
|
||||
const { container } = render(<SubmitVerificationForm capaId="abc" />)
|
||||
expect(button().disabled).toBe(true)
|
||||
|
||||
fireEvent.change(screen.getByLabelText('Completion note'), { target: { value: 'Rack fixed' } })
|
||||
expect(button().disabled).toBe(true)
|
||||
|
||||
const input = container.querySelector('input[type="file"]') as HTMLInputElement
|
||||
const file = new File(['x'], 'proof.jpg', { type: 'image/jpeg' })
|
||||
fireEvent.change(input, { target: { files: [file] } })
|
||||
expect(button().disabled).toBe(false)
|
||||
expect(screen.getByText('proof.jpg')).toBeTruthy()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user