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>
+ ))}
</>
);
},
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';
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">
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">
</Link>
);
}
+
+function renderIndexationDocPageLink() {
+ return (
+ <DocLink to="/instance-administration/reindexing/">
+ <FormattedMessage id="indexation.features_partly_available.link" />
+ </DocLink>
+ );
+}
* 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} />);
}
+++ /dev/null
-// 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>
-`;
# 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