Skip to content

Commit

Permalink
fix: fixed redirection to learners tab in inContext view (#680)
Browse files Browse the repository at this point in the history
* 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: ayesha waris <[email protected]>
Co-authored-by: sohailfatima <[email protected]>
Co-authored-by: Fatima Sohail <[email protected]>
Co-authored-by: Awais Ansari <[email protected]>
  • Loading branch information
5 people committed Mar 21, 2024
1 parent 5ca0042 commit efa0c1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/discussions/common/AuthorLabel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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;

Expand All @@ -47,7 +47,7 @@ const AuthorLabel = ({
const className = classNames('d-flex align-items-center', { 'mb-0.5': !postOrComment }, labelColor);

const showUserNameAsLink = useShowLearnersTab()
&& linkToProfile && author && author !== intl.formatMessage(messages.anonymous);
&& linkToProfile && author && author !== intl.formatMessage(messages.anonymous) && !enableInContextSidebar;

const authorName = useMemo(() => (
<span
Expand Down
17 changes: 13 additions & 4 deletions src/discussions/common/AuthorLabel.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ let store;
let axiosMock;
let container;

function renderComponent(author, authorLabel, linkToProfile, labelColor) {
function renderComponent(author, authorLabel, linkToProfile, labelColor, enableInContextSidebar) {
const wrapper = render(
<IntlProvider locale="en">
<AppProvider store={store}>
<DiscussionContext.Provider value={{ courseId }}>
<DiscussionContext.Provider value={{ courseId, enableInContextSidebar }}>
<AuthorLabel
author={author}
authorLabel={authorLabel}
Expand Down Expand Up @@ -79,9 +79,9 @@ describe('Author label', () => {
);

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();
Expand All @@ -91,6 +91,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 () => {
Expand Down

0 comments on commit efa0c1c

Please sign in to comment.