From 1a4daa13fd624ed2f07d2292937f774b981fd9b6 Mon Sep 17 00:00:00 2001 From: Cody Leff Date: Fri, 2 Dec 2022 08:08:23 -0700 Subject: [PATCH] Update dashboard type tests, trigger CI. --- .../test/query/types/Dashboard.test.ts | 65 +++++++++++++------ 1 file changed, 44 insertions(+), 21 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/test/query/types/Dashboard.test.ts b/superset-frontend/packages/superset-ui-core/test/query/types/Dashboard.test.ts index ea6236338c765..2c9cde43a59a4 100644 --- a/superset-frontend/packages/superset-ui-core/test/query/types/Dashboard.test.ts +++ b/superset-frontend/packages/superset-ui-core/test/query/types/Dashboard.test.ts @@ -21,27 +21,50 @@ import { isFilterDivider, Filter, NativeFilterType, + FilterWithDataMask, + Divider, + isNativeFilterWithDataMask, } from '@superset-ui/core'; -test('should do native filter type guard', () => { - const dummyFilter: Filter = { - cascadeParentIds: [], - defaultDataMask: {}, - id: 'dummyID', - name: 'dummyName', - scope: { rootPath: [], excluded: [] }, - filterType: 'dummyType', - targets: [{}], - controlValues: {}, - type: NativeFilterType.NATIVE_FILTER, - description: 'dummyDesc', - }; - expect(isNativeFilter(dummyFilter)).toBeTruthy(); - expect( - isFilterDivider({ - ...dummyFilter, - type: NativeFilterType.DIVIDER, - title: 'dummyTitle', - }), - ).toBeTruthy(); +const filter: Filter = { + cascadeParentIds: [], + defaultDataMask: {}, + id: 'filter_id', + name: 'Filter Name', + scope: { rootPath: [], excluded: [] }, + filterType: 'filter_type', + targets: [{}], + controlValues: {}, + type: NativeFilterType.NATIVE_FILTER, + description: 'Filter description.', +}; + +const filterWithDataMask: FilterWithDataMask = { + ...filter, + dataMask: { id: 'data_mask_id', filterState: { value: 'Filter value' } }, +}; + +const filterDivider: Divider = { + id: 'divider_id', + type: NativeFilterType.DIVIDER, + title: 'Divider title', + description: 'Divider description.', +}; + +test('filter type guard', () => { + expect(isNativeFilter(filter)).toBeTruthy(); + expect(isNativeFilter(filterWithDataMask)).toBeTruthy(); + expect(isNativeFilter(filterDivider)).toBeFalsy(); +}); + +test('filter with dataMask type guard', () => { + expect(isNativeFilterWithDataMask(filter)).toBeFalsy(); + expect(isNativeFilterWithDataMask(filterWithDataMask)).toBeTruthy(); + expect(isNativeFilterWithDataMask(filterDivider)).toBeFalsy(); +}); + +test('filter divider with dataMask type guard', () => { + expect(isFilterDivider(filter)).toBeFalsy(); + expect(isFilterDivider(filterWithDataMask)).toBeFalsy(); + expect(isFilterDivider(filterDivider)).toBeTruthy(); });