You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by en...@apache.org on 2025/12/24 17:17:52 UTC

(superset) branch enxdev/fix/dataset-cration-flow created (now bcfd463748)

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

enzomartellucci pushed a change to branch enxdev/fix/dataset-cration-flow
in repository https://gitbox.apache.org/repos/asf/superset.git


      at bcfd463748 test(chart-creation): add RTL tests to handle the query mismatch case

This branch includes the following new commits:

     new 85f9fc110e fix(chart-creation): use exact match when loading dataset from URL parameter
     new bcfd463748 test(chart-creation): add RTL tests to handle the query mismatch case

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(superset) 01/02: fix(chart-creation): use exact match when loading dataset from URL parameter

Posted by en...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

enzomartellucci pushed a commit to branch enxdev/fix/dataset-cration-flow
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 85f9fc110ee8daf1f3b47d36dd1c6810c239f3e5
Author: Enzo Martellucci <en...@gmail.com>
AuthorDate: Wed Dec 24 17:54:02 2025 +0100

    fix(chart-creation): use exact match when loading dataset from URL parameter
---
 superset-frontend/src/pages/ChartCreation/index.tsx | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/superset-frontend/src/pages/ChartCreation/index.tsx b/superset-frontend/src/pages/ChartCreation/index.tsx
index 118c78c3b7..b372d6426b 100644
--- a/superset-frontend/src/pages/ChartCreation/index.tsx
+++ b/superset-frontend/src/pages/ChartCreation/index.tsx
@@ -191,7 +191,7 @@ export class ChartCreation extends PureComponent<
   componentDidMount() {
     const params = new URLSearchParams(window.location.search).get('dataset');
     if (params) {
-      this.loadDatasources(params, 0, 1).then(r => {
+      this.loadDatasources(params, 0, 1, true).then(r => {
         const datasource = r.data[0];
         this.setState({ datasource });
       });
@@ -230,7 +230,12 @@ export class ChartCreation extends PureComponent<
     }
   }
 
-  loadDatasources(search: string, page: number, pageSize: number) {
+  loadDatasources(
+    search: string,
+    page: number,
+    pageSize: number,
+    exactMatch = false,
+  ) {
     const query = rison.encode({
       columns: [
         'id',
@@ -239,7 +244,9 @@ export class ChartCreation extends PureComponent<
         'database.database_name',
         'schema',
       ],
-      filters: [{ col: 'table_name', opr: 'ct', value: search }],
+      filters: [
+        { col: 'table_name', opr: exactMatch ? 'eq' : 'ct', value: search },
+      ],
       page,
       page_size: pageSize,
       order_column: 'table_name',


(superset) 02/02: test(chart-creation): add RTL tests to handle the query mismatch case

Posted by en...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

enzomartellucci pushed a commit to branch enxdev/fix/dataset-cration-flow
in repository https://gitbox.apache.org/repos/asf/superset.git

commit bcfd463748097f4b73f0586b1d70c534a03439a3
Author: Enzo Martellucci <en...@gmail.com>
AuthorDate: Wed Dec 24 18:07:57 2025 +0100

    test(chart-creation): add RTL tests to handle the query mismatch case
---
 .../src/pages/ChartCreation/ChartCreation.test.tsx | 92 ++++++++++++++++++++++
 1 file changed, 92 insertions(+)

diff --git a/superset-frontend/src/pages/ChartCreation/ChartCreation.test.tsx b/superset-frontend/src/pages/ChartCreation/ChartCreation.test.tsx
index 5caea4df88..ef1bb687bb 100644
--- a/superset-frontend/src/pages/ChartCreation/ChartCreation.test.tsx
+++ b/superset-frontend/src/pages/ChartCreation/ChartCreation.test.tsx
@@ -193,3 +193,95 @@ test('double-click viz type submits with formatted URL if datasource is selected
   const formattedUrl = '/explore/?viz_type=table&datasource=table_1__table';
   expect(history.push).toHaveBeenCalledWith(formattedUrl);
 });
+
+test('uses contains (ct) operator for dropdown search', async () => {
+  fetchMock.reset();
+  const mockFetch = fetchMock.get(/\/api\/v1\/dataset\/\?q=.*/, {
+    body: mockDatasourceResponse,
+    status: 200,
+  });
+
+  await renderComponent();
+
+  const datasourceSelect = await screen.findByRole('combobox', {
+    name: 'Dataset',
+  });
+  userEvent.click(datasourceSelect);
+  userEvent.type(datasourceSelect, 'test');
+
+  await waitFor(() => {
+    const calls = mockFetch.calls();
+    const lastCall = calls[calls.length - 1];
+    expect(lastCall[0]).toContain('opr:ct');
+  });
+});
+
+test('uses exact match (eq) operator when loading from URL parameter', async () => {
+  fetchMock.reset();
+  const mockFetch = fetchMock.get(/\/api\/v1\/dataset\/\?q=.*/, {
+    body: mockDatasourceResponse,
+    status: 200,
+  });
+
+  const originalLocation = window.location;
+  Object.defineProperty(window, 'location', {
+    value: { ...originalLocation, search: '?dataset=flights' },
+    writable: true,
+  });
+
+  await renderComponent();
+
+  await waitFor(() => {
+    const calls = mockFetch.calls();
+    const urlParamCall = calls.find(call => call[0].includes('flights'));
+    expect(urlParamCall).toBeDefined();
+    expect(urlParamCall![0]).toContain('opr:eq');
+  });
+
+  Object.defineProperty(window, 'location', {
+    value: originalLocation,
+    writable: true,
+  });
+});
+
+test('handles special characters in dataset name from URL parameter', async () => {
+  fetchMock.reset();
+  const mockFetch = fetchMock.get(/\/api\/v1\/dataset\/\?q=.*/, {
+    body: {
+      result: [
+        {
+          id: 'special_1',
+          table_name: 'flightsÆ test',
+          datasource_type: 'table',
+          database: { database_name: 'test_db' },
+          schema: 'public',
+        },
+      ],
+      count: 1,
+    },
+    status: 200,
+  });
+
+  const originalLocation = window.location;
+  Object.defineProperty(window, 'location', {
+    value: {
+      ...originalLocation,
+      search: '?dataset=flights%C3%86%20test',
+    },
+    writable: true,
+  });
+
+  await renderComponent();
+
+  await waitFor(() => {
+    const calls = mockFetch.calls();
+    expect(calls.length).toBeGreaterThan(0);
+    const urlParamCall = calls.find(call => call[0].includes('opr:eq'));
+    expect(urlParamCall).toBeDefined();
+  });
+
+  Object.defineProperty(window, 'location', {
+    value: originalLocation,
+    writable: true,
+  });
+});