fix(DatabaseModal): prevent errors when pasting text into supported database select (#35916)

This commit is contained in:
Enzo Martellucci
2025-11-05 20:38:41 +01:00
committed by GitHub
parent 32099d8f49
commit 1f960d5761
2 changed files with 23 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ import {
userEvent,
within,
waitFor,
fireEvent,
} from 'spec/helpers/testing-library';
import { getExtensionsRegistry } from '@superset-ui/core';
import setupCodeOverrides from 'src/setup/setupCodeOverrides';
@@ -423,6 +424,27 @@ describe('DatabaseModal', () => {
expect(footer).toBeEmptyDOMElement();
});
test('shows database options when pasting text in the select', async () => {
setup();
const modal = await screen.findByRole('dialog');
expect(modal).toBeInTheDocument();
// Find the select input (not opening the dropdown)
const selectInput = screen.getByRole('combobox');
expect(selectInput).toBeInTheDocument();
// Simulate focusing the input
userEvent.click(selectInput);
// Simulate pasting text into the input
expect(() =>
fireEvent.paste(selectInput, {
clipboardData: { getData: () => 'post' },
}),
).not.toThrow();
});
test('renders the "Basic" tab of SQL Alchemy form (step 2 of 2) correctly', async () => {
setup();

View File

@@ -1069,6 +1069,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
// eslint-disable-next-line camelcase
(db: DatabaseObject) => db.name === database_name,
)[0];
if (!selectedDbModel) return;
const {
engine,
parameters,