From: Ambroise C Date: Wed, 23 Aug 2023 15:34:41 +0000 (+0200) Subject: SONAR-19728 Update indexation notification text X-Git-Tag: 10.2.0.77647~54 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=adde1e3ed9c2cc8775d73de242b95aac1691e546;p=sonarqube.git SONAR-19728 Update indexation notification text --- diff --git a/server/sonar-web/__mocks__/react-intl.tsx b/server/sonar-web/__mocks__/react-intl.tsx index 9e8c8170dd1..dbd784e1301 100644 --- a/server/sonar-web/__mocks__/react-intl.tsx +++ b/server/sonar-web/__mocks__/react-intl.tsx @@ -21,13 +21,14 @@ import * as React from 'react'; module.exports = { ...jest.requireActual('react-intl'), - FormattedMessage: ({ id, values }: { id: string; values: { [x: string]: React.ReactNode } }) => { + FormattedMessage: ({ id, values }: { id: string; values?: { [x: string]: React.ReactNode } }) => { return ( <> {id} - {Object.entries(values).map(([key, value]) => ( - {value} - ))} + {values !== undefined && + Object.entries(values).map(([key, value]) => ( + {value} + ))} ); }, diff --git a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx index bca3ce81789..db92ceaf415 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx @@ -23,6 +23,7 @@ import classNames from 'classnames'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; +import DocLink from '../../../components/common/DocLink'; import Link from '../../../components/common/Link'; import { Alert, AlertProps } from '../../../components/ui/Alert'; import { translate, translateWithParameters } from '../../../helpers/l10n'; @@ -97,9 +98,15 @@ function renderCompletedWithFailureBanner() { function renderInProgressBanner(completedCount: number, total: number) { return ( <> - {`${translate('indexation.in_progress')} ${translate( - 'indexation.projects_unavailable' - )}`} + + {' '} + + @@ -126,9 +133,15 @@ function renderInProgressBanner(completedCount: number, total: number) { function renderInProgressWithFailureBanner(completedCount: number, total: number) { return ( <> - {`${translate('indexation.in_progress')} ${translate( - 'indexation.projects_unavailable' - )}`} + + {' '} + + @@ -166,3 +179,11 @@ function renderBackgroundTasksPageLink(hasError: boolean, text: string) { ); } + +function renderIndexationDocPageLink() { + return ( + + + + ); +} diff --git a/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotificationRenderer-test.tsx b/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotificationRenderer-test.tsx index 0a807e30149..fd7b757f8aa 100644 --- a/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotificationRenderer-test.tsx +++ b/server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotificationRenderer-test.tsx @@ -18,29 +18,47 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { shallow } from 'enzyme'; import * as React from 'react'; +import { renderComponent } from '../../../../helpers/testReactTestingUtils'; +import { byRole, byText } from '../../../../helpers/testSelector'; import { IndexationNotificationType } from '../../../../types/indexation'; -import IndexationNotificationRenderer, { - IndexationNotificationRendererProps, -} from '../IndexationNotificationRenderer'; - -it.each([ - [IndexationNotificationType.InProgress], - [IndexationNotificationType.InProgressWithFailure], - [IndexationNotificationType.Completed], - [IndexationNotificationType.CompletedWithFailure], -])('should render correctly for type=%p', (type: IndexationNotificationType) => { - expect(shallowRender({ type })).toMatchSnapshot(); +import IndexationNotificationRenderer from '../IndexationNotificationRenderer'; + +describe('Indexation notification renderer', () => { + const ui = { + inProgressText: byText(/indexation.in_progress\s*indexation.features_partly_available/), + completedText: byText('indexation.completed'), + completedWithFailures: byText('indexation.completed_with_error'), + docLink: byRole('link', { name: /indexation.features_partly_available.link/ }), + }; + + it('should display "In progress" status', () => { + renderIndexationNotificationRenderer(IndexationNotificationType.InProgress); + + expect(ui.inProgressText.get()).toBeInTheDocument(); + expect(ui.docLink.get()).toBeInTheDocument(); + }); + + it('should display "In progress with failures" status', () => { + renderIndexationNotificationRenderer(IndexationNotificationType.InProgressWithFailure); + + expect(ui.inProgressText.get()).toBeInTheDocument(); + expect(ui.docLink.get()).toBeInTheDocument(); + }); + + it('should display "Completed" status', () => { + renderIndexationNotificationRenderer(IndexationNotificationType.Completed); + + expect(ui.completedText.get()).toBeInTheDocument(); + }); + + it('should display "Completed with failures" status', () => { + renderIndexationNotificationRenderer(IndexationNotificationType.CompletedWithFailure); + + expect(ui.completedWithFailures.get()).toBeInTheDocument(); + }); }); -function shallowRender(props: Partial = {}) { - return shallow( - - ); +function renderIndexationNotificationRenderer(status: IndexationNotificationType) { + renderComponent(); } diff --git a/server/sonar-web/src/main/js/app/components/indexation/__tests__/__snapshots__/IndexationNotificationRenderer-test.tsx.snap b/server/sonar-web/src/main/js/app/components/indexation/__tests__/__snapshots__/IndexationNotificationRenderer-test.tsx.snap deleted file mode 100644 index 2217b780edd..00000000000 --- a/server/sonar-web/src/main/js/app/components/indexation/__tests__/__snapshots__/IndexationNotificationRenderer-test.tsx.snap +++ /dev/null @@ -1,165 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly for type="Completed" 1`] = ` -
- -
- - indexation.completed - -
-
-
-`; - -exports[`should render correctly for type="CompletedWithFailure" 1`] = ` -
- -
- - - indexation.completed_with_error.link - , - } - } - /> - -
-
-
-`; - -exports[`should render correctly for type="InProgress" 1`] = ` -
- -
- - indexation.in_progress indexation.projects_unavailable - - - - indexation.progression.23.42 - - - - background_tasks.page - , - } - } - /> - -
-
-
-`; - -exports[`should render correctly for type="InProgressWithFailure" 1`] = ` -
- -
- - indexation.in_progress indexation.projects_unavailable - - - - - indexation.progression_with_error.link - , - } - } - /> - -
-
-
-`; diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index fa2dd3db8eb..6387ddcdb20 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -4884,10 +4884,11 @@ maintenance.sonarqube_is_offline.text=The connection to SonarQube is lost. Pleas # INDEXATION # #------------------------------------------------------------------------------ -indexation.in_progress=SonarQube is reindexing project data. +indexation.in_progress=Reindexing in progress. indexation.details_unavailable=Details are unavailable until this process is complete. indexation.link_unavailable=The link to these results is unavailable until this process is complete. -indexation.projects_unavailable=Some projects will be unavailable until this process is complete. +indexation.features_partly_available=Most features are available. Some details only show upon completion. {link} +indexation.features_partly_available.link=More info indexation.progression={0} out of {1} projects reindexed. indexation.progression_with_error={0} out of {1} projects reindexed with some {link}. indexation.progression_with_error.link=tasks failing