mirror of
https://github.com/grafana/grafana.git
synced 2025-09-28 15:23:52 +08:00

* Update Azure Monitor * Update Prometheus * Update README * Update docs/sources/datasources/azure-monitor/_index.md Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com> * Update docs/sources/datasources/azure-monitor/_index.md Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com> * Update docs/sources/datasources/azure-monitor/_index.md Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com> * Update docs/sources/datasources/azure-monitor/_index.md Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com> * README updates * Fix prettier * memoize options --------- Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com> Co-authored-by: Beverly <131809838+BeverlyJaneJ@users.noreply.github.com>
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { render, screen } from '@testing-library/react';
|
|
import React from 'react';
|
|
|
|
import AzureCredentialsForm, { Props } from './AzureCredentialsForm';
|
|
|
|
const setup = (propsFunc?: (props: Props) => Props) => {
|
|
let props: Props = {
|
|
managedIdentityEnabled: false,
|
|
workloadIdentityEnabled: false,
|
|
credentials: {
|
|
authType: 'clientsecret',
|
|
azureCloud: 'azuremonitor',
|
|
tenantId: 'e7f3f661-a933-3h3f-0294-31c4f962ec48',
|
|
clientId: '34509fad-c0r9-45df-9e25-f1ee34af6900',
|
|
clientSecret: undefined,
|
|
defaultSubscriptionId: '44987801-6nn6-49he-9b2d-9106972f9789',
|
|
},
|
|
azureCloudOptions: [
|
|
{ value: 'azuremonitor', label: 'Azure' },
|
|
{ value: 'govazuremonitor', label: 'Azure US Government' },
|
|
{ value: 'chinaazuremonitor', label: 'Azure China' },
|
|
],
|
|
onCredentialsChange: jest.fn(),
|
|
getSubscriptions: jest.fn().mockResolvedValue([]),
|
|
};
|
|
|
|
if (propsFunc) {
|
|
props = propsFunc(props);
|
|
}
|
|
|
|
render(<AzureCredentialsForm {...props} />);
|
|
};
|
|
|
|
describe('AzureCredentialsForm', () => {
|
|
it('should render without error', () => {
|
|
expect(() => setup()).not.toThrow();
|
|
});
|
|
|
|
it('should disable azure monitor secret input when the clientSecret is a symbol', async () => {
|
|
setup((props) => ({
|
|
...props,
|
|
credentials: {
|
|
...props.credentials,
|
|
clientSecret: Symbol(),
|
|
},
|
|
}));
|
|
expect(await screen.findByLabelText('Client Secret')).toBeDisabled();
|
|
});
|
|
|
|
it('should enable azure monitor load subscriptions button when all required fields are defined', async () => {
|
|
setup((props) => ({
|
|
...props,
|
|
credentials: {
|
|
...props.credentials,
|
|
clientSecret: 'e7f3f661-a933-4b3f-8176-51c4f982ec48',
|
|
},
|
|
}));
|
|
expect(await screen.findByRole('button', { name: 'Load Subscriptions' })).not.toBeDisabled();
|
|
});
|
|
});
|