forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AzureMonitor: Hide App Insights for data sources not using it (grafan…
…a#34725) * AzureMonitor: Hide Application Insights and Insights Analytics for panels not using them * AzureMonitor: Hide Application Insights config * simplify * fix test
- Loading branch information
Showing
8 changed files
with
165 additions
and
167 deletions.
There are no files selected for viewing
93 changes: 55 additions & 38 deletions
93
.../app/plugins/datasource/grafana-azure-monitor-datasource/components/ConfigEditor.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 0 additions & 110 deletions
110
...urce/grafana-azure-monitor-datasource/components/__snapshots__/ConfigEditor.test.tsx.snap
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.