Files
grafana/public/app/plugins/datasource/azuremonitor/components/AzureCredentialsForm.test.tsx
Andreas Christou d7f7cd1e61 Schema: Initial Azure Monitor query schema (#62018)
* Initial schema

- Add types based off of current frontend

* Rename and field-level comments

* Update report and regenerate files

* Rename frontend Azure folder

- Doing this for consistency and to ensure code-generation works
- Update betterer results due to file renames

* Remove default and add back enum vals that I deleted

* Set workspace prop as optional

* Replace template variable types

* Connect frontend query types

- Keep properties optional for now to avoid major changes
- Rename AzureMetricResource
- Correctly use ResultFormat

* Add TSVeneer decorator

* Update schema

* Update type

* Update CODEOWNERS

* Fix gen-cue issue

* Fix backend test

* Fix e2e test

* Update code coverage

* Remove references to old Azure Monitor path

* Review

* Regen files
2023-02-03 16:06:54 +00:00

65 lines
1.8 KiB
TypeScript

import { render, screen, waitFor } from '@testing-library/react';
import React from 'react';
import AzureCredentialsForm, { Props } from './AzureCredentialsForm';
const setup = (propsFunc?: (props: Props) => Props) => {
let props: Props = {
managedIdentityEnabled: false,
credentials: {
authType: 'clientsecret',
azureCloud: 'azuremonitor',
tenantId: 'e7f3f661-a933-3h3f-0294-31c4f962ec48',
clientId: '34509fad-c0r9-45df-9e25-f1ee34af6900',
clientSecret: undefined,
},
azureCloudOptions: [
{ value: 'azuremonitor', label: 'Azure' },
{ value: 'govazuremonitor', label: 'Azure US Government' },
{ value: 'chinaazuremonitor', label: 'Azure China' },
],
onCredentialsChange: jest.fn(),
};
if (propsFunc) {
props = propsFunc(props);
}
return render(<AzureCredentialsForm {...props} />);
};
describe('Render', () => {
it('should render component', () => {
setup();
expect(screen.getByText('Azure Cloud')).toBeInTheDocument();
});
it('should disable azure monitor secret input', async () => {
setup((props) => ({
...props,
credentials: {
authType: 'clientsecret',
azureCloud: 'azuremonitor',
tenantId: 'e7f3f661-a933-3h3f-0294-31c4f962ec48',
clientId: '34509fad-c0r9-45df-9e25-f1ee34af6900',
clientSecret: Symbol(),
},
}));
await waitFor(() => screen.getByTestId('client-secret'));
expect(screen.getByTestId('client-secret')).toBeDisabled();
});
describe('when disabled', () => {
it('should disable inputs', async () => {
setup((props) => ({
...props,
disabled: true,
}));
await waitFor(() => screen.getByLabelText('Azure Cloud'));
expect(screen.getByLabelText('Azure Cloud')).toBeDisabled();
});
});
});