diff --git a/superset-frontend/packages/superset-ui-chart-controls/test/types.test.ts b/superset-frontend/packages/superset-ui-chart-controls/test/types.test.ts index abb96e62f7597..bd3197210e72e 100644 --- a/superset-frontend/packages/superset-ui-chart-controls/test/types.test.ts +++ b/superset-frontend/packages/superset-ui-chart-controls/test/types.test.ts @@ -28,6 +28,7 @@ const ADHOC_COLUMN: AdhocColumn = { hasCustomLabel: true, label: 'Adhoc column', sqlExpression: 'case when 1 = 1 then 1 else 2 end', + expressionType: 'SQL', }; const COLUMN_META: ColumnMeta = { column_name: 'my_col', diff --git a/superset-frontend/packages/superset-ui-core/package.json b/superset-frontend/packages/superset-ui-core/package.json index 28937d298ad6c..13e29e54a8c09 100644 --- a/superset-frontend/packages/superset-ui-core/package.json +++ b/superset-frontend/packages/superset-ui-core/package.json @@ -42,7 +42,6 @@ "@types/math-expression-evaluator": "^1.2.1", "@types/rison": "0.0.6", "@types/seedrandom": "^2.4.28", - "@types/tinycolor2": "^1.4.3", "@types/fetch-mock": "^7.3.3", "@types/enzyme": "^3.10.5", "@types/prop-types": "^15.7.2", @@ -71,6 +70,8 @@ "@emotion/styled": "^11.3.0", "@types/react": "*", "@types/react-loadable": "*", + "@types/tinycolor2": "*", + "tinycolor2": "*", "react": "^16.13.1", "react-loadable": "^5.5.0" } diff --git a/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts b/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts index f23ed2858d7ba..ac57561d5d2ba 100644 --- a/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts +++ b/superset-frontend/packages/superset-ui-core/src/query/types/QueryFormData.ts @@ -50,7 +50,9 @@ export type QueryFormColumn = PhysicalColumn | AdhocColumn; * Order query results by columns. * Format: [metric/column, is_ascending]. */ -export type QueryFormOrderBy = [QueryFormColumn | QueryFormMetric, boolean]; +export type QueryFormOrderBy = + | [QueryFormColumn | QueryFormMetric | {}, boolean] + | []; export interface FormDataResidual { [key: string]: any; @@ -201,7 +203,7 @@ export interface SqlaFormData extends BaseFormData { * Form data for Druid datasources. */ export interface DruidFormData extends BaseFormData { - granularity: string; + granularity?: string; having_druid?: string; druid_time_origin?: string; } diff --git a/superset-frontend/packages/superset-ui-core/test/chart/components/ChartDataProvider.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart/components/ChartDataProvider.test.tsx index ec0d73c4b8bca..2947fd9f9431a 100644 --- a/superset-frontend/packages/superset-ui-core/test/chart/components/ChartDataProvider.test.tsx +++ b/superset-frontend/packages/superset-ui-core/test/chart/components/ChartDataProvider.test.tsx @@ -119,7 +119,7 @@ describe('ChartDataProvider', () => { setup({ loadDatasource: false }); setTimeout(() => { expect(mockLoadDatasource.mock.calls).toHaveLength(0); - done(); + done(undefined); }, 0); })); @@ -132,7 +132,7 @@ describe('ChartDataProvider', () => { expect(mockLoadDatasource.mock.calls[0][0]).toEqual( props.formData.datasource, ); - done(); + done(undefined); }, 0); })); @@ -144,7 +144,7 @@ describe('ChartDataProvider', () => { setTimeout(() => { expect(mockLoadDatasource.mock.calls).toHaveLength(1); expect(mockLoadDatasource.mock.calls[0][1]).toEqual(options); - done(); + done(undefined); }, 0); })); @@ -164,7 +164,7 @@ describe('ChartDataProvider', () => { props.formData.datasource, ); expect(mockLoadDatasource.mock.calls[1][0]).toEqual(newDatasource); - done(); + done(undefined); }, 0); })); }); @@ -177,7 +177,7 @@ describe('ChartDataProvider', () => { setTimeout(() => { expect(mockLoadQueryData.mock.calls).toHaveLength(1); expect(mockLoadQueryData.mock.calls[0][0]).toEqual(props.formData); - done(); + done(undefined); }, 0); })); @@ -189,7 +189,7 @@ describe('ChartDataProvider', () => { setTimeout(() => { expect(mockLoadQueryData.mock.calls).toHaveLength(1); expect(mockLoadQueryData.mock.calls[0][1]).toEqual(options); - done(); + done(undefined); }, 0); })); @@ -204,7 +204,7 @@ describe('ChartDataProvider', () => { expect(mockLoadQueryData.mock.calls).toHaveLength(2); expect(mockLoadQueryData.mock.calls[0][0]).toEqual(props.formData); expect(mockLoadQueryData.mock.calls[1][0]).toEqual(newFormData); - done(); + done(undefined); }, 0); })); }); @@ -234,7 +234,7 @@ describe('ChartDataProvider', () => { queriesData: [props.formData], }, }); - done(); + done(undefined); }, 0); })); @@ -251,7 +251,7 @@ describe('ChartDataProvider', () => { expect(children.mock.calls[1][0]).toEqual({ error: new Error('error'), }); - done(); + done(undefined); }, 0); })); @@ -271,7 +271,7 @@ describe('ChartDataProvider', () => { expect(children.mock.calls[1][0]).toEqual({ error: new Error('non-async error'), }); - done(); + done(undefined); }, 0); })); }); @@ -290,7 +290,7 @@ describe('ChartDataProvider', () => { datasource: props.formData.datasource, queriesData: [props.formData], }); - done(); + done(undefined); }, 0); })); @@ -304,7 +304,7 @@ describe('ChartDataProvider', () => { setTimeout(() => { expect(onError.mock.calls).toHaveLength(1); expect(onError.mock.calls[0][0]).toEqual(new Error('error')); - done(); + done(undefined); }, 0); })); @@ -323,7 +323,7 @@ describe('ChartDataProvider', () => { expect(onError.mock.calls[0][0]).toEqual( new Error('non-async error'), ); - done(); + done(undefined); }, 0); })); }); diff --git a/superset-frontend/packages/superset-ui-core/test/chart/components/createLoadableRenderer.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart/components/createLoadableRenderer.test.tsx index 34ab7a3cc6990..b1eecf5f87fa1 100644 --- a/superset-frontend/packages/superset-ui-core/test/chart/components/createLoadableRenderer.test.tsx +++ b/superset-frontend/packages/superset-ui-core/test/chart/components/createLoadableRenderer.test.tsx @@ -106,7 +106,7 @@ describe('createLoadableRenderer', () => { expect(render).not.toHaveBeenCalled(); expect(onRenderSuccess).not.toHaveBeenCalled(); expect(onRenderFailure).toHaveBeenCalledTimes(1); - done(); + done(undefined); }, 10); })); @@ -126,7 +126,7 @@ describe('createLoadableRenderer', () => { expect(loadChartFailure).toHaveBeenCalledTimes(1); setTimeout(() => { expect(render).not.toHaveBeenCalled(); - done(); + done(undefined); }, 10); })); @@ -138,7 +138,7 @@ describe('createLoadableRenderer', () => { setTimeout(() => { // but rendered after the component is loaded. expect(wrapper.find(TestComponent)).toHaveLength(1); - done(); + done(undefined); }, 10); })); diff --git a/superset-frontend/packages/superset-ui-core/test/chart/components/reactify.test.tsx b/superset-frontend/packages/superset-ui-core/test/chart/components/reactify.test.tsx index 121f815c4cc4f..3277a6fece55e 100644 --- a/superset-frontend/packages/superset-ui-core/test/chart/components/reactify.test.tsx +++ b/superset-frontend/packages/superset-ui-core/test/chart/components/reactify.test.tsx @@ -86,7 +86,7 @@ describe('reactify(renderFn)', () => { expect(renderFn).toHaveBeenCalledTimes(2); expect(wrapper.html()).toEqual('
def
'); wrapper.unmount(); - done(); + done(undefined); }, 20); })); describe('displayName', () => { @@ -140,7 +140,7 @@ describe('reactify(renderFn)', () => { setTimeout(() => { wrapper.unmount(); expect(willUnmountCb).toHaveBeenCalledTimes(1); - done(); + done(undefined); }, 20); })); }); diff --git a/superset-frontend/packages/superset-ui-core/test/connection/callApi/callApi.test.ts b/superset-frontend/packages/superset-ui-core/test/connection/callApi/callApi.test.ts index 254883333af3a..81467ce2393a9 100644 --- a/superset-frontend/packages/superset-ui-core/test/connection/callApi/callApi.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/connection/callApi/callApi.test.ts @@ -93,7 +93,7 @@ describe('callApi()', () => { await callApi(mockRequest); const calls = fetchMock.calls(mockGetUrl); - const fetchParams = calls[0][1]; + const fetchParams = calls[0][1] as RequestInit; expect(calls).toHaveLength(1); expect(fetchParams.mode).toBe(mockRequest.mode); expect(fetchParams.cache).toBe(mockRequest.cache); @@ -118,7 +118,7 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPostUrl); expect(calls).toHaveLength(1); - const fetchParams = calls[0][1]; + const fetchParams = calls[0][1] as RequestInit; const body = fetchParams.body as FormData; Object.entries(postPayload).forEach(([key, value]) => { @@ -135,7 +135,7 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPostUrl); expect(calls).toHaveLength(1); - const fetchParams = calls[0][1]; + const fetchParams = calls[0][1] as RequestInit; const body = fetchParams.body as FormData; expect(body.get('key')).toBe(JSON.stringify(postPayload.key)); expect(body.get('noValue')).toBeNull(); @@ -166,10 +166,10 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPostUrl); expect(calls).toHaveLength(3); - const stringified = calls[0][1].body as FormData; - const unstringified = calls[1][1].body as FormData; + const stringified = (calls[0][1] as RequestInit).body as FormData; + const unstringified = (calls[1][1] as RequestInit).body as FormData; const jsonRequestBody = JSON.parse( - calls[2][1].body as string, + (calls[2][1] as RequestInit).body as string, ) as JsonObject; Object.entries(postPayload).forEach(([key, value]) => { @@ -189,7 +189,7 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPutUrl); expect(calls).toHaveLength(1); - const fetchParams = calls[0][1]; + const fetchParams = calls[0][1] as RequestInit; const body = fetchParams.body as FormData; Object.entries(postPayload).forEach(([key, value]) => { @@ -206,7 +206,7 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPutUrl); expect(calls).toHaveLength(1); - const fetchParams = calls[0][1]; + const fetchParams = calls[0][1] as RequestInit; const body = fetchParams.body as FormData; expect(body.get('key')).toBe(JSON.stringify(postPayload.key)); expect(body.get('noValue')).toBeNull(); @@ -236,8 +236,8 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPutUrl); expect(calls).toHaveLength(2); - const stringified = calls[0][1].body as FormData; - const unstringified = calls[1][1].body as FormData; + const stringified = (calls[0][1] as RequestInit).body as FormData; + const unstringified = (calls[1][1] as RequestInit).body as FormData; Object.entries(postPayload).forEach(([key, value]) => { expect(stringified.get(key)).toBe(JSON.stringify(value)); @@ -255,7 +255,7 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPatchUrl); expect(calls).toHaveLength(1); - const fetchParams = calls[0][1]; + const fetchParams = calls[0][1] as RequestInit; const body = fetchParams.body as FormData; Object.entries(postPayload).forEach(([key, value]) => { @@ -272,7 +272,7 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPatchUrl); expect(calls).toHaveLength(1); - const fetchParams = calls[0][1]; + const fetchParams = calls[0][1] as RequestInit; const body = fetchParams.body as FormData; expect(body.get('key')).toBe(JSON.stringify(postPayload.key)); expect(body.get('noValue')).toBeNull(); @@ -302,8 +302,8 @@ describe('callApi()', () => { const calls = fetchMock.calls(mockPatchUrl); expect(calls).toHaveLength(2); - const stringified = calls[0][1].body as FormData; - const unstringified = calls[1][1].body as FormData; + const stringified = (calls[0][1] as RequestInit).body as FormData; + const unstringified = (calls[1][1] as RequestInit).body as FormData; Object.entries(postPayload).forEach(([key, value]) => { expect(stringified.get(key)).toBe(JSON.stringify(value)); @@ -366,7 +366,7 @@ describe('callApi()', () => { url: mockCacheUrl, method: 'GET', }); - const fetchParams = calls[1][1]; + const fetchParams = calls[1][1] as RequestInit; expect(calls).toHaveLength(2); // second call should not have If-None-Match header expect(fetchParams.headers).toBeUndefined(); @@ -386,7 +386,7 @@ describe('callApi()', () => { // second call sends the Etag in the If-None-Match header await callApi({ url: mockCacheUrl, method: 'GET' }); - const fetchParams = calls[1][1]; + const fetchParams = calls[1][1] as RequestInit; const headers = { 'If-None-Match': 'etag' }; expect(calls).toHaveLength(2); expect(fetchParams.headers).toEqual( @@ -591,7 +591,7 @@ describe('callApi()', () => { method: 'POST', postPayload: payload, }); - expect(fetchMock.lastOptions().body).toBe(payload); + expect(fetchMock.lastOptions()?.body).toBe(payload); }); it('should ignore "null" postPayload string', async () => { @@ -602,6 +602,6 @@ describe('callApi()', () => { method: 'POST', postPayload: 'null', }); - expect(fetchMock.lastOptions().body).toBeUndefined(); + expect(fetchMock.lastOptions()?.body).toBeUndefined(); }); }); diff --git a/superset-frontend/packages/superset-ui-core/test/query/api/v1/makeApi.test.ts b/superset-frontend/packages/superset-ui-core/test/query/api/v1/makeApi.test.ts index 774a11ed0852f..899011b2811d1 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/api/v1/makeApi.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/api/v1/makeApi.test.ts @@ -95,7 +95,7 @@ describe('makeApi()', () => { const expected = new FormData(); expected.append('request', JSON.stringify('test')); - const received = fetchMock.lastOptions().body as FormData; + const received = fetchMock.lastOptions()?.body as FormData; expect(received).toBeInstanceOf(FormData); expect(received.get('request')).toEqual(expected.get('request')); diff --git a/superset-frontend/packages/superset-ui-core/test/query/buildQueryObject.test.ts b/superset-frontend/packages/superset-ui-core/test/query/buildQueryObject.test.ts index b2ee6f579d5c1..b8da644653fce 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/buildQueryObject.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/buildQueryObject.test.ts @@ -227,6 +227,7 @@ describe('buildQueryObject', () => { name: 'My Formula', opacity: AnnotationOpacity.Low, show: true, + showLabel: false, style: AnnotationStyle.Solid, value: '10*sin(x)', width: 1, @@ -235,6 +236,7 @@ describe('buildQueryObject', () => { annotationType: AnnotationType.Interval, color: null, show: false, + showLabel: false, name: 'My Interval', sourceType: AnnotationSourceType.Native, style: AnnotationStyle.Dashed, @@ -253,6 +255,7 @@ describe('buildQueryObject', () => { }, sourceType: AnnotationSourceType.Table, show: false, + showLabel: false, timeColumn: 'ds', style: AnnotationStyle.Dashed, value: 1, diff --git a/superset-frontend/packages/superset-ui-core/test/query/getColumnLabel.test.ts b/superset-frontend/packages/superset-ui-core/test/query/getColumnLabel.test.ts index aadde6e4b557f..e0e65c4332434 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/getColumnLabel.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/getColumnLabel.test.ts @@ -28,6 +28,7 @@ describe('getColumnLabel', () => { getColumnLabel({ sqlExpression: "case when 1 then 'a' else 'b' end", label: 'my col', + expressionType: 'SQL', }), ).toEqual('my col'); }); @@ -36,6 +37,7 @@ describe('getColumnLabel', () => { expect( getColumnLabel({ sqlExpression: "case when 1 then 'a' else 'b' end", + expressionType: 'SQL', }), ).toEqual("case when 1 then 'a' else 'b' end"); }); diff --git a/superset-frontend/packages/superset-ui-core/test/query/normalizeOrderBy.test.ts b/superset-frontend/packages/superset-ui-core/test/query/normalizeOrderBy.test.ts index a32aa4994a58e..57b186a1297ee 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/normalizeOrderBy.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/normalizeOrderBy.test.ts @@ -183,6 +183,7 @@ describe('normalizeOrderBy', () => { datasource: '5__table', viz_type: 'table', time_range: '1 year ago : 2013', + // @ts-ignore orderby: [['count(*)', 'true']], }; expect(normalizeOrderBy(query)).not.toHaveProperty('orderby'); diff --git a/superset-frontend/packages/superset-ui-core/test/query/processExtraFormData.test.ts b/superset-frontend/packages/superset-ui-core/test/query/processExtraFormData.test.ts index 871218bfd55ed..136a45803e88f 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/processExtraFormData.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/processExtraFormData.test.ts @@ -94,7 +94,7 @@ describe('overrideExtraFormData', () => { time_grain_sqla: 'PT1H', }, }, - { time_grain_sqla: 'PT2H' }, + { time_grain_sqla: 'P1D' }, ), ).toEqual({ granularity: 'something', @@ -102,7 +102,7 @@ describe('overrideExtraFormData', () => { datasource: 'table_1', time_range: '100 years ago', extras: { - time_grain_sqla: 'PT2H', + time_grain_sqla: 'P1D', }, }); }); diff --git a/superset-frontend/packages/superset-ui-core/test/query/types/PostProcessing.test.ts b/superset-frontend/packages/superset-ui-core/test/query/types/PostProcessing.test.ts index 63394f536cc7e..1d7d9f044e5d3 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/types/PostProcessing.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/types/PostProcessing.test.ts @@ -92,7 +92,6 @@ const CUM_RULE: PostProcessingCum = { options: { columns: ['foo'], operator: 'min', - is_pivot_df: true, }, }; @@ -134,7 +133,6 @@ const RESAMPLE_RULE: PostProcessingResample = { method: 'method', rule: 'rule', fill_value: null, - time_column: 'foo', }, }; @@ -145,7 +143,6 @@ const ROLLING_RULE: PostProcessingRolling = { window: 12, min_periods: 12, columns: ['foo', 'bar'], - is_pivot_df: true, }, }; diff --git a/superset-frontend/tsconfig.json b/superset-frontend/tsconfig.json index f67b47cdfe624..a040843986bae 100644 --- a/superset-frontend/tsconfig.json +++ b/superset-frontend/tsconfig.json @@ -62,12 +62,16 @@ /* Completeness */ "skipLibCheck": true }, + "exclude": [ + "./packages/generator-superset/test/**/*" + ], "include": [ "./src/**/*", "./spec/**/*", "./packages/*/src/**/*", "./packages/*/types/**/*", "./plugins/*/src/**/*", - "./plugins/*/types/**/*" + "./plugins/*/types/**/*", + "./packages/*/test/**/*" ] }