fix: superset-ui/core code coverage (#20676)

This commit is contained in:
Yongjie Zhao 2022-07-12 13:34:27 +08:00 committed by GitHub
parent d4b59ff1ea
commit 8d4994a899
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 5 deletions

View File

@ -43,7 +43,6 @@ export default function processFilters(
const { adhoc_filters, extras = {}, filters = [], where } = formData;
const simpleWhere: QueryObjectFilterClause[] = filters;
const simpleHaving: QueryObjectFilterClause[] = [];
const freeformWhere: string[] = [];
if (where) freeformWhere.push(where);
const freeformHaving: string[] = [];
@ -54,8 +53,6 @@ export default function processFilters(
const filterClause = convertFilter(filter);
if (clause === 'WHERE') {
simpleWhere.push(filterClause);
} else {
simpleHaving.push(filterClause);
}
} else {
const { sqlExpression } = filter;

View File

@ -38,6 +38,7 @@ describe('SupersetClient', () => {
expect(typeof SupersetClient.postForm).toBe('function');
expect(typeof SupersetClient.isAuthenticated).toBe('function');
expect(typeof SupersetClient.reAuthenticate).toBe('function');
expect(typeof SupersetClient.getGuestToken).toBe('function');
expect(typeof SupersetClient.request).toBe('function');
expect(typeof SupersetClient.reset).toBe('function');
});
@ -55,7 +56,7 @@ describe('SupersetClient', () => {
// this also tests that the ^above doesn't throw if configure is called appropriately
it('calls appropriate SupersetClient methods when configured', async () => {
expect.assertions(15);
expect.assertions(16);
const mockGetUrl = '/mock/get/url';
const mockPostUrl = '/mock/post/url';
const mockRequestUrl = '/mock/request/url';
@ -82,6 +83,10 @@ describe('SupersetClient', () => {
);
const csrfSpy = jest.spyOn(SupersetClientClass.prototype, 'getCSRFToken');
const requestSpy = jest.spyOn(SupersetClientClass.prototype, 'request');
const getGuestTokenSpy = jest.spyOn(
SupersetClientClass.prototype,
'getGuestToken',
);
SupersetClient.configure({});
await SupersetClient.init();
@ -114,6 +119,9 @@ describe('SupersetClient', () => {
SupersetClient.isAuthenticated();
await SupersetClient.reAuthenticate();
SupersetClient.getGuestToken();
expect(getGuestTokenSpy).toHaveBeenCalledTimes(1);
expect(initSpy).toHaveBeenCalledTimes(2);
expect(deleteSpy).toHaveBeenCalledTimes(1);
expect(putSpy).toHaveBeenCalledTimes(1);

View File

@ -329,7 +329,7 @@ describe('SupersetClientClass', () => {
});
it('uses a guest token when provided', async () => {
expect.assertions(1);
expect.assertions(2);
const client = new SupersetClientClass({
protocol,
@ -337,6 +337,7 @@ describe('SupersetClientClass', () => {
guestToken: 'abc123',
guestTokenHeaderName: 'guestTokenHeader',
});
expect(client.getGuestToken()).toBe('abc123');
await client.init();
await client.get({ url: mockGetUrl });

View File

@ -54,6 +54,14 @@ describe('processFilters', () => {
subject: 'gender',
operator: 'IS NOT NULL',
},
// ignore simple having filter
{
expressionType: 'SIMPLE',
clause: 'HAVING',
subject: 'sum(sales)',
operator: '>',
comparator: '100',
},
],
}),
).toEqual({