mirror of https://github.com/apache/superset.git
* Fix: https://github.com/apache/incubator-superset/issues/6590, also depends on https://github.com/apache-superset/superset-ui/pull/71 * Bumped version of superset-ui-connector * Added @babel/polyfill import * Reset mock history before each test, not after each test * Update CONTRIBUTING.md
This commit is contained in:
parent
f480a52074
commit
207d9529b2
|
@ -202,7 +202,7 @@ Make sure your machine meets the [OS dependencies](https://superset.incubator.ap
|
|||
|
||||
```bash
|
||||
# Create a virtual environemnt and activate it (recommended)
|
||||
virtualenv -p python3 venv . # setup a python3.6 virtualenv
|
||||
virtualenv -p python3 venv # setup a python3.6 virtualenv
|
||||
source venv/bin/activate
|
||||
|
||||
# Install external dependencies
|
||||
|
|
|
@ -2217,17 +2217,18 @@
|
|||
}
|
||||
},
|
||||
"@superset-ui/connection": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@superset-ui/connection/-/connection-0.5.0.tgz",
|
||||
"integrity": "sha512-neac60ghZfDoDdOdNPbWO7D/xGhbkjHno9ii3HD2sgs/WQWLL25IzS/yPYVzQ7ZVrtPYPYxBiXizp/mFzqq2Yg==",
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@superset-ui/connection/-/connection-0.8.0.tgz",
|
||||
"integrity": "sha512-wxKXvG38D4fTv+10693yPMQHsTA7Q+X4n8QHiai+3e2ka/bI72tv/wHSyc0MH1C5C/YVI1TNGfsg4qi6rlePIw==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.1.2",
|
||||
"json-bigint": "^0.3.0",
|
||||
"whatwg-fetch": "^2.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"whatwg-fetch": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz",
|
||||
"integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng=="
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
"@data-ui/xy-chart": "^0.0.61",
|
||||
"@superset-ui/chart": "^0.7.0",
|
||||
"@superset-ui/color": "^0.7.0",
|
||||
"@superset-ui/connection": "^0.5.0",
|
||||
"@superset-ui/connection": "^0.8.0",
|
||||
"@superset-ui/core": "^0.7.0",
|
||||
"@superset-ui/number-format": "^0.7.2",
|
||||
"@superset-ui/time-format": "^0.7.2",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint no-native-reassign: 0 */
|
||||
import '@babel/polyfill';
|
||||
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
|
||||
import jsdom from 'jsdom';
|
||||
import { configure } from 'enzyme';
|
||||
|
|
|
@ -6,6 +6,8 @@ import * as actions from '../../../../src/SqlLab/actions/sqlLab';
|
|||
import { query } from '../fixtures';
|
||||
|
||||
describe('async actions', () => {
|
||||
const mockBigNumber = '9223372036854775807';
|
||||
|
||||
let dispatch;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -42,7 +44,7 @@ describe('async actions', () => {
|
|||
|
||||
describe('fetchQueryResults', () => {
|
||||
const fetchQueryEndpoint = 'glob:*/superset/results/*';
|
||||
fetchMock.get(fetchQueryEndpoint, '{ "data": "" }');
|
||||
fetchMock.get(fetchQueryEndpoint, '{ "data": ' + mockBigNumber + ' }');
|
||||
|
||||
const makeRequest = () => {
|
||||
const actionThunk = actions.fetchQueryResults(query);
|
||||
|
@ -65,6 +67,13 @@ describe('async actions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('parses large number result without losing precision', () =>
|
||||
makeRequest().then(() => {
|
||||
expect(fetchMock.calls(fetchQueryEndpoint)).toHaveLength(1);
|
||||
expect(dispatch.callCount).toBe(2);
|
||||
expect(dispatch.getCall(1).lastArg.results.data.toString()).toBe(mockBigNumber);
|
||||
}));
|
||||
|
||||
it('calls querySuccess on fetch success', () =>
|
||||
makeRequest().then(() => {
|
||||
expect(dispatch.callCount).toBe(2);
|
||||
|
@ -88,7 +97,7 @@ describe('async actions', () => {
|
|||
|
||||
describe('runQuery', () => {
|
||||
const runQueryEndpoint = 'glob:*/superset/sql_json/*';
|
||||
fetchMock.post(runQueryEndpoint, { data: '' });
|
||||
fetchMock.post(runQueryEndpoint, '{ "data": ' + mockBigNumber + ' }');
|
||||
|
||||
const makeRequest = () => {
|
||||
const request = actions.runQuery(query);
|
||||
|
@ -111,6 +120,13 @@ describe('async actions', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('parses large number result without losing precision', () =>
|
||||
makeRequest().then(() => {
|
||||
expect(fetchMock.calls(runQueryEndpoint)).toHaveLength(1);
|
||||
expect(dispatch.callCount).toBe(2);
|
||||
expect(dispatch.getCall(1).lastArg.results.data.toString()).toBe(mockBigNumber);
|
||||
}));
|
||||
|
||||
it('calls querySuccess on fetch success', () => {
|
||||
expect.assertions(3);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ function setup() {
|
|||
}
|
||||
|
||||
describe('DashboardTable', () => {
|
||||
afterEach(fetchMock.resetHistory);
|
||||
beforeEach(fetchMock.resetHistory);
|
||||
|
||||
it('renders a Loading initially', () => {
|
||||
const wrapper = setup();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import shortid from 'shortid';
|
||||
import JSONbig from 'json-bigint';
|
||||
import { t } from '@superset-ui/translation';
|
||||
import { SupersetClient } from '@superset-ui/connection';
|
||||
|
||||
|
@ -111,11 +110,9 @@ export function fetchQueryResults(query) {
|
|||
|
||||
return SupersetClient.get({
|
||||
endpoint: `/superset/results/${query.resultsKey}/`,
|
||||
parseMethod: 'text',
|
||||
})
|
||||
.then(({ text = '{}' }) => {
|
||||
const bigIntJson = JSONbig.parse(text);
|
||||
dispatch(querySuccess(query, bigIntJson));
|
||||
.then(({ json = {} }) => {
|
||||
dispatch(querySuccess(query, json));
|
||||
})
|
||||
.catch(response =>
|
||||
getClientErrorObject(response).then((error) => {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { List } from 'immutable';
|
||||
import PropTypes from 'prop-types';
|
||||
import JSONbig from 'json-bigint';
|
||||
import React, { PureComponent } from 'react';
|
||||
import {
|
||||
Column,
|
||||
|
@ -85,7 +86,7 @@ export default class FilterableTable extends PureComponent {
|
|||
if (['string', 'number'].indexOf(typeof (val)) >= 0) {
|
||||
newRow[k] = val;
|
||||
} else {
|
||||
newRow[k] = JSON.stringify(val);
|
||||
newRow[k] = JSONbig.stringify(val);
|
||||
}
|
||||
}
|
||||
return newRow;
|
||||
|
|
Loading…
Reference in New Issue