This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch SO-164
in repository https://gitbox.apache.org/repos/asf/superset.git

commit c8a237a9ed22e8c23f1440ef4897bf2ae80b78f1
Author: Isaac Jaynes <[email protected]>
AuthorDate: Thu Jun 18 12:39:03 2026 -0700

    fix(databases): type textAreaCss as SerializedStyles, add renderAsTextArea 
tests
---
 .../superset-ui-core/src/components/Form/types.ts  |  5 +++-
 .../DatabaseConnectionForm/EncryptedField.test.tsx | 33 ++++++++++++++++++++++
 .../DatabaseConnectionForm/EncryptedField.tsx      |  7 ++---
 3 files changed, 40 insertions(+), 5 deletions(-)

diff --git 
a/superset-frontend/packages/superset-ui-core/src/components/Form/types.ts 
b/superset-frontend/packages/superset-ui-core/src/components/Form/types.ts
index be9fc7e2268..bcf5db252bb 100644
--- a/superset-frontend/packages/superset-ui-core/src/components/Form/types.ts
+++ b/superset-frontend/packages/superset-ui-core/src/components/Form/types.ts
@@ -16,7 +16,10 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+import type { SerializedStyles } from '@emotion/react';
+
 export type { FormProps, FormInstance, FormItemProps } from 'antd/es/form';
+export type { SerializedStyles };
 
 export interface LabeledErrorBoundInputProps {
   label?: string;
@@ -32,6 +35,6 @@ export interface LabeledErrorBoundInputProps {
   visibilityToggle?: boolean;
   isValidating?: boolean;
   renderAsTextArea?: boolean;
-  textAreaCss?: any;
+  textAreaCss?: SerializedStyles;
   [x: string]: any;
 }
diff --git 
a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.test.tsx
 
b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.test.tsx
index 2215f0ef0e7..e3b069b667e 100644
--- 
a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.test.tsx
+++ 
b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.test.tsx
@@ -373,6 +373,39 @@ describe('EncryptedField', () => {
     });
   });
 
+  // eslint-disable-next-line no-restricted-globals -- TODO: Migrate from 
describe blocks
+  describe('renderAsTextArea branch', () => {
+    test('renders a textarea element (not a plain input) in edit mode', () => {
+      const props = { ...defaultProps, isEditMode: true };
+      const { container } = render(<EncryptedField {...props} />);
+
+      // renderAsTextArea causes LabeledErrorBoundInput to render <textarea>
+      expect(container.querySelector('textarea')).toBeInTheDocument();
+      expect(container.querySelector('input')).not.toBeInTheDocument();
+    });
+
+    test('renders a textarea element in copy-paste mode', () => {
+      const props = { ...defaultProps, isEditMode: false };
+      render(<EncryptedField {...props} />);
+
+      // Switch to copy-paste option to trigger renderAsTextArea branch
+      const select = screen.getByRole('combobox');
+      fireEvent.mouseDown(select);
+      fireEvent.click(screen.getByText('Copy and Paste JSON credentials'));
+
+      expect(screen.getByRole('textbox').tagName).toBe('TEXTAREA');
+    });
+
+    test('does not render a textarea when upload option is selected', () => {
+      const props = { ...defaultProps, isEditMode: false, editNewDb: false };
+      render(<EncryptedField {...props} />);
+
+      // Default upload option — no textarea should be present
+      expect(screen.queryByRole('textbox')).not.toBeInTheDocument();
+      expect(screen.getByText('Upload credentials')).toBeInTheDocument();
+    });
+  });
+
   // eslint-disable-next-line no-restricted-globals -- TODO: Migrate from 
describe blocks
   describe('Error Boundaries', () => {
     test('renders gracefully when database prop is missing', () => {
diff --git 
a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx
 
b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx
index f2830119112..834727c8d57 100644
--- 
a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx
+++ 
b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx
@@ -18,7 +18,7 @@
  */
 import { useState, useEffect } from 'react';
 import { t } from '@apache-superset/core/translation';
-import { SupersetTheme } from '@apache-superset/core/theme';
+import { SupersetTheme, useTheme } from '@apache-superset/core/theme';
 import {
   Button,
   FormLabel,
@@ -61,6 +61,7 @@ export const EncryptedField = ({
   validationErrors,
   getValidation,
 }: FieldPropTypes) => {
+  const theme = useTheme() as SupersetTheme;
   const [fileList, setFileList] = useState<UploadFile[]>([]);
   const [uploadOption, setUploadOption] = useState<number>(
     CredentialInfoOptions.JsonUpload.valueOf(),
@@ -194,9 +195,7 @@ export const EncryptedField = ({
           onChange={changeMethods.onParametersChange}
           helpText={t('Add service credentials')}
           renderAsTextArea
-          textAreaCss={(theme: SupersetTheme) =>
-            CredentialInfoFormTextArea(theme)
-          }
+          textAreaCss={CredentialInfoFormTextArea(theme)}
         />
       ) : (
         showCredentialsInfo && (

Reply via email to