fix(ui): hide email if not present in the data (#15927)

This commit is contained in:
Chirag Madlani 2024-04-17 15:30:37 +05:30 committed by GitHub
parent 6c44308ba4
commit f4ebfbbfc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 12 deletions

View File

@ -223,7 +223,9 @@ const UserProfileDetails = ({
}; };
const userEmailRender = useMemo( const userEmailRender = useMemo(
() => ( () =>
userData.email && (
<>
<Space align="center"> <Space align="center">
<Typography.Text <Typography.Text
className="text-grey-muted" className="text-grey-muted"
@ -231,10 +233,14 @@ const UserProfileDetails = ({
'label.email' 'label.email'
)} :`}</Typography.Text> )} :`}</Typography.Text>
<Typography.Paragraph className="m-b-0" data-testid="user-email-value"> <Typography.Paragraph
className="m-b-0"
data-testid="user-email-value">
{userData.email} {userData.email}
</Typography.Paragraph> </Typography.Paragraph>
</Space> </Space>
<Divider type="vertical" />
</>
), ),
[userData.email] [userData.email]
); );

View File

@ -263,4 +263,20 @@ describe('Test User Profile Details Component', () => {
'defaultPersona' 'defaultPersona'
); );
}); });
it('should not render if not present', async () => {
render(
<UserProfileDetails
{...mockPropsData}
userData={{ ...USER_DATA, email: '' }}
/>,
{
wrapper: MemoryRouter,
}
);
// user email
expect(screen.queryByTestId('user-email-label')).not.toBeInTheDocument();
expect(screen.queryByTestId('user-email-value')).not.toBeInTheDocument();
});
}); });