diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-controls/src/operators/boxplotOperator.ts b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-controls/src/operators/boxplotOperator.ts index 7ded5fc993d8..8b551fc6d1e3 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-controls/src/operators/boxplotOperator.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-chart-controls/src/operators/boxplotOperator.ts @@ -16,12 +16,7 @@ * specific language governing permissions and limitationsxw * under the License. */ -import { - PostProcessingBoxplot, - getMetricLabel, - ensureIsArray, - QueryFormColumn, -} from '@superset-ui/core'; +import { PostProcessingBoxplot, getMetricLabel, ensureIsArray } from '@superset-ui/core'; import { PostProcessingFactory } from './types'; type BoxPlotQueryObjectWhiskerType = PostProcessingBoxplot['options']['whisker_type']; @@ -31,7 +26,7 @@ export const boxplotOperator: PostProcessingFactory { - const { whiskerOptions } = formData; + const { groupby, whiskerOptions } = formData; if (whiskerOptions) { let whiskerType: BoxPlotQueryObjectWhiskerType; @@ -54,7 +49,7 @@ export const boxplotOperator: PostProcessingFactory { + expect(isPostProcessingAggregation(AGGREGATE_RULE)).toEqual(true); + expect(isPostProcessingAggregation(BOXPLOT_RULE)).toEqual(false); + expect(isPostProcessingAggregation(undefined)).toEqual(false); +}); + +test('PostProcessingBoxplot type guard', () => { + expect(isPostProcessingBoxplot(BOXPLOT_RULE)).toEqual(true); + expect(isPostProcessingBoxplot(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingBoxplot(undefined)).toEqual(false); +}); + +test('PostProcessingCompare type guard', () => { + expect(isPostProcessingCompare(COMPARE_RULE)).toEqual(true); + expect(isPostProcessingCompare(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingCompare(undefined)).toEqual(false); +}); + +test('PostProcessingContribution type guard', () => { + expect(isPostProcessingContribution(CONTRIBUTION_RULE)).toEqual(true); + expect(isPostProcessingContribution(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingContribution(undefined)).toEqual(false); +}); + +test('PostProcessingCum type guard', () => { + expect(isPostProcessingCum(CUM_RULE)).toEqual(true); + expect(isPostProcessingCum(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingCum(undefined)).toEqual(false); +}); + +test('PostProcessingDiff type guard', () => { + expect(isPostProcessingDiff(DIFF_RULE)).toEqual(true); + expect(isPostProcessingDiff(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingDiff(undefined)).toEqual(false); +}); + +test('PostProcessingPivot type guard', () => { + expect(isPostProcessingPivot(PIVOT_RULE)).toEqual(true); + expect(isPostProcessingPivot(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingPivot(undefined)).toEqual(false); +}); + +test('PostProcessingProphet type guard', () => { + expect(isPostProcessingProphet(PROPHET_RULE)).toEqual(true); + expect(isPostProcessingProphet(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingProphet(undefined)).toEqual(false); +}); + +test('PostProcessingResample type guard', () => { + expect(isPostProcessingResample(RESAMPLE_RULE)).toEqual(true); + expect(isPostProcessingResample(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingResample(undefined)).toEqual(false); +}); + +test('PostProcessingRolling type guard', () => { + expect(isPostProcessingRolling(ROLLING_RULE)).toEqual(true); + expect(isPostProcessingRolling(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingRolling(undefined)).toEqual(false); +}); + +test('PostProcessingSort type guard', () => { + expect(isPostProcessingSort(SORT_RULE)).toEqual(true); + expect(isPostProcessingSort(AGGREGATE_RULE)).toEqual(false); + expect(isPostProcessingSort(undefined)).toEqual(false); +}); diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/test/BoxPlot/buildQuery.test.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/test/BoxPlot/buildQuery.test.ts index 96d45fde4ac9..10ba3a1ec575 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/test/BoxPlot/buildQuery.test.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-chart-echarts/test/BoxPlot/buildQuery.test.ts @@ -16,6 +16,7 @@ * specific language governing permissions and limitations * under the License. */ +import { isPostProcessingBoxplot } from '@superset-ui/core'; import buildQuery from '../../src/BoxPlot/buildQuery'; import { BoxPlotQueryFormData } from '../../src/BoxPlot/types'; @@ -39,6 +40,9 @@ describe('BoxPlot buildQuery', () => { expect(query.metrics).toEqual(['foo']); expect(query.columns).toEqual(['ds', 'bar']); expect(query.series_columns).toEqual(['bar']); + const [rule] = query.post_processing || []; + expect(isPostProcessingBoxplot(rule)).toEqual(true); + expect(rule.options.groupby).toEqual(['bar']); }); it('should build non-timeseries query object when columns is defined', () => { @@ -47,5 +51,8 @@ describe('BoxPlot buildQuery', () => { expect(query.metrics).toEqual(['foo']); expect(query.columns).toEqual(['qwerty', 'bar']); expect(query.series_columns).toEqual(['bar']); + const [rule] = query.post_processing || []; + expect(isPostProcessingBoxplot(rule)).toEqual(true); + expect(rule.options.groupby).toEqual(['bar']); }); });