diff --git a/app/components/form/fields/TlsCertsField.tsx b/app/components/form/fields/TlsCertsField.tsx index 824f98612..139304230 100644 --- a/app/components/form/fields/TlsCertsField.tsx +++ b/app/components/form/fields/TlsCertsField.tsx @@ -20,8 +20,7 @@ import { Modal } from '~/ui/lib/Modal' import { DescriptionField } from './DescriptionField' import { ErrorMessage } from './ErrorMessage' import { FileField } from './FileField' -import { validateName } from './NameField' -import { TextField } from './TextField' +import { NameField } from './NameField' export function TlsCertsField({ control }: { control: Control }) { const [showAddCert, setShowAddCert] = useState(false) @@ -110,19 +109,14 @@ const AddCertModal = ({ onDismiss, onSubmit, allNames }: AddCertModalProps) => {
- { - if (allNames.includes(name)) { - return 'A certificate with this name already exists' - } - return validateName(name, 'Name', true) - }} + validate={(name) => + allNames.includes(name) + ? 'A certificate with this name already exists' + : undefined + } /> { await chooseFile(page.getByLabel('Cert', { exact: true }), 'small') await chooseFile(page.getByLabel('Key'), 'small') const certName = certDialog.getByRole('textbox', { name: 'Name' }) - await certName.fill('test-cert') + // check name format validation + await certName.fill('Bad Name') + await certSubmit.click() + await expect( + certDialog.getByText('Can only contain lower-case letters, numbers, and dashes') + ).toBeVisible() + + await certName.fill('test-cert') await certSubmit.click() // Check cert appears in the mini-table