Compare commits

...

2 Commits

Author SHA1 Message Date
hainenber
efd9141a38 test(frontend/db): add test to cover for executeQuery function
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-07-26 12:50:00 +07:00
hainenber
d0b422638e chore(ci): remove nyc usage for merging coverage results as Codecov natively supports the action
Signed-off-by: hainenber <dotronghai96@gmail.com>
2026-07-26 11:57:45 +07:00
3 changed files with 69 additions and 14 deletions

View File

@@ -122,25 +122,13 @@ jobs:
pattern: coverage-artifacts-*
path: coverage/
- name: Reorganize test result reports
run: |
find coverage/
for i in {1..8}; do
mv coverage/coverage-artifacts-${i}/coverage-final.json coverage/coverage-shard-${i}.json
done
shell: bash
- name: Merge Code Coverage
run: npx nyc merge coverage/ merged-output/coverage-summary.json
- name: Upload Code Coverage
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
flags: javascript
use_oidc: true
verbose: true
disable_search: true
files: merged-output/coverage-summary.json
directory: coverage
slug: apache/superset
lint-frontend:

View File

@@ -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,
});
});

View File

@@ -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));
}