diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Input.test.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Input.test.tsx new file mode 100644 index 0000000000..98e5c8c792 --- /dev/null +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Input.test.tsx @@ -0,0 +1,16 @@ +import { render } from '@testing-library/react' +import Input from './Input' + +test('Input renders correctly as password type with no autocomplete', () => { + const { asFragment, getByPlaceholderText } = render( + , + ) + const input = getByPlaceholderText('API Key') + expect(input).toHaveAttribute('type', 'password') + expect(input).not.toHaveAttribute('autocomplete') + expect(asFragment()).toMatchSnapshot() +}) diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx b/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx index a19e330315..8340faa0c3 100644 --- a/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/Input.tsx @@ -13,6 +13,7 @@ type InputProps = { min?: number max?: number } + const Input: FC = ({ value, onChange, @@ -32,23 +33,23 @@ const Input: FC = ({ onChange(`${min}`) return } - if (!isNaN(maxNum) && Number.parseFloat(v) > maxNum) onChange(`${max}`) } + return (
onChange(e.target.value)} @@ -60,13 +61,11 @@ const Input: FC = ({ min={min} max={max} /> - { - validated && ( -
- -
- ) - } + {validated && ( +
+ +
+ )}
) } diff --git a/web/app/components/header/account-setting/model-provider-page/model-modal/__snapshots__/Input.test.tsx.snap b/web/app/components/header/account-setting/model-provider-page/model-modal/__snapshots__/Input.test.tsx.snap new file mode 100644 index 0000000000..9a5fe8dd29 --- /dev/null +++ b/web/app/components/header/account-setting/model-provider-page/model-modal/__snapshots__/Input.test.tsx.snap @@ -0,0 +1,24 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Input renders correctly as password type with no autocomplete 1`] = ` + +
+ +
+
+`;