2021-05-27 14:28:36 -05:00
|
|
|
import { render, screen } from '@testing-library/react';
|
2019-08-19 16:35:44 -05:00
|
|
|
import React from 'react';
|
2021-05-27 14:28:36 -05:00
|
|
|
import ConfigEditor from './ConfigEditor';
|
2019-08-19 16:35:44 -05:00
|
|
|
|
2021-05-27 14:28:36 -05:00
|
|
|
describe('AppInsights ConfigEditor', () => {
|
|
|
|
const baseOptions = {
|
|
|
|
id: 21,
|
|
|
|
uid: 'y',
|
|
|
|
orgId: 1,
|
|
|
|
name: 'Azure Monitor-10-10',
|
|
|
|
type: 'grafana-azure-monitor-datasource',
|
|
|
|
typeLogoUrl: '',
|
|
|
|
typeName: 'Azure',
|
|
|
|
access: 'proxy',
|
|
|
|
url: '',
|
|
|
|
password: '',
|
|
|
|
user: '',
|
|
|
|
database: '',
|
|
|
|
basicAuth: false,
|
|
|
|
basicAuthUser: '',
|
|
|
|
basicAuthPassword: '',
|
|
|
|
withCredentials: false,
|
|
|
|
isDefault: false,
|
|
|
|
jsonData: {},
|
|
|
|
secureJsonFields: {},
|
|
|
|
version: 1,
|
|
|
|
readOnly: false,
|
2019-08-19 16:35:44 -05:00
|
|
|
};
|
|
|
|
|
2021-05-27 14:28:36 -05:00
|
|
|
const jsonData = {
|
|
|
|
subscriptionId: '44987801-6nn6-49he-9b2d-9106972f9789',
|
|
|
|
azureLogAnalyticsSameAs: true,
|
|
|
|
cloudName: 'azuremonitor',
|
|
|
|
};
|
|
|
|
|
|
|
|
const onOptionsChange = jest.fn();
|
|
|
|
|
|
|
|
it('should not render application insights config for new data sources', () => {
|
|
|
|
const options = {
|
|
|
|
...baseOptions,
|
|
|
|
jsonData,
|
|
|
|
};
|
|
|
|
render(<ConfigEditor options={options} onOptionsChange={onOptionsChange} />);
|
2019-08-19 16:35:44 -05:00
|
|
|
|
2021-05-27 14:28:36 -05:00
|
|
|
expect(screen.queryByText('Azure Application Insights')).not.toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render application insights config for data sources using application insights', () => {
|
|
|
|
const options = {
|
|
|
|
...baseOptions,
|
|
|
|
jsonData: {
|
|
|
|
...jsonData,
|
|
|
|
appInsightsAppId: 'abc-123',
|
|
|
|
},
|
|
|
|
secureJsonFields: {
|
|
|
|
appInsightsApiKey: true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
render(<ConfigEditor options={options} onOptionsChange={onOptionsChange} />);
|
2019-08-19 16:35:44 -05:00
|
|
|
|
2021-05-27 14:28:36 -05:00
|
|
|
expect(screen.queryByText('Azure Application Insights')).toBeInTheDocument();
|
2019-08-19 16:35:44 -05:00
|
|
|
});
|
|
|
|
});
|