mirror of https://github.com/grafana/grafana
AzureMonitor: Hide App Insights for data sources not using it (#34725)
* AzureMonitor: Hide Application Insights and Insights Analytics for panels not using them * AzureMonitor: Hide Application Insights config * simplify * fix testpull/34828/head^2
parent
6d750c000e
commit
7646246d8c
@ -1,46 +1,63 @@ |
||||
import { render, screen } from '@testing-library/react'; |
||||
import React from 'react'; |
||||
import { shallow } from 'enzyme'; |
||||
import ConfigEditor, { Props } from './ConfigEditor'; |
||||
import ConfigEditor from './ConfigEditor'; |
||||
|
||||
const setup = () => { |
||||
const props: Props = { |
||||
options: { |
||||
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: { |
||||
subscriptionId: '44987801-6nn6-49he-9b2d-9106972f9789', |
||||
azureLogAnalyticsSameAs: true, |
||||
cloudName: 'azuremonitor', |
||||
}, |
||||
secureJsonFields: {}, |
||||
version: 1, |
||||
readOnly: false, |
||||
}, |
||||
onOptionsChange: jest.fn(), |
||||
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, |
||||
}; |
||||
|
||||
return shallow(<ConfigEditor {...props} />); |
||||
}; |
||||
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} />); |
||||
|
||||
describe('Render', () => { |
||||
it('should render component', () => { |
||||
const wrapper = setup(); |
||||
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} />); |
||||
|
||||
expect(wrapper).toMatchSnapshot(); |
||||
expect(screen.queryByText('Azure Application Insights')).toBeInTheDocument(); |
||||
}); |
||||
}); |
||||
|
@ -1,110 +0,0 @@ |
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
||||
|
||||
exports[`Render should render component 1`] = ` |
||||
<Fragment> |
||||
<MonitorConfig |
||||
getSubscriptions={[Function]} |
||||
options={ |
||||
Object { |
||||
"access": "proxy", |
||||
"basicAuth": false, |
||||
"basicAuthPassword": "", |
||||
"basicAuthUser": "", |
||||
"database": "", |
||||
"id": 21, |
||||
"isDefault": false, |
||||
"jsonData": Object { |
||||
"azureLogAnalyticsSameAs": true, |
||||
"cloudName": "azuremonitor", |
||||
"subscriptionId": "44987801-6nn6-49he-9b2d-9106972f9789", |
||||
}, |
||||
"name": "Azure Monitor-10-10", |
||||
"orgId": 1, |
||||
"password": "", |
||||
"readOnly": false, |
||||
"secureJsonData": Object {}, |
||||
"secureJsonFields": Object {}, |
||||
"type": "grafana-azure-monitor-datasource", |
||||
"typeLogoUrl": "", |
||||
"typeName": "Azure", |
||||
"uid": "y", |
||||
"url": "", |
||||
"user": "", |
||||
"version": 1, |
||||
"withCredentials": false, |
||||
} |
||||
} |
||||
updateOptions={[Function]} |
||||
/> |
||||
<AnalyticsConfig |
||||
getSubscriptions={[Function]} |
||||
getWorkspaces={[Function]} |
||||
options={ |
||||
Object { |
||||
"access": "proxy", |
||||
"basicAuth": false, |
||||
"basicAuthPassword": "", |
||||
"basicAuthUser": "", |
||||
"database": "", |
||||
"id": 21, |
||||
"isDefault": false, |
||||
"jsonData": Object { |
||||
"azureLogAnalyticsSameAs": true, |
||||
"cloudName": "azuremonitor", |
||||
"subscriptionId": "44987801-6nn6-49he-9b2d-9106972f9789", |
||||
}, |
||||
"name": "Azure Monitor-10-10", |
||||
"orgId": 1, |
||||
"password": "", |
||||
"readOnly": false, |
||||
"secureJsonData": Object {}, |
||||
"secureJsonFields": Object {}, |
||||
"type": "grafana-azure-monitor-datasource", |
||||
"typeLogoUrl": "", |
||||
"typeName": "Azure", |
||||
"uid": "y", |
||||
"url": "", |
||||
"user": "", |
||||
"version": 1, |
||||
"withCredentials": false, |
||||
} |
||||
} |
||||
updateOptions={[Function]} |
||||
/> |
||||
<InsightsConfig |
||||
onResetOptionKey={[Function]} |
||||
onUpdateJsonDataOption={[Function]} |
||||
onUpdateSecureJsonDataOption={[Function]} |
||||
options={ |
||||
Object { |
||||
"access": "proxy", |
||||
"basicAuth": false, |
||||
"basicAuthPassword": "", |
||||
"basicAuthUser": "", |
||||
"database": "", |
||||
"id": 21, |
||||
"isDefault": false, |
||||
"jsonData": Object { |
||||
"azureLogAnalyticsSameAs": true, |
||||
"cloudName": "azuremonitor", |
||||
"subscriptionId": "44987801-6nn6-49he-9b2d-9106972f9789", |
||||
}, |
||||
"name": "Azure Monitor-10-10", |
||||
"orgId": 1, |
||||
"password": "", |
||||
"readOnly": false, |
||||
"secureJsonData": Object {}, |
||||
"secureJsonFields": Object {}, |
||||
"type": "grafana-azure-monitor-datasource", |
||||
"typeLogoUrl": "", |
||||
"typeName": "Azure", |
||||
"uid": "y", |
||||
"url": "", |
||||
"user": "", |
||||
"version": 1, |
||||
"withCredentials": false, |
||||
} |
||||
} |
||||
/> |
||||
</Fragment> |
||||
`; |
Loading…
Reference in new issue