diff --git a/public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/MultiFilter.test.tsx b/public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/MultiFilter.test.tsx
index 72cf5ade437..18fa8b923a4 100644
--- a/public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/MultiFilter.test.tsx
+++ b/public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/MultiFilter.test.tsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
+import { fireEvent, render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { MultiFilter } from './MultiFilter';
@@ -29,11 +29,9 @@ describe('MultiFilters', () => {
const onChange = jest.fn();
render();
- userEvent.click(screen.getByLabelText('Add'));
- await waitFor(() => {
- expect(screen.getByTestId('cloudwatch-multifilter-item')).toBeInTheDocument();
- expect(onChange).not.toHaveBeenCalled();
- });
+ await userEvent.click(screen.getByLabelText('Add'));
+ expect(screen.getByTestId('cloudwatch-multifilter-item')).toBeInTheDocument();
+ expect(onChange).not.toHaveBeenCalled();
});
});
@@ -43,22 +41,17 @@ describe('MultiFilters', () => {
const onChange = jest.fn();
render();
- userEvent.click(screen.getByLabelText('Add'));
-
- await waitFor(() => {
- const filterItemElement = screen.getByTestId('cloudwatch-multifilter-item');
- expect(filterItemElement).toBeInTheDocument();
- });
+ await userEvent.click(screen.getByLabelText('Add'));
+ const filterItemElement = screen.getByTestId('cloudwatch-multifilter-item');
+ expect(filterItemElement).toBeInTheDocument();
const keyElement = screen.getByTestId('cloudwatch-multifilter-item-key');
expect(keyElement).toBeInTheDocument();
- userEvent.type(keyElement!, 'my-key');
+ await userEvent.type(keyElement!, 'my-key');
fireEvent.blur(keyElement!);
- await waitFor(() => {
- expect(screen.getByDisplayValue('my-key')).toBeInTheDocument();
- expect(onChange).not.toHaveBeenCalled();
- });
+ expect(within(filterItemElement).getByDisplayValue('my-key')).toBeInTheDocument();
+ expect(onChange).not.toHaveBeenCalled();
});
});
@@ -69,28 +62,24 @@ describe('MultiFilters', () => {
render();
const label = await screen.findByLabelText('Add');
- userEvent.click(label);
- const filterItemElement = await screen.findByTestId('cloudwatch-multifilter-item');
+ await userEvent.click(label);
+ const filterItemElement = screen.getByTestId('cloudwatch-multifilter-item');
expect(filterItemElement).toBeInTheDocument();
const keyElement = screen.getByTestId('cloudwatch-multifilter-item-key');
expect(keyElement).toBeInTheDocument();
- userEvent.type(keyElement!, 'my-key');
+ await userEvent.type(keyElement!, 'my-key');
fireEvent.blur(keyElement!);
- await waitFor(() => {
- expect(screen.getByDisplayValue('my-key')).toBeInTheDocument();
- expect(onChange).not.toHaveBeenCalled();
- });
+ expect(within(filterItemElement).getByDisplayValue('my-key')).toBeInTheDocument();
+ expect(onChange).not.toHaveBeenCalled();
const valueElement = screen.getByTestId('cloudwatch-multifilter-item-value');
expect(valueElement).toBeInTheDocument();
- userEvent.type(valueElement!, 'my-value1,my-value2');
+ await userEvent.type(valueElement!, 'my-value1,my-value2');
fireEvent.blur(valueElement!);
- await waitFor(() => {
- expect(screen.getByDisplayValue('my-value1, my-value2')).toBeInTheDocument();
- expect(onChange).toHaveBeenCalledWith({
- 'my-key': ['my-value1', 'my-value2'],
- });
+ expect(within(filterItemElement).getByDisplayValue('my-value1, my-value2')).toBeInTheDocument();
+ expect(onChange).toHaveBeenCalledWith({
+ 'my-key': ['my-value1', 'my-value2'],
});
});
});
@@ -107,14 +96,12 @@ describe('MultiFilters', () => {
const keyElement = screen.getByTestId('cloudwatch-multifilter-item-key');
expect(keyElement).toBeInTheDocument();
- userEvent.type(keyElement!, '2');
+ await userEvent.type(keyElement!, '2');
fireEvent.blur(keyElement!);
- await waitFor(() => {
- expect(within(filterItemElement).getByDisplayValue('my-key2')).toBeInTheDocument();
- expect(onChange).toHaveBeenCalledWith({
- 'my-key2': ['my-value'],
- });
+ expect(within(filterItemElement).getByDisplayValue('my-key2')).toBeInTheDocument();
+ expect(onChange).toHaveBeenCalledWith({
+ 'my-key2': ['my-value'],
});
});
});
diff --git a/public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/VariableQueryEditor.test.tsx b/public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/VariableQueryEditor.test.tsx
index 2c38a561807..838c719fc1e 100644
--- a/public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/VariableQueryEditor.test.tsx
+++ b/public/app/plugins/datasource/cloudwatch/components/VariableQueryEditor/VariableQueryEditor.test.tsx
@@ -189,18 +189,16 @@ describe('VariableEditor', () => {
// set filter value
const valueElement = screen.getByTestId('cloudwatch-multifilter-item-value');
expect(valueElement).toBeInTheDocument();
- userEvent.type(valueElement!, ',baz');
+ await userEvent.type(valueElement!, ',baz');
fireEvent.blur(valueElement!);
expect(screen.getByDisplayValue('foo, bar, baz')).toBeInTheDocument();
- await waitFor(() => {
- expect(onChange).toHaveBeenCalledWith({
- ...defaultQuery,
- queryType: VariableQueryType.EC2InstanceAttributes,
- region: 'a1',
- attributeName: 'Tags.blah',
- ec2Filters: { s4: ['foo', 'bar', 'baz'] },
- });
+ expect(onChange).toHaveBeenCalledWith({
+ ...defaultQuery,
+ queryType: VariableQueryType.EC2InstanceAttributes,
+ region: 'a1',
+ attributeName: 'Tags.blah',
+ ec2Filters: { s4: ['foo', 'bar', 'baz'] },
});
});
});
@@ -228,19 +226,17 @@ describe('VariableEditor', () => {
expect(ds.datasource.getMetrics).toHaveBeenCalledWith('z2', 'b1');
expect(ds.datasource.getDimensionKeys).toHaveBeenCalledWith('z2', 'b1');
- await waitFor(() => {
- expect(props.onChange).toHaveBeenCalledWith({
- ...defaultQuery,
- refId: 'CloudWatchVariableQueryEditor-VariableQuery',
- queryType: VariableQueryType.DimensionValues,
- namespace: 'z2',
- region: 'b1',
- // metricName i3 exists in the new region and should not be removed
- metricName: 'i3',
- // dimensionKey s4 and valueDimension do not exist in the new region and should be removed
- dimensionKey: '',
- dimensionFilters: {},
- });
+ expect(props.onChange).toHaveBeenCalledWith({
+ ...defaultQuery,
+ refId: 'CloudWatchVariableQueryEditor-VariableQuery',
+ queryType: VariableQueryType.DimensionValues,
+ namespace: 'z2',
+ region: 'b1',
+ // metricName i3 exists in the new region and should not be removed
+ metricName: 'i3',
+ // dimensionKey s4 and valueDimension do not exist in the new region and should be removed
+ dimensionKey: '',
+ dimensionFilters: {},
});
});
});