williaster commented on a change in pull request #3993: [Explore view] Use POST 
method for charting requests
URL: 
https://github.com/apache/incubator-superset/pull/3993#discussion_r161937950
 
 

 ##########
 File path: superset/assets/spec/javascripts/explore/utils_spec.jsx
 ##########
 @@ -12,48 +13,124 @@ describe('utils', () => {
     expect(uri1.toString()).to.equal(uri2.toString());
   }
 
-  it('getExploreUrl generates proper base url', () => {
+  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');
 
+    const { url, payload } = getExploreUrlAndPayload({
+      formData,
+      endpointType: 'base',
+      force: false,
+      curUrl: 'http://superset.com',
+    });
     compareURI(
-        URI(getExploreUrl(formData, 'base', false, 'http://superset.com')),
-        URI('/superset/explore/table/1/').search({ form_data: sFormData }),
+        URI(url),
+        URI('/superset/explore/table/1/'),
     );
+    expect(payload).to.deep.equals(formData);
   });
-  it('getExploreUrl generates proper json url', () => {
+  it('generates proper json url', () => {
+    const { url, payload } = getExploreUrlAndPayload({
+      formData,
+      endpointType: 'json',
+      force: false,
+      curUrl: 'http://superset.com',
+    });
     compareURI(
-        URI(getExploreUrl(formData, 'json', false, 'superset.com')),
-        URI('/superset/explore_json/table/1/').search({ form_data: sFormData 
}),
+        URI(url),
+        URI('/superset/explore_json/table/1/'),
     );
+    expect(payload).to.deep.equals(formData);
   });
-  it('getExploreUrl generates proper json forced url', () => {
+  it('generates proper json forced url', () => {
+    const { url, payload } = getExploreUrlAndPayload({
+      formData,
+      endpointType: 'json',
+      force: true,
+      curUrl: 'superset.com',
+    });
     compareURI(
-        URI(getExploreUrl(formData, 'json', true, 'superset.com')),
+        URI(url),
         URI('/superset/explore_json/table/1/')
-          .search({ form_data: sFormData, force: 'true' }),
+          .search({ force: 'true' }),
     );
+    expect(payload).to.deep.equals(formData);
   });
-  it('getExploreUrl generates proper csv URL', () => {
+  it('generates proper csv URL', () => {
+    const { url, payload } = getExploreUrlAndPayload({
+      formData,
+      endpointType: 'csv',
+      force: false,
+      curUrl: 'superset.com',
+    });
     compareURI(
-        URI(getExploreUrl(formData, 'csv', false, 'superset.com')),
+        URI(url),
         URI('/superset/explore_json/table/1/')
-          .search({ form_data: sFormData, csv: 'true' }),
+          .search({ csv: 'true' }),
     );
+    expect(payload).to.deep.equals(formData);
   });
-  it('getExploreUrl generates proper standalone URL', () => {
+  it('generates proper standalone URL', () => {
+    const { url, payload } = getExploreUrlAndPayload({
+      formData,
+      endpointType: 'standalone',
+      force: false,
+      curUrl: 'superset.com',
+    });
     compareURI(
-        URI(getExploreUrl(formData, 'standalone', false, 'superset.com')),
+        URI(url),
         URI('/superset/explore/table/1/')
-          .search({ form_data: sFormData, standalone: 'true' }),
+          .search({ standalone: 'true' }),
     );
+    expect(payload).to.deep.equals(formData);
   });
-  it('getExploreUrl preserves main URLs params', () => {
+  it('preserves main URLs params', () => {
+    const { url, payload } = getExploreUrlAndPayload({
+      formData,
+      endpointType: 'json',
+      force: false,
+      curUrl: 'superset.com?foo=bar',
+    });
     compareURI(
-        URI(getExploreUrl(formData, 'json', false, 'superset.com?foo=bar')),
+        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);
+  });
+  it('getExploreLongUrl generates proper base url with form_data', () => {
+    compareURI(
+      URI(getExploreLongUrl(formData, 'base', false, 'http://superset.com')),
 
 Review comment:
   are the last two arguments used by the `getExploreLongUrl ` func? I think 
functions that take an object are much less error-prone than relying on 
positional arguments.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to