This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch chore/ts-migration-non-dashboard
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to
refs/heads/chore/ts-migration-non-dashboard by this push:
new 6a2ff340af fix(types): resolve remaining TypeScript errors in
chartActions tests
6a2ff340af is described below
commit 6a2ff340afef43d4378ed6098a9c62d2e991cd5b
Author: Evan Rusackas <[email protected]>
AuthorDate: Wed Jan 14 22:35:51 2026 -0800
fix(types): resolve remaining TypeScript errors in chartActions tests
- Use Awaited<ReturnType<...>> for async stub return type
- Fix SupersetClient.post mock implementations with proper type casting
- Use AnnotationSourceType.Native enum instead of string literal
- Add thunk action type assertion for store.dispatch calls
Co-Authored-By: Claude Opus 4.5 <[email protected]>
---
.../src/components/Chart/chartActions.test.ts | 31 ++++++++++++++--------
1 file changed, 20 insertions(+), 11 deletions(-)
diff --git a/superset-frontend/src/components/Chart/chartActions.test.ts
b/superset-frontend/src/components/Chart/chartActions.test.ts
index f63198ee20..5c3c997fd4 100644
--- a/superset-frontend/src/components/Chart/chartActions.test.ts
+++ b/superset-frontend/src/components/Chart/chartActions.test.ts
@@ -128,7 +128,7 @@ describe('chart actions', () => {
some_param: 'fake query!',
result_type: 'full',
result_format: 'json',
- } as unknown as ReturnType<typeof exploreUtils.buildV1ChartDataPayload>);
+ } as unknown as Awaited<ReturnType<typeof
exploreUtils.buildV1ChartDataPayload>>);
fakeMetadata = { useLegacyApi: true };
mockedGetChartMetadataRegistry.mockImplementation(
() =>
@@ -555,8 +555,11 @@ describe('chart actions', () => {
const key = undefined;
const postSpy = jest.spyOn(SupersetClient, 'post');
- postSpy.mockImplementation(() =>
- Promise.resolve({ json: { result: [] } } as { json: JsonObject }),
+ postSpy.mockImplementation(
+ () =>
+ Promise.resolve({ json: { result: [] } }) as unknown as ReturnType<
+ typeof SupersetClient.post
+ >,
);
const buildV1ChartDataPayloadSpy = jest.spyOn(
exploreUtils,
@@ -592,8 +595,11 @@ describe('chart actions timeout', () => {
test('should use the timeout from arguments when given', async () => {
const postSpy = jest.spyOn(SupersetClient, 'post');
- postSpy.mockImplementation(() =>
- Promise.resolve({ json: { result: [] } } as { json: JsonObject }),
+ postSpy.mockImplementation(
+ () =>
+ Promise.resolve({ json: { result: [] } }) as unknown as ReturnType<
+ typeof SupersetClient.post
+ >,
);
const timeout = 10; // Set the timeout value here
const formData: Partial<QueryFormData> = { datasource: 'table__1' }; //
Set the formData here
@@ -604,13 +610,13 @@ describe('chart actions timeout', () => {
actions.runAnnotationQuery({
annotation: {
value: 'annotationValue',
- sourceType: 'Event',
+ sourceType: AnnotationSourceType.Native,
overrides: {},
} as AnnotationLayer,
timeout,
formData: formData as QueryFormData,
key,
- }),
+ }) as unknown as actions.ChartThunkAction<Promise<void>>,
);
const expectedPayload = {
@@ -626,8 +632,11 @@ describe('chart actions timeout', () => {
test('should use the timeout from common.conf when not passed as an
argument', async () => {
const postSpy = jest.spyOn(SupersetClient, 'post');
- postSpy.mockImplementation(() =>
- Promise.resolve({ json: { result: [] } } as { json: JsonObject }),
+ postSpy.mockImplementation(
+ () =>
+ Promise.resolve({ json: { result: [] } }) as unknown as ReturnType<
+ typeof SupersetClient.post
+ >,
);
const formData: Partial<QueryFormData> = { datasource: 'table__1' }; //
Set the formData here
const key = 'chartKey'; // Set the chart key here
@@ -637,13 +646,13 @@ describe('chart actions timeout', () => {
actions.runAnnotationQuery({
annotation: {
value: 'annotationValue',
- sourceType: 'Event',
+ sourceType: AnnotationSourceType.Native,
overrides: {},
} as AnnotationLayer,
timeout: undefined,
formData: formData as QueryFormData,
key,
- }),
+ }) as unknown as actions.ChartThunkAction<Promise<void>>,
);
const expectedPayload = {