diff --git a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx index 147b983c455a3..ad80699802e62 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/DatabaseConnectionForm/EncryptedField.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import { useState } from 'react'; +import { useRef, useState } from 'react'; import { SupersetTheme, t } from '@superset-ui/core'; import { Button, AntdSelect } from 'src/components'; import InfoTooltip from 'src/components/InfoTooltip'; @@ -46,6 +46,7 @@ export const EncryptedField = ({ db, editNewDb, }: FieldPropTypes) => { + const selectedFileInputRef = useRef(null); const [uploadOption, setUploadOption] = useState( CredentialInfoOptions.JsonUpload.valueOf(), ); @@ -152,9 +153,7 @@ export const EncryptedField = ({ {!fileToUpload && ( @@ -178,6 +177,7 @@ export const EncryptedField = ({ )} diff --git a/superset-frontend/src/features/databases/UploadDataModel/UploadDataModal.test.tsx b/superset-frontend/src/features/databases/UploadDataModel/UploadDataModal.test.tsx index 5a3958e00a836..34bebac917ce3 100644 --- a/superset-frontend/src/features/databases/UploadDataModel/UploadDataModal.test.tsx +++ b/superset-frontend/src/features/databases/UploadDataModel/UploadDataModal.test.tsx @@ -622,7 +622,7 @@ test('CSV form post', async () => { // Select a file from the file dialog const file = new File(['test'], 'test.csv', { type: 'text' }); - const inputElement = document.querySelector('input[type="file"]'); + const inputElement = screen.getByTestId('model-file-input'); if (inputElement) { userEvent.upload(inputElement as HTMLElement, file); @@ -680,7 +680,7 @@ test('Excel form post', async () => { // Select a file from the file dialog const file = new File(['test'], 'test.xls', { type: 'text' }); - const inputElement = document.querySelector('input[type="file"]'); + const inputElement = screen.getByTestId('model-file-input'); if (inputElement) { userEvent.upload(inputElement as HTMLElement, file); @@ -738,7 +738,7 @@ test('Columnar form post', async () => { // Select a file from the file dialog const file = new File(['test'], 'test.parquet', { type: 'text' }); - const inputElement = document.querySelector('input[type="file"]'); + const inputElement = screen.getByTestId('model-file-input'); if (inputElement) { userEvent.upload(inputElement as HTMLElement, file);