From 516a97f0bae4ae30ccdf6db3d328cbd1939d3ffc Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Tue, 27 Sep 2022 14:40:55 +0200 Subject: [PATCH] [NO JIRA] Fix flaky test --- .../component/__tests__/ComponentNav-test.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx index 08d22435ec7..edefa213b80 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx @@ -29,29 +29,39 @@ import ComponentNav, { ComponentNavProps } from '../ComponentNav'; it('renders correctly when there are warnings', () => { renderComponentNav({ warnings: [mockTaskWarning()] }); - expect(screen.getByText('component_navigation.last_analysis_had_warnings')).toBeInTheDocument(); + expect( + screen.getByText('component_navigation.last_analysis_had_warnings', { exact: false }) + ).toBeInTheDocument(); }); it('renders correctly when there is a background task in progress', () => { renderComponentNav({ isInProgress: true }); - expect(screen.getByText('component_navigation.status.in_progress')).toBeInTheDocument(); + expect( + screen.getByText('component_navigation.status.in_progress', { exact: false }) + ).toBeInTheDocument(); }); it('renders correctly when there is a background task pending', () => { renderComponentNav({ isPending: true }); - expect(screen.getByText('component_navigation.status.pending')).toBeInTheDocument(); + expect( + screen.getByText('component_navigation.status.pending', { exact: false }) + ).toBeInTheDocument(); }); it('renders correctly when there is a failing background task', () => { renderComponentNav({ currentTask: mockTask({ status: TaskStatuses.Failed }) }); - expect(screen.getByText('component_navigation.status.failed_X')).toBeInTheDocument(); + expect( + screen.getByText('component_navigation.status.failed_X', { exact: false }) + ).toBeInTheDocument(); }); it('renders correctly when the project binding is incorrect', () => { renderComponentNav({ projectBindingErrors: mockProjectAlmBindingConfigurationErrors() }); - expect(screen.getByText('component_navigation.pr_deco.error_detected_X')).toBeInTheDocument(); + expect( + screen.getByText('component_navigation.pr_deco.error_detected_X', { exact: false }) + ).toBeInTheDocument(); }); it('correctly returns focus to the Project Information link when the drawer is closed', () => { -- 2.39.5