From e845804cceec56778fc5c50cef1da383fdbab6f2 Mon Sep 17 00:00:00 2001 From: ayesha waris <73840786+ayesha-waris@users.noreply.github.com> Date: Wed, 31 Jan 2024 18:18:54 +0500 Subject: [PATCH] fix: fixed redirection to learners tab in inContext view (#659) * fix: redirection to learners tab in inContext view * fix: changed username to simple text for incontext view * test: username is not clickable in incontext view --------- Co-authored-by: sohailfatima <23100065@lums.edu.pk> Co-authored-by: Fatima Sohail <68312464+sohailfatima@users.noreply.github.com> Co-authored-by: Awais Ansari <79941147+awais-ansari@users.noreply.github.com> --- src/discussions/common/AuthorLabel.jsx | 5 +++-- src/discussions/common/AuthorLabel.test.jsx | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) 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 () => {