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

hainenber pushed a commit to branch use-native-codecov-merging-coverage-results
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to 
refs/heads/use-native-codecov-merging-coverage-results by this push:
     new efd9141a38a test(frontend/db): add test to cover for `executeQuery` 
function
efd9141a38a is described below

commit efd9141a38a37c754a38e88458f2a4acc7b3e572
Author: hainenber <[email protected]>
AuthorDate: Sun Jul 26 12:50:00 2026 +0700

    test(frontend/db): add test to cover for `executeQuery` function
    
    Signed-off-by: hainenber <[email protected]>
---
 superset-frontend/src/database/actions.test.ts | 67 ++++++++++++++++++++++++++
 superset-frontend/src/database/actions.ts      |  2 +-
 2 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/database/actions.test.ts 
b/superset-frontend/src/database/actions.test.ts
new file mode 100644
index 00000000000..82958ae98f6
--- /dev/null
+++ b/superset-frontend/src/database/actions.test.ts
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { executeQuery } from './actions';
+import fetchMock from 'fetch-mock';
+
+fetchMock.post('glob:*/sqllab/execute', { result: [] });
+
+afterAll(() => {
+  fetchMock.clearHistory().removeRoutes();
+});
+
+test('executeQuery', async () => {
+  const mockDispatch = jest.fn();
+  const mockedQueryExecutePayload = {
+    client_id: 'client_id_1',
+    database_id: 1,
+    runAsync: false,
+    catalog: null,
+    schema: 'schema_1',
+    sql: '1',
+    tmp_table_name: 'tmp_table_1',
+    select_as_cta: false,
+    ctas_method: 'SELECT',
+    queryLimit: 10,
+    expand_data: false,
+  };
+
+  const returnedDispatchFunc = executeQuery(mockedQueryExecutePayload);
+  await returnedDispatchFunc(mockDispatch);
+
+  const [
+    [setQueryIsLoadingActionObject],
+    [setQueryResultActionObject],
+    [setQueryIsNotLoadingActionObject],
+  ] = mockDispatch.mock.calls;
+  expect(setQueryIsLoadingActionObject).toStrictEqual({
+    type: 'SET_QUERY_IS_LOADING',
+    payload: true,
+  });
+  expect(setQueryResultActionObject).toStrictEqual({
+    type: 'SET_QUERY_RESULT',
+    payload: {
+      result: [],
+    },
+  });
+  expect(setQueryIsNotLoadingActionObject).toStrictEqual({
+    type: 'SET_QUERY_IS_LOADING',
+    payload: false,
+  });
+});
diff --git a/superset-frontend/src/database/actions.ts 
b/superset-frontend/src/database/actions.ts
index ef20594537d..fd70034dad4 100644
--- a/superset-frontend/src/database/actions.ts
+++ b/superset-frontend/src/database/actions.ts
@@ -67,7 +67,7 @@ export function executeQuery(payload: QueryExecutePayload) {
       const result = await executeQueryApi(payload);
       dispatch(setQueryResult(result as QueryExecuteResponse));
     } catch (error) {
-      dispatch(setQueryError(error.message));
+      dispatch(setQueryError((error as Error).message));
     } finally {
       dispatch(setQueryIsLoading(false));
     }

Reply via email to