mirror of
https://github.com/apache/superset.git
synced 2026-04-14 05:34:38 +00:00
committed by
GitHub
parent
8c29ba88a4
commit
3fb183349f
@@ -55,7 +55,7 @@ const columns = [
|
||||
|
||||
const formData = {
|
||||
metric: undefined,
|
||||
metrics: [sumValueAdhocMetric, savedMetric.saved_metric_name],
|
||||
metrics: [sumValueAdhocMetric, savedMetric.metric_name],
|
||||
};
|
||||
|
||||
function setup(overrides) {
|
||||
|
||||
@@ -23,11 +23,15 @@ import Popover from 'src/common/components/Popover';
|
||||
import sinon from 'sinon';
|
||||
import { Provider } from 'react-redux';
|
||||
import configureStore from 'redux-mock-store';
|
||||
|
||||
import fetchMock from 'fetch-mock';
|
||||
import EmbedCodeButton from 'src/explore/components/EmbedCodeButton';
|
||||
import * as exploreUtils from 'src/explore/exploreUtils';
|
||||
import * as common from 'src/utils/common';
|
||||
|
||||
const ENDPOINT = 'glob:*/r/shortner/';
|
||||
|
||||
fetchMock.post(ENDPOINT, {});
|
||||
|
||||
describe('EmbedCodeButton', () => {
|
||||
const mockStore = configureStore([]);
|
||||
const store = mockStore({});
|
||||
|
||||
@@ -131,7 +131,6 @@ describe('MetricsControl', () => {
|
||||
label: 'SUM(value)',
|
||||
optionName: 'blahblahblah',
|
||||
},
|
||||
'avg__value',
|
||||
],
|
||||
});
|
||||
|
||||
@@ -149,7 +148,6 @@ describe('MetricsControl', () => {
|
||||
sqlExpression: null,
|
||||
isNew: false,
|
||||
},
|
||||
'avg__value',
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -157,7 +155,10 @@ describe('MetricsControl', () => {
|
||||
describe('onChange', () => {
|
||||
it('handles creating a new metric', () => {
|
||||
const { component, onChange } = setup();
|
||||
component.instance().onNewMetric({ metric_name: 'sum__value' });
|
||||
component.instance().onNewMetric({
|
||||
metric_name: 'sum__value',
|
||||
expression: 'SUM(energy_usage.value)',
|
||||
});
|
||||
expect(onChange.lastCall.args).toEqual([['sum__value']]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -71,6 +71,17 @@ describe('SaveModal', () => {
|
||||
value: 10,
|
||||
};
|
||||
|
||||
const mockDashboardData = {
|
||||
pks: ['id'],
|
||||
result: [{ id: 'id', dashboard_title: 'dashboard title' }],
|
||||
};
|
||||
|
||||
const saveEndpoint = `glob:*/dashboardasync/api/read?_flt_0_owners=${1}`;
|
||||
|
||||
beforeAll(() => fetchMock.get(saveEndpoint, mockDashboardData));
|
||||
|
||||
afterAll(() => fetchMock.restore());
|
||||
|
||||
const getWrapper = () =>
|
||||
shallow(<SaveModal {...defaultProps} store={store} />)
|
||||
.dive()
|
||||
@@ -183,21 +194,21 @@ describe('SaveModal', () => {
|
||||
});
|
||||
|
||||
describe('should always reload or redirect', () => {
|
||||
const originalLocation = window.location;
|
||||
delete window.location;
|
||||
window.location = { assign: jest.fn() };
|
||||
const stub = sinon.stub(window.location, 'assign');
|
||||
|
||||
afterAll(() => {
|
||||
delete window.location;
|
||||
window.location = originalLocation;
|
||||
});
|
||||
|
||||
let wrapper;
|
||||
let windowLocation;
|
||||
|
||||
beforeEach(() => {
|
||||
stub.resetHistory();
|
||||
wrapper = getWrapper();
|
||||
windowLocation = window.location;
|
||||
// To bypass "TypeError: Cannot redefine property: assign"
|
||||
Object.defineProperty(window, 'location', {
|
||||
value: { ...windowLocation, assign: () => {} },
|
||||
});
|
||||
sinon.stub(window.location, 'assign');
|
||||
});
|
||||
afterEach(() => {
|
||||
window.location.assign.restore();
|
||||
Object.defineProperty(window, 'location', windowLocation);
|
||||
});
|
||||
|
||||
it('Save & go to dashboard', () =>
|
||||
@@ -248,25 +259,9 @@ describe('SaveModal', () => {
|
||||
let actionThunk;
|
||||
const userID = 1;
|
||||
|
||||
const mockDashboardData = {
|
||||
pks: ['id'],
|
||||
result: [{ id: 'id', dashboard_title: 'dashboard title' }],
|
||||
};
|
||||
|
||||
const saveEndpoint = `glob:*/dashboardasync/api/read?_flt_0_owners=${1}`;
|
||||
|
||||
beforeAll(() => {
|
||||
fetchMock.get(saveEndpoint, mockDashboardData);
|
||||
});
|
||||
|
||||
afterAll(fetchMock.restore);
|
||||
|
||||
beforeEach(() => {
|
||||
dispatch = sinon.spy();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fetchMock.resetHistory();
|
||||
dispatch = sinon.spy();
|
||||
});
|
||||
|
||||
const makeRequest = () => {
|
||||
|
||||
@@ -155,7 +155,7 @@ describe('SelectControl', () => {
|
||||
<SelectControl
|
||||
{...defaultProps}
|
||||
multi
|
||||
value={50}
|
||||
value={['today']}
|
||||
placeholder="add something"
|
||||
/>,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user