mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
fix: superset-ui/core code coverage (#20676)
This commit is contained in:
parent
d4b59ff1ea
commit
8d4994a899
@ -43,7 +43,6 @@ export default function processFilters(
|
|||||||
const { adhoc_filters, extras = {}, filters = [], where } = formData;
|
const { adhoc_filters, extras = {}, filters = [], where } = formData;
|
||||||
const simpleWhere: QueryObjectFilterClause[] = filters;
|
const simpleWhere: QueryObjectFilterClause[] = filters;
|
||||||
|
|
||||||
const simpleHaving: QueryObjectFilterClause[] = [];
|
|
||||||
const freeformWhere: string[] = [];
|
const freeformWhere: string[] = [];
|
||||||
if (where) freeformWhere.push(where);
|
if (where) freeformWhere.push(where);
|
||||||
const freeformHaving: string[] = [];
|
const freeformHaving: string[] = [];
|
||||||
@ -54,8 +53,6 @@ export default function processFilters(
|
|||||||
const filterClause = convertFilter(filter);
|
const filterClause = convertFilter(filter);
|
||||||
if (clause === 'WHERE') {
|
if (clause === 'WHERE') {
|
||||||
simpleWhere.push(filterClause);
|
simpleWhere.push(filterClause);
|
||||||
} else {
|
|
||||||
simpleHaving.push(filterClause);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const { sqlExpression } = filter;
|
const { sqlExpression } = filter;
|
||||||
|
@ -38,6 +38,7 @@ describe('SupersetClient', () => {
|
|||||||
expect(typeof SupersetClient.postForm).toBe('function');
|
expect(typeof SupersetClient.postForm).toBe('function');
|
||||||
expect(typeof SupersetClient.isAuthenticated).toBe('function');
|
expect(typeof SupersetClient.isAuthenticated).toBe('function');
|
||||||
expect(typeof SupersetClient.reAuthenticate).toBe('function');
|
expect(typeof SupersetClient.reAuthenticate).toBe('function');
|
||||||
|
expect(typeof SupersetClient.getGuestToken).toBe('function');
|
||||||
expect(typeof SupersetClient.request).toBe('function');
|
expect(typeof SupersetClient.request).toBe('function');
|
||||||
expect(typeof SupersetClient.reset).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
|
// this also tests that the ^above doesn't throw if configure is called appropriately
|
||||||
it('calls appropriate SupersetClient methods when configured', async () => {
|
it('calls appropriate SupersetClient methods when configured', async () => {
|
||||||
expect.assertions(15);
|
expect.assertions(16);
|
||||||
const mockGetUrl = '/mock/get/url';
|
const mockGetUrl = '/mock/get/url';
|
||||||
const mockPostUrl = '/mock/post/url';
|
const mockPostUrl = '/mock/post/url';
|
||||||
const mockRequestUrl = '/mock/request/url';
|
const mockRequestUrl = '/mock/request/url';
|
||||||
@ -82,6 +83,10 @@ describe('SupersetClient', () => {
|
|||||||
);
|
);
|
||||||
const csrfSpy = jest.spyOn(SupersetClientClass.prototype, 'getCSRFToken');
|
const csrfSpy = jest.spyOn(SupersetClientClass.prototype, 'getCSRFToken');
|
||||||
const requestSpy = jest.spyOn(SupersetClientClass.prototype, 'request');
|
const requestSpy = jest.spyOn(SupersetClientClass.prototype, 'request');
|
||||||
|
const getGuestTokenSpy = jest.spyOn(
|
||||||
|
SupersetClientClass.prototype,
|
||||||
|
'getGuestToken',
|
||||||
|
);
|
||||||
|
|
||||||
SupersetClient.configure({});
|
SupersetClient.configure({});
|
||||||
await SupersetClient.init();
|
await SupersetClient.init();
|
||||||
@ -114,6 +119,9 @@ describe('SupersetClient', () => {
|
|||||||
SupersetClient.isAuthenticated();
|
SupersetClient.isAuthenticated();
|
||||||
await SupersetClient.reAuthenticate();
|
await SupersetClient.reAuthenticate();
|
||||||
|
|
||||||
|
SupersetClient.getGuestToken();
|
||||||
|
expect(getGuestTokenSpy).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
expect(initSpy).toHaveBeenCalledTimes(2);
|
expect(initSpy).toHaveBeenCalledTimes(2);
|
||||||
expect(deleteSpy).toHaveBeenCalledTimes(1);
|
expect(deleteSpy).toHaveBeenCalledTimes(1);
|
||||||
expect(putSpy).toHaveBeenCalledTimes(1);
|
expect(putSpy).toHaveBeenCalledTimes(1);
|
||||||
|
@ -329,7 +329,7 @@ describe('SupersetClientClass', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('uses a guest token when provided', async () => {
|
it('uses a guest token when provided', async () => {
|
||||||
expect.assertions(1);
|
expect.assertions(2);
|
||||||
|
|
||||||
const client = new SupersetClientClass({
|
const client = new SupersetClientClass({
|
||||||
protocol,
|
protocol,
|
||||||
@ -337,6 +337,7 @@ describe('SupersetClientClass', () => {
|
|||||||
guestToken: 'abc123',
|
guestToken: 'abc123',
|
||||||
guestTokenHeaderName: 'guestTokenHeader',
|
guestTokenHeaderName: 'guestTokenHeader',
|
||||||
});
|
});
|
||||||
|
expect(client.getGuestToken()).toBe('abc123');
|
||||||
|
|
||||||
await client.init();
|
await client.init();
|
||||||
await client.get({ url: mockGetUrl });
|
await client.get({ url: mockGetUrl });
|
||||||
|
@ -54,6 +54,14 @@ describe('processFilters', () => {
|
|||||||
subject: 'gender',
|
subject: 'gender',
|
||||||
operator: 'IS NOT NULL',
|
operator: 'IS NOT NULL',
|
||||||
},
|
},
|
||||||
|
// ignore simple having filter
|
||||||
|
{
|
||||||
|
expressionType: 'SIMPLE',
|
||||||
|
clause: 'HAVING',
|
||||||
|
subject: 'sum(sales)',
|
||||||
|
operator: '>',
|
||||||
|
comparator: '100',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
).toEqual({
|
).toEqual({
|
||||||
|
Loading…
Reference in New Issue
Block a user