updating tests with to reduce warnings and support AI server side
This commit is contained in:
Родитель
6d92e73cb9
Коммит
abe20af83a
|
@ -7,6 +7,7 @@ import utils from '../utils';
|
|||
interface IConfigurationsActions {
|
||||
loadConfiguration(): any;
|
||||
loadDashboard(id: string): any;
|
||||
loadDashboardComplete(dashboard: IDashboardConfig): any;
|
||||
createDashboard(dashboard: IDashboardConfig): any;
|
||||
loadTemplate(id: string): any;
|
||||
saveConfiguration(dashboard: IDashboardConfig): any;
|
||||
|
@ -71,19 +72,20 @@ class ConfigurationsActions extends AbstractActions implements IConfigurationsAc
|
|||
|
||||
loadDashboard(id: string) {
|
||||
|
||||
return (dispatcher: (result: { dashboard: IDashboardConfig }) => void) => {
|
||||
|
||||
(window as any)['dashboard'] = undefined;
|
||||
this.getScript('/api/dashboards/' + id, () => {
|
||||
let dashboard: IDashboardConfig = (window as any)['dashboard'];
|
||||
(window as any)['dashboard'] = undefined;
|
||||
this.getScript('/api/dashboards/' + id, () => {
|
||||
let dashboard: IDashboardConfig = (window as any)['dashboard'];
|
||||
|
||||
if (!dashboard) {
|
||||
return this.failure(new Error('Could not load configuration for dashboard ' + id));
|
||||
}
|
||||
if (!dashboard) {
|
||||
return this.failure(new Error('Could not load configuration for dashboard ' + id));
|
||||
}
|
||||
|
||||
return dispatcher({ dashboard });
|
||||
});
|
||||
};
|
||||
return this.loadDashboardComplete(dashboard);
|
||||
});
|
||||
}
|
||||
|
||||
loadDashboardComplete(dashboard: IDashboardConfig): any {
|
||||
return { dashboard };
|
||||
}
|
||||
|
||||
createDashboard(dashboard: IDashboardConfig) {
|
||||
|
|
|
@ -44,7 +44,7 @@ class ConfigurationsStore extends AbstractStoreModel<IConfigurationsStoreState>
|
|||
|
||||
this.bindListeners({
|
||||
loadConfiguration: configurationActions.loadConfiguration,
|
||||
loadDashboard: configurationActions.loadDashboard,
|
||||
loadDashboardComplete: configurationActions.loadDashboardComplete,
|
||||
loadTemplate: configurationActions.loadTemplate,
|
||||
createDashboard: configurationActions.createDashboard,
|
||||
failure: configurationActions.failure
|
||||
|
@ -69,15 +69,16 @@ class ConfigurationsStore extends AbstractStoreModel<IConfigurationsStoreState>
|
|||
this.templates = templates;
|
||||
}
|
||||
|
||||
loadDashboard(result: { dashboard: IDashboardConfig }) {
|
||||
loadDashboardComplete(result: { dashboard: IDashboardConfig }) {
|
||||
let { dashboard } = result;
|
||||
this.dashboard = dashboard;
|
||||
|
||||
if (this.dashboard && !this.loaded) {
|
||||
|
||||
DataSourceConnector.createDataSources(dashboard, dashboard.config.connections);
|
||||
|
||||
|
||||
this.connections = this.getConnections(dashboard);
|
||||
|
||||
|
||||
// Checking for missing connection params
|
||||
this.connectionsMissing = Object.keys(this.connections).some(connectionKey => {
|
||||
var connection = this.connections[connectionKey];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import TokenInput from '../../components/common/TokenInput';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
describe('Info drawer', () => {
|
||||
let tokenInput;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import InfoDrawer from '../../components/common/InfoDrawer';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
describe('Info drawer', () => {
|
||||
let infoDrawer;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { IDataSourceDictionary } from '../../data-sources';
|
||||
import { setupTests } from '../utils/setup';
|
||||
import Sample from '../../data-sources/plugins/Sample';
|
||||
|
||||
import { formatTests } from './formats';
|
||||
|
@ -7,7 +6,7 @@ import * as formats from '../../utils/data-formats';
|
|||
|
||||
describe('Data Formats', () => {
|
||||
|
||||
let sampleMockPlugin = new Sample(<any>{
|
||||
let sampleMockPlugin = new Sample(<any> {
|
||||
params: {
|
||||
values: [ 'value 1', 'value 2', 'value 3' ],
|
||||
samples: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { IDataSourceDictionary } from '../../data-sources';
|
||||
import { setupTests } from '../utils/setup';
|
||||
|
@ -16,10 +16,11 @@ describe('Data Source: Application Insights: Query', () => {
|
|||
let element;
|
||||
|
||||
beforeAll(done => {
|
||||
|
||||
mockRequests();
|
||||
element = TestUtils.renderIntoDocument(<Toast />);
|
||||
TestUtils.isElementOfType(element, 'div');
|
||||
dataSources = setupTests(dashboardMock, done);
|
||||
setupTests(dashboardMock, ds => dataSources = ds, () => setTimeout(done, 100));
|
||||
});
|
||||
|
||||
it ('Query for 30 months with data rows', () => {
|
||||
|
|
|
@ -9,10 +9,10 @@ describe('Data Source: Application Insights: Forked Query', () => {
|
|||
|
||||
let dataSources: IDataSourceDictionary = {};
|
||||
|
||||
beforeAll(() => {
|
||||
beforeAll((done) => {
|
||||
|
||||
mockRequests();
|
||||
dataSources = setupTests(dashboardMock);
|
||||
setupTests(dashboardMock, ds => dataSources = ds, done);
|
||||
});
|
||||
|
||||
it ('Query for 30 months with data rows', () => {
|
||||
|
|
|
@ -9,10 +9,10 @@ describe('Data Source: Application Insights: Query', () => {
|
|||
|
||||
let dataSources: IDataSourceDictionary = {};
|
||||
|
||||
beforeAll(() => {
|
||||
beforeAll((done) => {
|
||||
|
||||
mockRequests();
|
||||
dataSources = setupTests(dashboardMock);
|
||||
setupTests(dashboardMock, ds => dataSources = ds, done);
|
||||
});
|
||||
|
||||
it ('Query for 30 months with data rows', () => {
|
||||
|
|
|
@ -6,8 +6,8 @@ describe('Data Source: Constant', () => {
|
|||
|
||||
let dataSources: IDataSourceDictionary;
|
||||
|
||||
beforeAll((done) => {
|
||||
dataSources = setupTests(dashboardMock, done);
|
||||
beforeAll(done => {
|
||||
setupTests(dashboardMock, ds => dataSources = ds, () => setTimeout(done, 100));
|
||||
});
|
||||
|
||||
it ('Check basic data == 3 rows', () => {
|
||||
|
|
|
@ -9,9 +9,9 @@ describe('Data Source: CosmosDB: Query', () => {
|
|||
|
||||
let dataSources: IDataSourceDictionary = {};
|
||||
|
||||
beforeAll(() => {
|
||||
beforeAll(done => {
|
||||
mockRequests();
|
||||
dataSources = setupTests(dashboardMock);
|
||||
setupTests(dashboardMock, ds => dataSources = ds, done);
|
||||
});
|
||||
|
||||
it('Query for data', () => {
|
||||
|
|
|
@ -9,10 +9,9 @@ describe('Data Source: DirectLine: Query', () => {
|
|||
|
||||
let dataSources: IDataSourceDictionary = {};
|
||||
|
||||
beforeAll(() => {
|
||||
|
||||
beforeAll(done => {
|
||||
mockRequests();
|
||||
dataSources = setupTests(dashboardMock);
|
||||
setupTests(dashboardMock, ds => dataSources = ds, done);
|
||||
});
|
||||
|
||||
it ('Query for data', () => {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import { IDataSourceDictionary } from '../../data-sources';
|
||||
import { setupTests } from '../utils/setup';
|
||||
import dashboardMock from '../mocks/dashboards/samples';
|
||||
import { setTimeout } from 'timers';
|
||||
|
||||
describe('Data Source: Samples', () => {
|
||||
|
||||
let dataSources: IDataSourceDictionary;
|
||||
|
||||
beforeAll((done) => {
|
||||
dataSources = setupTests(dashboardMock, done);
|
||||
beforeAll(done => {
|
||||
setupTests(dashboardMock, ds => dataSources = ds, () => setTimeout(done, 100));
|
||||
});
|
||||
|
||||
it ('Check basic data == 3 rows', () => {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Dialog, DialogsActions, loadDialogsFromDashboard } from '../../components/generic/Dialogs';
|
||||
import MDDialog from 'react-md/lib/Dialogs';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import Snackbar from 'react-md/lib/Snackbars';
|
||||
import IconPicker from '../../components/Home/IconPicker';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
import { PieChart, Pie, Sector, Cell, Legend, Layer } from 'recharts';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
import { Scorecard, Sector, Cell, Legend, Layer } from 'recharts';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import CircularProgress from 'react-md/lib/Progress/CircularProgress';
|
||||
import { Spinner, SpinnerActions } from '../../components/Spinner';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
import { Spinner, SpinnerActions } from '../../components/Spinner';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
import { DataTable, TableRow } from 'react-md/lib/DataTables';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import Snackbar from 'react-md/lib/Snackbars';
|
||||
import { Toast, IToast, ToastActions } from '../../components/Toast';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export default <IDashboardConfig>{
|
||||
export default <IDashboardConfig> {
|
||||
id: 'id',
|
||||
url: 'url',
|
||||
icon: 'icon',
|
||||
|
|
|
@ -3,6 +3,7 @@ import dashboardMock from '../../dashboards/application-insights';
|
|||
import query24HResponseMock from './query.24h.mock';
|
||||
import query30DResponseMock from './query.30d.mock';
|
||||
import { appInsightsUri } from '../../../../data-sources/plugins/ApplicationInsights/common';
|
||||
import { REPLACE } from 'history/lib/actions';
|
||||
|
||||
const { appId, apiKey } = dashboardMock.config.connections['application-insights'];
|
||||
|
||||
|
@ -11,22 +12,33 @@ const { appId, apiKey } = dashboardMock.config.connections['application-insights
|
|||
*/
|
||||
function mockRequests() {
|
||||
|
||||
nock(appInsightsUri, {
|
||||
reqheaders: {
|
||||
"x-api-key": apiKey
|
||||
}
|
||||
})
|
||||
.post(`/${appId}/query?timespan=PT24H`)
|
||||
nock('http://localhost')
|
||||
.post('/applicationInsights/query', {
|
||||
query: /(.*?)/g,
|
||||
appId: appId,
|
||||
dashboardId: dashboardMock.id,
|
||||
queryTimespan: 'PT24H'
|
||||
})
|
||||
.delay(10)
|
||||
.reply(200, query24HResponseMock)
|
||||
.post(`/${appId}/query?timespan=P30D`)
|
||||
.post('/applicationInsights/query', {
|
||||
query: /(.*?)/g,
|
||||
appId: appId,
|
||||
dashboardId: dashboardMock.id,
|
||||
queryTimespan: 'P30D'
|
||||
})
|
||||
.delay(10)
|
||||
.reply(200, query30DResponseMock)
|
||||
.post(`/id_fail/query?timespan=P30D`)
|
||||
.post('/applicationInsights/query', {
|
||||
query: /(.*?)/g,
|
||||
appId: 'id_fail',
|
||||
dashboardId: dashboardMock.id,
|
||||
queryTimespan: 'P30D'
|
||||
})
|
||||
.delay(10)
|
||||
.reply(404, 'Some error');
|
||||
|
||||
}
|
||||
|
||||
export {
|
||||
mockRequests
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import HomeComponent from '../../components/Home';
|
||||
import dashboardMock from '../mocks/dashboards/pie';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import Home from '../../pages/Home'
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Card } from 'react-md/lib/Cards';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import NotFound from '../../pages/NotFound'
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import Setup from '../../components/Setup';
|
||||
import SetupComponent from '../../pages/Setup'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Toast } from '../../components/Toast';
|
||||
import AccountStore from '../../stores/AccountStore';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import * as TestUtils from 'react-addons-test-utils';
|
||||
import * as TestUtils from 'react-dom/test-utils';
|
||||
|
||||
import { Toast } from '../../components/Toast';
|
||||
import ConfigurationsStore from '../../stores/ConfigurationsStore';
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
import ConfigurationsActions from '../../actions/ConfigurationsActions';
|
||||
import ConfigurationsStore from '../../stores/ConfigurationsStore';
|
||||
import { DataSourceConnector, IDataSourceDictionary } from '../../data-sources';
|
||||
|
||||
function setupTests(dashboardMock: IDashboardConfig, done?: () => void): IDataSourceDictionary {
|
||||
DataSourceConnector.createDataSources(dashboardMock, dashboardMock.config.connections);
|
||||
let dataSources = DataSourceConnector.getDataSources();
|
||||
function setupTests(
|
||||
dashboardMock: IDashboardConfig,
|
||||
setDataSources: (ds: IDataSourceDictionary) => void,
|
||||
done: () => void): void {
|
||||
|
||||
// Waiting for all defered functions to complete their execution
|
||||
done && setTimeout(done, 100);
|
||||
ConfigurationsStore.listen(() => {
|
||||
let dataSources = DataSourceConnector.getDataSources();
|
||||
setDataSources(dataSources);
|
||||
return done();
|
||||
});
|
||||
|
||||
return dataSources;
|
||||
ConfigurationsActions.loadDashboardComplete(dashboardMock);
|
||||
}
|
||||
|
||||
export {
|
||||
|
|
Загрузка…
Ссылка в новой задаче