Skip to content

Commit e845804

Browse files
ayesha-warissohailfatimaawais-ansari
authored
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 <[email protected]> Co-authored-by: Fatima Sohail <[email protected]> Co-authored-by: Awais Ansari <[email protected]>
1 parent f69b2c1 commit e845804

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/discussions/common/AuthorLabel.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const AuthorLabel = ({
2626
}) => {
2727
timeago.register('time-locale', timeLocale);
2828
const intl = useIntl();
29-
const { courseId } = useContext(DiscussionContext);
29+
const { courseId, enableInContextSidebar } = useContext(DiscussionContext);
3030
let icon = null;
3131
let authorLabelMessage = null;
3232

@@ -44,7 +44,8 @@ const AuthorLabel = ({
4444
const showTextPrimary = !authorLabelMessage && !isRetiredUser && !alert;
4545
const className = classNames('d-flex align-items-center', { 'mb-0.5': !postOrComment }, labelColor);
4646

47-
const showUserNameAsLink = linkToProfile && author && author !== intl.formatMessage(messages.anonymous);
47+
const showUserNameAsLink = linkToProfile && author && author !== intl.formatMessage(messages.anonymous)
48+
&& !enableInContextSidebar;
4849

4950
const authorName = useMemo(() => (
5051
<span

src/discussions/common/AuthorLabel.test.jsx

+13-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ let store;
2121
let axiosMock;
2222
let container;
2323

24-
function renderComponent(author, authorLabel, linkToProfile, labelColor) {
24+
function renderComponent(author, authorLabel, linkToProfile, labelColor, enableInContextSidebar) {
2525
const wrapper = render(
2626
<IntlProvider locale="en">
2727
<AppProvider store={store}>
28-
<DiscussionContext.Provider value={{ courseId }}>
28+
<DiscussionContext.Provider value={{ courseId, enableInContextSidebar }}>
2929
<AuthorLabel
3030
author={author}
3131
authorLabel={authorLabel}
@@ -78,9 +78,9 @@ describe('Author label', () => {
7878
);
7979

8080
it(
81-
`it is "${!linkToProfile && 'not'}" clickable when linkToProfile is ${!!linkToProfile}`,
81+
`it is "${(!linkToProfile) && 'not'}" clickable when linkToProfile is ${!!linkToProfile} and enableInContextSidebar is false`,
8282
async () => {
83-
renderComponent(author, authorLabel, linkToProfile, labelColor);
83+
renderComponent(author, authorLabel, linkToProfile, labelColor, false);
8484

8585
if (linkToProfile) {
8686
expect(screen.queryByTestId('learner-posts-link')).toBeInTheDocument();
@@ -90,6 +90,15 @@ describe('Author label', () => {
9090
},
9191
);
9292

93+
it(
94+
'it is not clickable when enableInContextSidebar is true',
95+
async () => {
96+
renderComponent(author, authorLabel, linkToProfile, labelColor, true);
97+
98+
expect(screen.queryByTestId('learner-posts-link')).not.toBeInTheDocument();
99+
},
100+
);
101+
93102
it(
94103
`it has "${!linkToProfile && 'not'}" label text and label color when linkToProfile is ${!!linkToProfile}`,
95104
async () => {

0 commit comments

Comments
 (0)