diff --git a/src/discussions/common/AuthorLabel.jsx b/src/discussions/common/AuthorLabel.jsx index e30577c6..e50bcf16 100644 --- a/src/discussions/common/AuthorLabel.jsx +++ b/src/discussions/common/AuthorLabel.jsx @@ -26,7 +26,7 @@ const AuthorLabel = ({ }) => { timeago.register('time-locale', timeLocale); const intl = useIntl(); - const { courseId } = useContext(DiscussionContext); + const { courseId, enableInContextSidebar } = useContext(DiscussionContext); let icon = null; let authorLabelMessage = null; @@ -44,7 +44,8 @@ const AuthorLabel = ({ const showTextPrimary = !authorLabelMessage && !isRetiredUser && !alert; const className = classNames('d-flex align-items-center', { 'mb-0.5': !postOrComment }, labelColor); - const showUserNameAsLink = linkToProfile && author && author !== intl.formatMessage(messages.anonymous); + const showUserNameAsLink = linkToProfile && author && author !== intl.formatMessage(messages.anonymous) + && !enableInContextSidebar; const authorName = useMemo(() => ( - + { ); it( - `it is "${!linkToProfile && 'not'}" clickable when linkToProfile is ${!!linkToProfile}`, + `it is "${(!linkToProfile) && 'not'}" clickable when linkToProfile is ${!!linkToProfile} and enableInContextSidebar is false`, async () => { - renderComponent(author, authorLabel, linkToProfile, labelColor); + renderComponent(author, authorLabel, linkToProfile, labelColor, false); if (linkToProfile) { expect(screen.queryByTestId('learner-posts-link')).toBeInTheDocument(); @@ -90,6 +90,15 @@ describe('Author label', () => { }, ); + it( + 'it is not clickable when enableInContextSidebar is true', + async () => { + renderComponent(author, authorLabel, linkToProfile, labelColor, true); + + expect(screen.queryByTestId('learner-posts-link')).not.toBeInTheDocument(); + }, + ); + it( `it has "${!linkToProfile && 'not'}" label text and label color when linkToProfile is ${!!linkToProfile}`, async () => {