Skip to content

Commit

Permalink
variable name fix
Browse files Browse the repository at this point in the history
  • Loading branch information
AnujChhikara committed Dec 2, 2024
1 parent 13b5ef5 commit 1b6374e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import ProgressUpdateCardPresentation from '@/components/taskDetails/ProgressUpd
let initialProps: ProgressUpdateCardPresentationProps;
const titleToShow = mockGetTaskProgress.data[1].completed;
const username = 'mock-user-name';
const profileImageUrl = 'random-profile-pic-url';
const userProfileImageUrl = 'random-profile-pic-url';
const momentDate = moment(mockGetTaskProgress.data[2].createdAt);
const fullDate = momentDate.format('DD-MM-YY');
const time = momentDate.format('hh:mmA');
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('ProgressUpdateCardPresentation Component', () => {
mockedOnCardClick = jest.fn<void, [React.MouseEvent<HTMLElement>]>();
initialProps = {
username: username,
profileImageUrl: profileImageUrl,
userProfileImageUrl: userProfileImageUrl,
titleToShow: titleToShow,
isExpanded: false,
dateInAgoFormat: dateInAgoFormat,
Expand Down Expand Up @@ -241,33 +241,39 @@ describe('ProgressUpdateCardPresentation Component', () => {
);
expect(usernameElement).toBeInTheDocument();
expect(usernameElement.textContent).toContain('mock-user-name');
const profileImageUrlElement = screen.getByTestId(
const userProfileImageUrlElement = screen.getByTestId(
'progress-update-card-profile-picture'
);

expect(profileImageUrlElement).toBeInTheDocument();
expect(profileImageUrlElement).toHaveAttribute('src', profileImageUrl);
expect(profileImageUrlElement).toHaveAttribute('alt', 'Avatar');
expect(userProfileImageUrlElement).toBeInTheDocument();
expect(userProfileImageUrlElement).toHaveAttribute(
'src',
userProfileImageUrl
);
expect(userProfileImageUrlElement).toHaveAttribute('alt', 'Avatar');
});
it('should display the default avatar if profile url is empty', () => {
(useRouter as jest.Mock).mockReturnValue({
query: { dev: 'true' },
});
const props: ProgressUpdateCardPresentationProps = {
...initialProps,
profileImageUrl: '',
userProfileImageUrl: '',
};
renderWithRouter(
<Provider store={store()}>
<ProgressUpdateCardPresentation {...props} />
</Provider>
);
const profileImageUrlElement = screen.getByTestId(
const userProfileImageUrlElement = screen.getByTestId(
'progress-update-card-profile-picture'
);

expect(profileImageUrlElement).toBeInTheDocument();
expect(profileImageUrlElement).toHaveAttribute('src', DEFAULT_AVATAR);
expect(userProfileImageUrlElement).toBeInTheDocument();
expect(userProfileImageUrlElement).toHaveAttribute(
'src',
DEFAULT_AVATAR
);
});
it('should render the updater name as a link with the correct href', () => {
(useRouter as jest.Mock).mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function LatestProgressUpdateCard({
searchString: userId,
});
const username = userData?.user?.username ?? '';
const profileImageUrl = userData?.user?.picture?.url ?? '';
const userProfileImageUrl = userData?.user?.picture?.url ?? '';

const dateInAgoFormat = momentDate.fromNow();
const fullDate = momentDate.format('dddd, MMMM DD, YYYY, hh:mm A [GMT] Z');
Expand Down Expand Up @@ -81,7 +81,7 @@ export default function LatestProgressUpdateCard({
return (
<LatestProgressUpdateCardPresentation
username={username}
profileImageUrl={profileImageUrl}
userProfileImageUrl={userProfileImageUrl}
dataToShowState={dataToShowState}
tooltipText={tooltipText}
onMoreOrLessButtonClick={onMoreOrLessButtonClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { USER_MANAGEMENT_URL } from '@/constants/url';
import { DEFAULT_AVATAR } from '@/constants/url';
export default function LatestProgressUpdateCardPresentation({
username,
profileImageUrl,
userProfileImageUrl,
dataToShowState,
tooltipText,
onMoreOrLessButtonClick,
Expand Down Expand Up @@ -109,9 +109,9 @@ export default function LatestProgressUpdateCardPresentation({
>
<img
src={
profileImageUrl == ''
userProfileImageUrl == ''
? DEFAULT_AVATAR
: profileImageUrl
: userProfileImageUrl
}
alt={'Avatar'}
className={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default memo(function ProgressUpdateCard({
searchString: userId,
});
const username = userData?.user?.username ?? '';
const profileImageUrl = userData?.user?.picture?.url ?? '';
const userProfileImageUrl = userData?.user?.picture?.url ?? '';

const charactersToShow = 70;
const readMoreTitle = readMoreFormatter(data?.completed, charactersToShow);
Expand Down Expand Up @@ -81,7 +81,7 @@ export default memo(function ProgressUpdateCard({
return (
<ProgressUpdateCardPresentation
username={username}
profileImageUrl={profileImageUrl}
userProfileImageUrl={userProfileImageUrl}
dataToShowState={dataToShowState}
titleToShow={titleToShow}
onMoreOrLessButtonClick={onMoreOrLessButtonClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { DEFAULT_AVATAR, USER_MANAGEMENT_URL } from '@/constants/url';

export default function ProgressUpdateCardPresentation({
username,
profileImageUrl,
userProfileImageUrl,
titleToShow,
dateInAgoFormat,
tooltipString,
Expand Down Expand Up @@ -123,9 +123,9 @@ export default function ProgressUpdateCardPresentation({
>
<img
src={
profileImageUrl == ''
userProfileImageUrl == ''
? DEFAULT_AVATAR
: profileImageUrl
: userProfileImageUrl
}
alt={'Avatar'}
data-testid="progress-update-card-profile-picture"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
height: 32px;
border-radius: 50%;
object-fit: cover;
margin-right: 4px;
@media (width<=425px) {
width: 28px;
height: 28px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
.progress-update-card__profile-picture {
width: 32px;
height: 32px;
margin-right: 4px;
border-radius: 50%;
object-fit: cover;
@media (width<=425px) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type MouseEventType = (event: MouseEvent<HTMLElement>) => void;

export type ProgressUpdateCardPresentationProps = {
username: string;
profileImageUrl: string;
userProfileImageUrl: string;
titleToShow: string;
dateInAgoFormat: string;
tooltipString: string;
Expand All @@ -24,7 +24,7 @@ export type ProgressUpdateCardPresentationProps = {

export type LatestProgressUpdateCardPresentationProps = {
username: string;
profileImageUrl: string;
userProfileImageUrl: string;
dataToShowState: ProgressUpdateDataToShow[];
tooltipText: string;
onMoreOrLessButtonClick: (
Expand Down

0 comments on commit 1b6374e

Please sign in to comment.