From 20e1457a78aed45d161cdbaadeefe04b5b5d2b96 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 23 Nov 2021 14:53:10 +0000 Subject: [PATCH] Select: use findBy and make these tests async to avoid act() errors (#42134) --- public/app/core/components/Select/TeamPicker.test.tsx | 4 ++-- .../components/DashboardSettings/GeneralSettings.test.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/app/core/components/Select/TeamPicker.test.tsx b/public/app/core/components/Select/TeamPicker.test.tsx index f12e8f9e280..c24e25324d0 100644 --- a/public/app/core/components/Select/TeamPicker.test.tsx +++ b/public/app/core/components/Select/TeamPicker.test.tsx @@ -13,11 +13,11 @@ jest.mock('@grafana/runtime', () => ({ })); describe('TeamPicker', () => { - it('renders correctly', () => { + it('renders correctly', async () => { const props = { onSelected: () => {}, }; render(); - expect(screen.getByTestId('teamPicker')).toBeInTheDocument(); + expect(await screen.findByTestId('teamPicker')).toBeInTheDocument(); }); }); diff --git a/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx b/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx index 6b6f80a729c..8b5b4301ae3 100644 --- a/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx +++ b/public/app/features/dashboard/components/DashboardSettings/GeneralSettings.test.tsx @@ -35,11 +35,11 @@ const setupTestContext = (options: Partial) => { describe('General Settings', () => { describe('when component is mounted with timezone', () => { - it('should render correctly', () => { + it('should render correctly', async () => { setupTestContext({}); screen.getByDisplayValue('test dashboard title'); screen.getByDisplayValue('test dashboard description'); - expect(screen.getByTestId(selectors.components.TimeZonePicker.containerV2)).toHaveTextContent( + expect(await screen.findByTestId(selectors.components.TimeZonePicker.containerV2)).toHaveTextContent( 'Coordinated Universal Time' ); });