Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: superset-ui/core code coverage #20676

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default function processFilters(
const { adhoc_filters, extras = {}, filters = [], where } = formData;
const simpleWhere: QueryObjectFilterClause[] = filters;

const simpleHaving: QueryObjectFilterClause[] = [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussion from PR, should remove druid simpleHaving clause

const freeformWhere: string[] = [];
if (where) freeformWhere.push(where);
const freeformHaving: string[] = [];
Expand All @@ -54,8 +53,6 @@ export default function processFilters(
const filterClause = convertFilter(filter);
if (clause === 'WHERE') {
simpleWhere.push(filterClause);
} else {
simpleHaving.push(filterClause);
Comment on lines -57 to -58
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use only in native druid connector.

}
} else {
const { sqlExpression } = filter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand All @@ -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';
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,15 @@ describe('SupersetClientClass', () => {
});

it('uses a guest token when provided', async () => {
expect.assertions(1);
expect.assertions(2);

const client = new SupersetClientClass({
protocol,
host,
guestToken: 'abc123',
guestTokenHeaderName: 'guestTokenHeader',
});
expect(client.getGuestToken()).toBe('abc123');

await client.init();
await client.get({ url: mockGetUrl });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down