feat: apply Time Grain to X-Axis column (#21163)

This commit is contained in:
Yongjie Zhao
2022-09-07 16:24:15 +08:00
committed by GitHub
parent 875e9f8a04
commit ce3d38d2e7
24 changed files with 705 additions and 29 deletions

View File

@@ -17,6 +17,7 @@
* under the License.
*/
import { buildQueryContext } from '@superset-ui/core';
import * as queryModule from '../../src/query/normalizeTimeColumn';
describe('buildQueryContext', () => {
it('should build datasource for table sources and apply defaults', () => {
@@ -122,4 +123,50 @@ describe('buildQueryContext', () => {
},
]);
});
it('should call normalizeTimeColumn if GENERIC_CHART_AXES is enabled', () => {
// @ts-ignore
const spy = jest.spyOn(window, 'window', 'get').mockImplementation(() => ({
featureFlags: {
GENERIC_CHART_AXES: true,
},
}));
const spyNormalizeTimeColumn = jest.spyOn(
queryModule,
'normalizeTimeColumn',
);
buildQueryContext(
{
datasource: '5__table',
viz_type: 'table',
},
() => [{}],
);
expect(spyNormalizeTimeColumn).toBeCalled();
spy.mockRestore();
spyNormalizeTimeColumn.mockRestore();
});
it("shouldn't call normalizeTimeColumn if GENERIC_CHART_AXES is disabled", () => {
// @ts-ignore
const spy = jest.spyOn(window, 'window', 'get').mockImplementation(() => ({
featureFlags: {
GENERIC_CHART_AXES: false,
},
}));
const spyNormalizeTimeColumn = jest.spyOn(
queryModule,
'normalizeTimeColumn',
);
buildQueryContext(
{
datasource: '5__table',
viz_type: 'table',
},
() => [{}],
);
expect(spyNormalizeTimeColumn).not.toBeCalled();
spy.mockRestore();
spyNormalizeTimeColumn.mockRestore();
});
});