mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
[Explore view] Use POST method for charting requests (#3993)
* [Explore view] Use POST method for charting requests * fix per code review comments * more code review fixes * code review fix: remove duplicated calls for getting values from request * [Explore view] Use POST method for charting requests * fix per code review comments * more code review fixes * code review fix: remove duplicated calls for getting values from request
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import URI from 'urijs';
|
||||
import { getExploreUrl } from '../../../javascripts/explore/exploreUtils';
|
||||
import { getExploreUrlAndPayload, getExploreLongUrl } from '../../../javascripts/explore/exploreUtils';
|
||||
|
||||
describe('utils', () => {
|
||||
const location = window.location;
|
||||
const formData = {
|
||||
datasource: '1__table',
|
||||
};
|
||||
@@ -12,48 +13,129 @@ describe('utils', () => {
|
||||
expect(uri1.toString()).to.equal(uri2.toString());
|
||||
}
|
||||
|
||||
it('getExploreUrl generates proper base url', () => {
|
||||
// This assertion is to show clearly the value of location.href
|
||||
// in the context of unit tests.
|
||||
expect(location.href).to.equal('about:blank');
|
||||
describe('getExploreUrlAndPayload', () => {
|
||||
it('generates proper base url', () => {
|
||||
// This assertion is to show clearly the value of location.href
|
||||
// in the context of unit tests.
|
||||
expect(location.href).to.equal('about:blank');
|
||||
|
||||
compareURI(
|
||||
URI(getExploreUrl(formData, 'base', false, 'http://superset.com')),
|
||||
URI('/superset/explore/table/1/').search({ form_data: sFormData }),
|
||||
);
|
||||
});
|
||||
it('getExploreUrl generates proper json url', () => {
|
||||
compareURI(
|
||||
URI(getExploreUrl(formData, 'json', false, 'superset.com')),
|
||||
URI('/superset/explore_json/table/1/').search({ form_data: sFormData }),
|
||||
);
|
||||
});
|
||||
it('getExploreUrl generates proper json forced url', () => {
|
||||
compareURI(
|
||||
URI(getExploreUrl(formData, 'json', true, 'superset.com')),
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'base',
|
||||
force: false,
|
||||
curUrl: 'http://superset.com',
|
||||
});
|
||||
compareURI(
|
||||
URI(url),
|
||||
URI('/superset/explore/table/1/'),
|
||||
);
|
||||
expect(payload).to.deep.equals(formData);
|
||||
});
|
||||
it('generates proper json url', () => {
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'json',
|
||||
force: false,
|
||||
curUrl: 'http://superset.com',
|
||||
});
|
||||
compareURI(
|
||||
URI(url),
|
||||
URI('/superset/explore_json/table/1/'),
|
||||
);
|
||||
expect(payload).to.deep.equals(formData);
|
||||
});
|
||||
it('generates proper json forced url', () => {
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'json',
|
||||
force: true,
|
||||
curUrl: 'superset.com',
|
||||
});
|
||||
compareURI(
|
||||
URI(url),
|
||||
URI('/superset/explore_json/table/1/')
|
||||
.search({ form_data: sFormData, force: 'true' }),
|
||||
);
|
||||
});
|
||||
it('getExploreUrl generates proper csv URL', () => {
|
||||
compareURI(
|
||||
URI(getExploreUrl(formData, 'csv', false, 'superset.com')),
|
||||
.search({ force: 'true' }),
|
||||
);
|
||||
expect(payload).to.deep.equals(formData);
|
||||
});
|
||||
it('generates proper csv URL', () => {
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'csv',
|
||||
force: false,
|
||||
curUrl: 'superset.com',
|
||||
});
|
||||
compareURI(
|
||||
URI(url),
|
||||
URI('/superset/explore_json/table/1/')
|
||||
.search({ form_data: sFormData, csv: 'true' }),
|
||||
);
|
||||
});
|
||||
it('getExploreUrl generates proper standalone URL', () => {
|
||||
compareURI(
|
||||
URI(getExploreUrl(formData, 'standalone', false, 'superset.com')),
|
||||
.search({ csv: 'true' }),
|
||||
);
|
||||
expect(payload).to.deep.equals(formData);
|
||||
});
|
||||
it('generates proper standalone URL', () => {
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'standalone',
|
||||
force: false,
|
||||
curUrl: 'superset.com',
|
||||
});
|
||||
compareURI(
|
||||
URI(url),
|
||||
URI('/superset/explore/table/1/')
|
||||
.search({ form_data: sFormData, standalone: 'true' }),
|
||||
);
|
||||
});
|
||||
it('getExploreUrl preserves main URLs params', () => {
|
||||
compareURI(
|
||||
URI(getExploreUrl(formData, 'json', false, 'superset.com?foo=bar')),
|
||||
.search({ standalone: 'true' }),
|
||||
);
|
||||
expect(payload).to.deep.equals(formData);
|
||||
});
|
||||
it('preserves main URLs params', () => {
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'json',
|
||||
force: false,
|
||||
curUrl: 'superset.com?foo=bar',
|
||||
});
|
||||
compareURI(
|
||||
URI(url),
|
||||
URI('/superset/explore_json/table/1/')
|
||||
.search({ foo: 'bar', form_data: sFormData }),
|
||||
);
|
||||
.search({ foo: 'bar' }),
|
||||
);
|
||||
expect(payload).to.deep.equals(formData);
|
||||
});
|
||||
it('generate proper save slice url', () => {
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'json',
|
||||
force: false,
|
||||
curUrl: 'superset.com?foo=bar',
|
||||
});
|
||||
compareURI(
|
||||
URI(url),
|
||||
URI('/superset/explore_json/table/1/')
|
||||
.search({ foo: 'bar' }),
|
||||
);
|
||||
expect(payload).to.deep.equals(formData);
|
||||
});
|
||||
it('generate proper saveas slice url', () => {
|
||||
const { url, payload } = getExploreUrlAndPayload({
|
||||
formData,
|
||||
endpointType: 'json',
|
||||
force: false,
|
||||
curUrl: 'superset.com?foo=bar',
|
||||
});
|
||||
compareURI(
|
||||
URI(url),
|
||||
URI('/superset/explore_json/table/1/')
|
||||
.search({ foo: 'bar' }),
|
||||
);
|
||||
expect(payload).to.deep.equals(formData);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getExploreLongUrl', () => {
|
||||
it('generates proper base url with form_data', () => {
|
||||
compareURI(
|
||||
URI(getExploreLongUrl(formData, 'base')),
|
||||
URI('/superset/explore/table/1/').search({ form_data: sFormData }),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user