From 3bd4c7260353b1c50f8558267c6a1946d285319d Mon Sep 17 00:00:00 2001 From: David Crespo Date: Thu, 30 Apr 2026 17:14:56 -0500 Subject: [PATCH] prevent autofill on TLS cert name field --- app/components/form/fields/TlsCertsField.tsx | 20 +++++++------------- test/e2e/silos.e2e.ts | 9 ++++++++- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/components/form/fields/TlsCertsField.tsx b/app/components/form/fields/TlsCertsField.tsx index 824f986121..1393042301 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