diff --git a/src/discussions/learners/data/selectors.js b/src/discussions/learners/data/selectors.js index bf3ea98e8..0cacbd74c 100644 --- a/src/discussions/learners/data/selectors.js +++ b/src/discussions/learners/data/selectors.js @@ -14,5 +14,5 @@ export const selectLearnerSorting = () => state => state.learners.sortedBy; export const selectLearnerNextPage = () => state => state.learners.nextPage; export const selectLearnerAvatar = author => state => ( - state.learners.learnerProfiles[author]?.profileImage?.imageUrlLarge + state.learners.learnerProfiles[author]?.profileImage?.imageUrlSmall ); diff --git a/src/discussions/post-comments/PostCommentsView.test.jsx b/src/discussions/post-comments/PostCommentsView.test.jsx index 2de528732..c2f57a5e4 100644 --- a/src/discussions/post-comments/PostCommentsView.test.jsx +++ b/src/discussions/post-comments/PostCommentsView.test.jsx @@ -9,7 +9,9 @@ import { } from 'react-router-dom'; import { Factory } from 'rosie'; -import { camelCaseObject, initializeMockApp } from '@edx/frontend-platform'; +import { + camelCaseObject, getConfig, initializeMockApp, setConfig, +} from '@edx/frontend-platform'; import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth'; import { AppProvider } from '@edx/frontend-platform/react'; @@ -738,6 +740,20 @@ describe('ThreadView', () => { expect(screen.queryByTestId('comment-comment-4')) .toBeInTheDocument(); }); + + it('it show avatar for reply author when ENABLE_PROFILE_IMAGE is true', async () => { + setConfig({ + ...getConfig(), + ENABLE_PROFILE_IMAGE: 'true', + }); + await waitFor(() => renderComponent(discussionPostId)); + + const comment = await waitFor(() => screen.findByTestId('comment-comment-1')); + + expect(comment).toBeInTheDocument(); + const replyAuthorAvatar = within(comment).getAllByAltText('edx'); + expect(replyAuthorAvatar.length).toBeGreaterThan(0); + }); }); describe('for question thread', () => { diff --git a/src/discussions/post-comments/comments/comment/Comment.jsx b/src/discussions/post-comments/comments/comment/Comment.jsx index 7a0820744..6334bb637 100644 --- a/src/discussions/post-comments/comments/comment/Comment.jsx +++ b/src/discussions/post-comments/comments/comment/Comment.jsx @@ -46,7 +46,7 @@ const Comment = ({ const { id, parentId, childCount, abuseFlagged, endorsed, threadId, endorsedAt, endorsedBy, endorsedByLabel, renderedBody, voted, following, voteCount, authorLabel, author, createdAt, lastEdit, rawBody, closed, closedBy, closeReason, - editByLabel, closedByLabel, users: postUsers, + editByLabel, closedByLabel, users: commentUsers, } = comment; const intl = useIntl(); const hasChildren = childCount > 0; @@ -209,7 +209,7 @@ const Comment = ({ closed={closed} createdAt={createdAt} lastEdit={lastEdit} - postUsers={postUsers} + commentUsers={commentUsers} /> {isEditing ? ( { const colorClass = AvatarOutlineAndLabelColors[authorLabel]; const hasAnyAlert = useAlertBannerVisible({ @@ -31,7 +31,7 @@ const CommentHeader = ({ const authorAvatar = useSelector(selectAuthorAvatar(author)); const profileImage = getConfig()?.ENABLE_PROFILE_IMAGE === 'true' - ? Object.values(postUsers ?? {})[0]?.profile?.image + ? Object.values(commentUsers ?? {})[0]?.profile?.image : null; return ( @@ -43,7 +43,7 @@ const CommentHeader = ({ { timeago.register('time-locale', timeLocale); const { - id, abuseFlagged, author, authorLabel, endorsed, lastEdit, closed, closedBy, + id, abuseFlagged, author, authorLabel, endorsed, lastEdit, closed, closedBy, users: replyUsers, closeReason, createdAt, threadId, parentId, rawBody, renderedBody, editByLabel, closedByLabel, } = useSelector(selectCommentOrResponseById(responseId)); const intl = useIntl(); @@ -78,6 +79,10 @@ const Reply = ({ responseId }) => { [ContentActions.REPORT]: handleAbusedFlag, }), [handleEditContent, handleReplyEndorse, showDeleteConfirmation, handleAbusedFlag]); + const profileImage = getConfig()?.ENABLE_PROFILE_IMAGE === 'true' + ? Object.values(replyUsers ?? {})[0]?.profile?.image + : null; + return (
{ ({ })); jest.setTimeout(1000000); + +mergeConfig({ + LEARNING_BASE_URL: process.env.LEARNING_BASE_URL, + LEARNER_FEEDBACK_URL: process.env.LEARNER_FEEDBACK_URL, + STAFF_FEEDBACK_URL: process.env.STAFF_FEEDBACK_URL, + ENABLE_PROFILE_IMAGE: process.env.ENABLE_PROFILE_IMAGE || 'false', +}, 'DiscussionsConfig');