test: Fix act errors in AnnotationLayer test (#21423)

This commit is contained in:
Lyndsi Kay Williams 2022-09-09 20:27:21 -05:00 committed by GitHub
parent c7c6149f4a
commit 69d3a336b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,7 +78,7 @@ test('renders extra checkboxes when type is time series', async () => {
userEvent.click(screen.getAllByText('Formula')[0]); userEvent.click(screen.getAllByText('Formula')[0]);
userEvent.click(screen.getByText('Time series')); userEvent.click(screen.getByText('Time series'));
expect( expect(
screen.getByRole('button', { name: 'Show Markers' }), await screen.findByRole('button', { name: 'Show Markers' }),
).toBeInTheDocument(); ).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Hide Line' })).toBeInTheDocument(); expect(screen.getByRole('button', { name: 'Hide Line' })).toBeInTheDocument();
}); });
@ -86,7 +86,7 @@ test('renders extra checkboxes when type is time series', async () => {
test('enables apply and ok buttons', async () => { test('enables apply and ok buttons', async () => {
const { container } = render(<AnnotationLayer {...defaultProps} />); const { container } = render(<AnnotationLayer {...defaultProps} />);
waitFor(() => { await waitFor(() => {
expect(container).toBeInTheDocument(); expect(container).toBeInTheDocument();
}); });
@ -99,7 +99,7 @@ test('enables apply and ok buttons', async () => {
userEvent.type(nameInput, 'Name'); userEvent.type(nameInput, 'Name');
userEvent.type(formulaInput, '2x'); userEvent.type(formulaInput, '2x');
waitFor(() => { await waitFor(() => {
expect(screen.getByRole('button', { name: 'Apply' })).toBeEnabled(); expect(screen.getByRole('button', { name: 'Apply' })).toBeEnabled();
expect(screen.getByRole('button', { name: 'OK' })).toBeEnabled(); expect(screen.getByRole('button', { name: 'OK' })).toBeEnabled();
}); });
@ -150,13 +150,13 @@ test('renders chart options', async () => {
screen.getByRole('combobox', { name: 'Annotation source type' }), screen.getByRole('combobox', { name: 'Annotation source type' }),
); );
userEvent.click(screen.getByText('Superset annotation')); userEvent.click(screen.getByText('Superset annotation'));
expect(screen.getByText('Annotation layer')).toBeInTheDocument(); expect(await screen.findByText('Annotation layer')).toBeInTheDocument();
userEvent.click( userEvent.click(
screen.getByRole('combobox', { name: 'Annotation source type' }), screen.getByRole('combobox', { name: 'Annotation source type' }),
); );
userEvent.click(screen.getByText('Table')); userEvent.click(screen.getByText('Table'));
expect(screen.getByText('Chart')).toBeInTheDocument(); expect(await screen.findByText('Chart')).toBeInTheDocument();
}); });
test('keeps apply disabled when missing required fields', async () => { test('keeps apply disabled when missing required fields', async () => {
@ -167,25 +167,26 @@ test('keeps apply disabled when missing required fields', async () => {
userEvent.click( userEvent.click(
screen.getByRole('combobox', { name: 'Annotation layer value' }), screen.getByRole('combobox', { name: 'Annotation layer value' }),
); );
userEvent.click(await screen.findByText('Chart A')); expect(await screen.findByText('Chart A')).toBeInTheDocument();
expect( userEvent.click(screen.getByText('Chart A'));
screen.getByText('Annotation Slice Configuration'),
).toBeInTheDocument();
userEvent.click(screen.getByRole('button', { name: 'Automatic Color' })); userEvent.click(screen.getByRole('button', { name: 'Automatic Color' }));
userEvent.click( userEvent.click(
screen.getByRole('combobox', { name: 'Annotation layer title column' }), screen.getByRole('combobox', { name: 'Annotation layer title column' }),
); );
expect(await screen.findByText(/none/i)).toBeInTheDocument();
userEvent.click(screen.getByText('None')); userEvent.click(screen.getByText('None'));
userEvent.click(screen.getByText('Style')); userEvent.click(screen.getByText('Style'));
userEvent.click( userEvent.click(
screen.getByRole('combobox', { name: 'Annotation layer stroke' }), screen.getByRole('combobox', { name: 'Annotation layer stroke' }),
); );
expect(await screen.findByText('Dashed')).toBeInTheDocument();
userEvent.click(screen.getByText('Dashed')); userEvent.click(screen.getByText('Dashed'));
userEvent.click(screen.getByText('Opacity')); userEvent.click(screen.getByText('Opacity'));
userEvent.click( userEvent.click(
screen.getByRole('combobox', { name: 'Annotation layer opacity' }), screen.getByRole('combobox', { name: 'Annotation layer opacity' }),
); );
expect(await screen.findByText(/0.5/i)).toBeInTheDocument();
userEvent.click(screen.getByText('0.5')); userEvent.click(screen.getByText('0.5'));
const checkboxes = screen.getAllByRole('checkbox'); const checkboxes = screen.getAllByRole('checkbox');