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 <[email protected]>
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,
+  });
+});

Reply via email to