mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Azure Monitor: Add Resource Picker for Metrics Queries (#49029)
This commit is contained in:
parent
acd31ae9f0
commit
c652849303
@ -28,7 +28,9 @@ describe('Azure Monitor QueryEditor', () => {
|
||||
};
|
||||
|
||||
render(<QueryEditor query={mockQuery} datasource={mockDatasource} onChange={() => {}} onRunQuery={() => {}} />);
|
||||
await waitFor(() => expect(screen.getByTestId('azure-monitor-metrics-query-editor')).toBeInTheDocument());
|
||||
await waitFor(() =>
|
||||
expect(screen.getByTestId('azure-monitor-metrics-query-editor-with-resource-picker')).toBeInTheDocument()
|
||||
);
|
||||
});
|
||||
|
||||
it('renders the Logs query editor when the query type is Logs', async () => {
|
||||
@ -60,35 +62,14 @@ describe('Azure Monitor QueryEditor', () => {
|
||||
|
||||
it('displays error messages from frontend Azure calls', async () => {
|
||||
const mockDatasource = createMockDatasource();
|
||||
mockDatasource.azureMonitorDatasource.getSubscriptions = jest.fn().mockRejectedValue(invalidNamespaceError());
|
||||
mockDatasource.azureMonitorDatasource.getMetricNamespaces = jest.fn().mockRejectedValue(invalidNamespaceError());
|
||||
render(
|
||||
<QueryEditor query={createMockQuery()} datasource={mockDatasource} onChange={() => {}} onRunQuery={() => {}} />
|
||||
);
|
||||
await waitFor(() => expect(screen.getByTestId('azure-monitor-query-editor')).toBeInTheDocument());
|
||||
|
||||
expect(screen.getByText("The resource namespace 'grafanadev' is invalid.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders the new query editor for metrics when enabled with a feature toggle', async () => {
|
||||
const originalConfigValue = config.featureToggles.azureMonitorResourcePickerForMetrics;
|
||||
|
||||
// To do this irl go to custom.ini file and add resourcePickerForMetrics = true under [feature_toggles]
|
||||
config.featureToggles.azureMonitorResourcePickerForMetrics = true;
|
||||
|
||||
const mockDatasource = createMockDatasource();
|
||||
const mockQuery = {
|
||||
...createMockQuery(),
|
||||
queryType: AzureQueryType.AzureMonitor,
|
||||
};
|
||||
|
||||
render(<QueryEditor query={mockQuery} datasource={mockDatasource} onChange={() => {}} onRunQuery={() => {}} />);
|
||||
|
||||
await waitFor(() =>
|
||||
expect(screen.getByTestId('azure-monitor-metrics-query-editor-with-resource-picker')).toBeInTheDocument()
|
||||
);
|
||||
|
||||
// reset config to not impact future tests
|
||||
config.featureToggles.azureMonitorResourcePickerForMetrics = originalConfigValue;
|
||||
expect(screen.getByText('An error occurred while requesting metadata from Azure Monitor')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render the experimental QueryHeader when feature toggle is enabled', async () => {
|
||||
|
@ -16,7 +16,6 @@ import {
|
||||
import useLastError from '../../utils/useLastError';
|
||||
import ArgQueryEditor from '../ArgQueryEditor';
|
||||
import LogsQueryEditor from '../LogsQueryEditor';
|
||||
import MetricsQueryEditor from '../MetricsQueryEditor';
|
||||
import NewMetricsQueryEditor from '../NewMetricsQueryEditor/MetricsQueryEditor';
|
||||
import { QueryHeader } from '../QueryHeader';
|
||||
import { Space } from '../Space';
|
||||
@ -102,22 +101,9 @@ const EditorForQueryType: React.FC<EditorForQueryTypeProps> = ({
|
||||
}) => {
|
||||
switch (query.queryType) {
|
||||
case AzureQueryType.AzureMonitor:
|
||||
if (config.featureToggles.azureMonitorResourcePickerForMetrics) {
|
||||
return (
|
||||
<NewMetricsQueryEditor
|
||||
data={data}
|
||||
query={query}
|
||||
datasource={datasource}
|
||||
onChange={onChange}
|
||||
variableOptionGroup={variableOptionGroup}
|
||||
setError={setError}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<MetricsQueryEditor
|
||||
<NewMetricsQueryEditor
|
||||
data={data}
|
||||
subscriptionId={subscriptionId}
|
||||
query={query}
|
||||
datasource={datasource}
|
||||
onChange={onChange}
|
||||
|
Loading…
Reference in New Issue
Block a user