From d987d1f37c4735755bf46772c8134ac277798a1b Mon Sep 17 00:00:00 2001 From: Enzo Martellucci Date: Thu, 30 Oct 2025 18:29:50 +0100 Subject: [PATCH 1/5] fix(DatabaseModal): filter pasted text in the select against supported DB values without errors --- superset-frontend/src/features/databases/DatabaseModal/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.tsx index 57d8ee5a41f2..93476a53b752 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/index.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/index.tsx @@ -1069,6 +1069,7 @@ const DatabaseModal: FunctionComponent = ({ // eslint-disable-next-line camelcase (db: DatabaseObject) => db.name === database_name, )[0]; + if (!selectedDbModel) return; const { engine, parameters, From 41859465d4840dcde541cb3c24cca26fd6df303b Mon Sep 17 00:00:00 2001 From: Enzo Martellucci Date: Fri, 31 Oct 2025 17:17:15 +0100 Subject: [PATCH 2/5] chore:(DatabaseModal): ensure pasted text filters supported DB select correctly --- .../databases/DatabaseModal/index.test.tsx | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx index 8b3dcc222617..56b4d493ad5e 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx @@ -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'; @@ -55,7 +56,7 @@ const dbProps = { show: true, database_name: 'my database', sqlalchemy_uri: 'postgres://superset:superset@something:1234/superset', - onHide: () => {}, + onHide: () => { }, }; const DATABASE_FETCH_ENDPOINT = 'glob:*/api/v1/database/10'; @@ -423,6 +424,45 @@ describe('DatabaseModal', () => { expect(footer).toBeEmptyDOMElement(); }); + test.only('shows filtered 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'); + + // Simulate focusing the input + userEvent.click(selectInput); + + // Simulate a paste event with clipboard data + fireEvent.paste(selectInput, { + clipboardData: { + getData: () => 'post', + }, + }); + + fireEvent.change(selectInput, { target: { value: 'post' } }); + + // Wait for filtered options to appear + const options = await screen.findAllByRole('option'); + + // Ensure that only supported databases are displayed + expect( + options.some(option => + option.textContent?.toLowerCase().includes('postgres'), + ), + ).toBe(true); + + // Ensure unsupported ones are hidden + expect( + options.some(option => + option.textContent?.toLowerCase().includes('sqlite'), + ), + ).toBe(false); + }); + test('renders the "Basic" tab of SQL Alchemy form (step 2 of 2) correctly', async () => { setup(); From f00802aea5931f45b74c5250768513964513832a Mon Sep 17 00:00:00 2001 From: Enzo Martellucci Date: Fri, 31 Oct 2025 22:26:13 +0100 Subject: [PATCH 3/5] clean up --- .../src/features/databases/DatabaseModal/index.test.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx index 56b4d493ad5e..3916348a3279 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx @@ -26,7 +26,7 @@ import { userEvent, within, waitFor, - fireEvent + fireEvent, } from 'spec/helpers/testing-library'; import { getExtensionsRegistry } from '@superset-ui/core'; import setupCodeOverrides from 'src/setup/setupCodeOverrides'; @@ -56,7 +56,7 @@ const dbProps = { show: true, database_name: 'my database', sqlalchemy_uri: 'postgres://superset:superset@something:1234/superset', - onHide: () => { }, + onHide: () => {}, }; const DATABASE_FETCH_ENDPOINT = 'glob:*/api/v1/database/10'; @@ -424,7 +424,7 @@ describe('DatabaseModal', () => { expect(footer).toBeEmptyDOMElement(); }); - test.only('shows filtered database options when pasting text in the select', async () => { + test('shows filtered database options when pasting text in the select', async () => { setup(); const modal = await screen.findByRole('dialog'); From a048613d8452c966a9a21a2d30957a74885c21bb Mon Sep 17 00:00:00 2001 From: Enzo Martellucci Date: Wed, 5 Nov 2025 12:06:23 +0100 Subject: [PATCH 4/5] chore(DatabaseModalTest): simplify test related to pasting text in select --- .../databases/DatabaseModal/index.test.tsx | 36 +++++-------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx index 3916348a3279..c8c332a4d480 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx @@ -56,7 +56,7 @@ const dbProps = { show: true, database_name: 'my database', sqlalchemy_uri: 'postgres://superset:superset@something:1234/superset', - onHide: () => {}, + onHide: () => { }, }; const DATABASE_FETCH_ENDPOINT = 'glob:*/api/v1/database/10'; @@ -424,7 +424,7 @@ describe('DatabaseModal', () => { expect(footer).toBeEmptyDOMElement(); }); - test('shows filtered database options when pasting text in the select', async () => { + test('shows database options when pasting text in the select', async () => { setup(); const modal = await screen.findByRole('dialog'); @@ -432,35 +432,17 @@ describe('DatabaseModal', () => { // Find the select input (not opening the dropdown) const selectInput = screen.getByRole('combobox'); + expect(selectInput).toBeInTheDocument(); // Simulate focusing the input userEvent.click(selectInput); - // Simulate a paste event with clipboard data - fireEvent.paste(selectInput, { - clipboardData: { - getData: () => 'post', - }, - }); - - fireEvent.change(selectInput, { target: { value: 'post' } }); - - // Wait for filtered options to appear - const options = await screen.findAllByRole('option'); - - // Ensure that only supported databases are displayed - expect( - options.some(option => - option.textContent?.toLowerCase().includes('postgres'), - ), - ).toBe(true); - - // Ensure unsupported ones are hidden - expect( - options.some(option => - option.textContent?.toLowerCase().includes('sqlite'), - ), - ).toBe(false); + // 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 () => { From fbffc1d6dd8bbc8cd6304f0a9e5ca40f5ded3229 Mon Sep 17 00:00:00 2001 From: Enzo Martellucci Date: Wed, 5 Nov 2025 14:30:04 +0100 Subject: [PATCH 5/5] lint --- .../src/features/databases/DatabaseModal/index.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx index c8c332a4d480..bbdb9023b342 100644 --- a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx +++ b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx @@ -56,7 +56,7 @@ const dbProps = { show: true, database_name: 'my database', sqlalchemy_uri: 'postgres://superset:superset@something:1234/superset', - onHide: () => { }, + onHide: () => {}, }; const DATABASE_FETCH_ENDPOINT = 'glob:*/api/v1/database/10';