chore: Add tests for CertificateList and CertificateUploadDialog components

- Implement test to deselect a row checkbox in CertificateList by clicking it a second time.
- Add test to close detail dialog via the close button in CertificateList.
- Add test to close export dialog via the cancel button in CertificateList.
- Add test to show KEY format badge when a .key file is uploaded in CertificateUploadDialog.
- Add test to ensure no format badge is shown for unknown file extensions in CertificateUploadDialog.
This commit is contained in:
GitHub Actions
2026-04-15 11:35:10 +00:00
parent fb8d80f6a3
commit 8239a94938
10 changed files with 3334 additions and 1724 deletions

View File

@@ -384,4 +384,26 @@ describe('CertificateUploadDialog', () => {
expect(screen.queryByTestId('certificate-validation-preview')).toBeFalsy()
})
})
it('shows KEY format badge when .key file is uploaded', async () => {
const user = userEvent.setup({ applyAccept: false })
renderDialog()
const certInput = document.getElementById('cert-file') as HTMLInputElement
const file = new File(['key-data'], 'server.key', { type: 'application/x-pem-file' })
await user.upload(certInput, file)
expect(await screen.findByText('KEY')).toBeTruthy()
})
it('shows no format badge for unknown file extension', async () => {
const user = userEvent.setup({ applyAccept: false })
renderDialog()
const certInput = document.getElementById('cert-file') as HTMLInputElement
const file = new File(['data'], 'cert.bin', { type: 'application/octet-stream' })
await user.upload(certInput, file)
await screen.findByText('cert.bin')
expect(screen.queryByText('KEY')).toBeNull()
expect(screen.queryByText('DER')).toBeNull()
expect(screen.queryByText('PFX/PKCS#12')).toBeNull()
expect(screen.queryByText('PEM')).toBeNull()
})
})