From 501b750fa27f1874c652446dda7be4bbbfb81e8e Mon Sep 17 00:00:00 2001 From: Radu Ciopraga <1442639+raduciopraga@users.noreply.github.com> Date: Mon, 5 Feb 2024 21:23:20 +0100 Subject: [PATCH] wait for GroupsExplorerContent test expectations to pass Signed-off-by: Radu Ciopraga <1442639+raduciopraga@users.noreply.github.com> --- .../GroupsExplorerContent.test.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/plugins/explore/src/components/GroupsExplorerContent/GroupsExplorerContent.test.tsx b/plugins/explore/src/components/GroupsExplorerContent/GroupsExplorerContent.test.tsx index 0e992c220d..00a6164aa9 100644 --- a/plugins/explore/src/components/GroupsExplorerContent/GroupsExplorerContent.test.tsx +++ b/plugins/explore/src/components/GroupsExplorerContent/GroupsExplorerContent.test.tsx @@ -17,7 +17,7 @@ import { Entity } from '@backstage/catalog-model'; import { catalogApiRef, entityRouteRef } from '@backstage/plugin-catalog-react'; import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; -import { screen } from '@testing-library/react'; +import { waitFor, screen } from '@testing-library/react'; import React from 'react'; import { GroupsExplorerContent } from '../GroupsExplorerContent'; @@ -80,9 +80,11 @@ describe('', () => { mountedRoutes, ); - expect( - screen.getByRole('link', { name: 'group:my-namespace/group-a' }), - ).toBeInTheDocument(); + await waitFor(() => + expect( + screen.getByRole('link', { name: 'group:my-namespace/group-a' }), + ).toBeInTheDocument(), + ); }); it('renders a custom title', async () => { @@ -95,9 +97,11 @@ describe('', () => { mountedRoutes, ); - expect( - screen.getByText('Our Teams', { selector: 'h2' }), - ).toBeInTheDocument(); + await waitFor(() => + expect( + screen.getByText('Our Teams', { selector: 'h2' }), + ).toBeInTheDocument(), + ); }); it('renders a friendly error if it cannot collect domains', async () => { @@ -111,6 +115,8 @@ describe('', () => { mountedRoutes, ); - expect(screen.getAllByText(/Error: Network timeout/).length).not.toBe(0); + await waitFor(() => + expect(screen.getAllByText(/Error: Network timeout/).length).not.toBe(0), + ); }); });