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:
2026-10-14 11:12:22 +08:00
co-authored by Claude Sonnet 5.5
parent de7fb298f7
commit 550a61cedc
4 changed files with 156 additions and 8 deletions
@@ -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()
})
})