Chore: clean up console warning from SQL Builder Editor tests (#46779)

* Chore: clean up console warning from SQL Builder Editor tests

* Re-add test for checking dimensions filter
This commit is contained in:
Kevin Yu 2022-03-22 09:39:51 -07:00 committed by GitHub
parent a0f5953cb3
commit ba62f5ad5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { SQLBuilderEditor } from '..'; import { SQLBuilderEditor } from '..';
import { act, render, screen, waitFor } from '@testing-library/react'; import { render, screen, waitFor } from '@testing-library/react';
import { CloudWatchMetricsQuery, MetricEditorMode, MetricQueryType, SQLExpression } from '../../types'; import { CloudWatchMetricsQuery, MetricEditorMode, MetricQueryType, SQLExpression } from '../../types';
import { setupMockedDataSource } from '../../__mocks__/CloudWatchDataSource'; import { setupMockedDataSource } from '../../__mocks__/CloudWatchDataSource';
import { QueryEditorExpressionType, QueryEditorPropertyType } from '../../expressions'; import { QueryEditorExpressionType, QueryEditorPropertyType } from '../../expressions';
@ -74,7 +74,7 @@ describe('Cloudwatch SQLBuilderEditor', () => {
expect(screen.getByText('Schema labels')).toBeInTheDocument(); expect(screen.getByText('Schema labels')).toBeInTheDocument();
}); });
it('Uses dimension filter when loading dimension keys', async () => { it('Uses dimension filter when loading dimension keys if query includes InstanceID', async () => {
const query = makeSQLQuery({ const query = makeSQLQuery({
from: { from: {
type: QueryEditorExpressionType.Function, type: QueryEditorExpressionType.Function,
@ -93,20 +93,12 @@ describe('Cloudwatch SQLBuilderEditor', () => {
}); });
render(<SQLBuilderEditor {...baseProps} query={query} />); render(<SQLBuilderEditor {...baseProps} query={query} />);
await waitFor(() =>
act(async () => { expect(datasource.getDimensionKeys).toHaveBeenCalledWith('AWS/EC2', query.region, { InstanceId: null }, undefined)
expect(screen.getByText('AWS/EC2')).toBeInTheDocument(); );
expect(screen.getByLabelText('With schema')).toBeChecked(); expect(screen.getByText('AWS/EC2')).toBeInTheDocument();
expect(screen.getByText('Schema labels')).toBeInTheDocument(); expect(screen.getByLabelText('With schema')).toBeChecked();
await waitFor(() => expect(screen.getByText('Schema labels')).toBeInTheDocument();
expect(datasource.getDimensionKeys).toHaveBeenCalledWith(
query.namespace,
query.region,
{ InstanceId: null },
undefined
)
);
});
}); });
it('Displays the SELECT correctly', async () => { it('Displays the SELECT correctly', async () => {