]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19728 Update indexation notification text
authorAmbroise C <ambroise.christea@sonarsource.com>
Wed, 23 Aug 2023 15:34:41 +0000 (17:34 +0200)
committersonartech <sonartech@sonarsource.com>
Fri, 25 Aug 2023 20:02:41 +0000 (20:02 +0000)
server/sonar-web/__mocks__/react-intl.tsx
server/sonar-web/src/main/js/app/components/indexation/IndexationNotificationRenderer.tsx
server/sonar-web/src/main/js/app/components/indexation/__tests__/IndexationNotificationRenderer-test.tsx
server/sonar-web/src/main/js/app/components/indexation/__tests__/__snapshots__/IndexationNotificationRenderer-test.tsx.snap [deleted file]
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 9e8c8170dd1f401c0970e089bfa345c3216e43b5..dbd784e1301ed3a8e44d892f86c9c4a461774e27 100644 (file)
@@ -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]) => (
-          <React.Fragment key={key}>{value}</React.Fragment>
-        ))}
+        {values !== undefined &&
+          Object.entries(values).map(([key, value]) => (
+            <React.Fragment key={key}>{value}</React.Fragment>
+          ))}
       </>
     );
   },
index bca3ce817897bf60043c240910d239aeae0ef746..db92ceaf415e1be1398f9fefa54c0e994b35d6ec 100644 (file)
@@ -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 (
     <>
-      <span className="spacer-right">{`${translate('indexation.in_progress')} ${translate(
-        'indexation.projects_unavailable'
-      )}`}</span>
+      <span className="spacer-right">
+        <FormattedMessage id="indexation.in_progress" />{' '}
+        <FormattedMessage
+          id="indexation.features_partly_available"
+          values={{
+            link: renderIndexationDocPageLink(),
+          }}
+        />
+      </span>
       <i className="spinner spacer-right" />
 
       <span className="spacer-right">
@@ -126,9 +133,15 @@ function renderInProgressBanner(completedCount: number, total: number) {
 function renderInProgressWithFailureBanner(completedCount: number, total: number) {
   return (
     <>
-      <span className="spacer-right">{`${translate('indexation.in_progress')} ${translate(
-        'indexation.projects_unavailable'
-      )}`}</span>
+      <span className="spacer-right">
+        <FormattedMessage id="indexation.in_progress" />{' '}
+        <FormattedMessage
+          id="indexation.features_partly_available"
+          values={{
+            link: renderIndexationDocPageLink(),
+          }}
+        />
+      </span>
       <i className="spinner spacer-right" />
 
       <span className="spacer-right">
@@ -166,3 +179,11 @@ function renderBackgroundTasksPageLink(hasError: boolean, text: string) {
     </Link>
   );
 }
+
+function renderIndexationDocPageLink() {
+  return (
+    <DocLink to="/instance-administration/reindexing/">
+      <FormattedMessage id="indexation.features_partly_available.link" />
+    </DocLink>
+  );
+}
index 0a807e3014937e457f65e5fbdf9678ef567a1ed3..fd7b757f8aa8df6bbf88dcc44da7ad49d6327f11 100644 (file)
  * 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<IndexationNotificationRendererProps> = {}) {
-  return shallow<IndexationNotificationRendererProps>(
-    <IndexationNotificationRenderer
-      completedCount={23}
-      total={42}
-      type={IndexationNotificationType.InProgress}
-      {...props}
-    />
-  );
+function renderIndexationNotificationRenderer(status: IndexationNotificationType) {
+  renderComponent(<IndexationNotificationRenderer completedCount={23} total={42} type={status} />);
 }
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 (file)
index 2217b78..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`should render correctly for type="Completed" 1`] = `
-<div
-  className="indexation-notification-wrapper"
->
-  <Alert
-    aria-live="assertive"
-    className="indexation-notification-banner"
-    display="banner"
-    variant="success"
-  >
-    <div
-      className="display-flex-center"
-    >
-      <span
-        className="spacer-right"
-      >
-        indexation.completed
-      </span>
-    </div>
-  </Alert>
-</div>
-`;
-
-exports[`should render correctly for type="CompletedWithFailure" 1`] = `
-<div
-  className="indexation-notification-wrapper"
->
-  <Alert
-    aria-live="assertive"
-    className="indexation-notification-banner"
-    display="banner"
-    variant="error"
-  >
-    <div
-      className="display-flex-center"
-    >
-      <span
-        className="spacer-right"
-      >
-        <FormattedMessage
-          defaultMessage="indexation.completed_with_error"
-          id="indexation.completed_with_error"
-          values={
-            {
-              "link": <ForwardRef(Link)
-                to={
-                  {
-                    "pathname": "/admin/background_tasks",
-                    "search": "?taskType=ISSUE_SYNC&status=FAILED",
-                  }
-                }
-              >
-                indexation.completed_with_error.link
-              </ForwardRef(Link)>,
-            }
-          }
-        />
-      </span>
-    </div>
-  </Alert>
-</div>
-`;
-
-exports[`should render correctly for type="InProgress" 1`] = `
-<div
-  className="indexation-notification-wrapper"
->
-  <Alert
-    aria-live="assertive"
-    className="indexation-notification-banner"
-    display="banner"
-    variant="warning"
-  >
-    <div
-      className="display-flex-center"
-    >
-      <span
-        className="spacer-right"
-      >
-        indexation.in_progress indexation.projects_unavailable
-      </span>
-      <i
-        className="spinner spacer-right"
-      />
-      <span
-        className="spacer-right"
-      >
-        indexation.progression.23.42
-      </span>
-      <span
-        className="spacer-right"
-      >
-        <FormattedMessage
-          defaultMessage="indexation.admin_link"
-          id="indexation.admin_link"
-          values={
-            {
-              "link": <ForwardRef(Link)
-                to={
-                  {
-                    "pathname": "/admin/background_tasks",
-                    "search": "?taskType=ISSUE_SYNC",
-                  }
-                }
-              >
-                background_tasks.page
-              </ForwardRef(Link)>,
-            }
-          }
-        />
-      </span>
-    </div>
-  </Alert>
-</div>
-`;
-
-exports[`should render correctly for type="InProgressWithFailure" 1`] = `
-<div
-  className="indexation-notification-wrapper"
->
-  <Alert
-    aria-live="assertive"
-    className="indexation-notification-banner"
-    display="banner"
-    variant="error"
-  >
-    <div
-      className="display-flex-center"
-    >
-      <span
-        className="spacer-right"
-      >
-        indexation.in_progress indexation.projects_unavailable
-      </span>
-      <i
-        className="spinner spacer-right"
-      />
-      <span
-        className="spacer-right"
-      >
-        <FormattedMessage
-          defaultMessage="indexation.progression_with_error.23.42"
-          id="indexation.progression_with_error"
-          values={
-            {
-              "link": <ForwardRef(Link)
-                to={
-                  {
-                    "pathname": "/admin/background_tasks",
-                    "search": "?taskType=ISSUE_SYNC&status=FAILED",
-                  }
-                }
-              >
-                indexation.progression_with_error.link
-              </ForwardRef(Link)>,
-            }
-          }
-        />
-      </span>
-    </div>
-  </Alert>
-</div>
-`;
index fa2dd3db8eb2b2c61b3d6a4cf318ea135a58fe8a..6387ddcdb20b2db5bed41b0cc2051e95edb6f9b5 100644 (file)
@@ -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