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,19 +223,25 @@ const UserProfileDetails = ({
}; };
const userEmailRender = useMemo( const userEmailRender = useMemo(
() => ( () =>
<Space align="center"> userData.email && (
<Typography.Text <>
className="text-grey-muted" <Space align="center">
data-testid="user-email-label">{`${t( <Typography.Text
'label.email' className="text-grey-muted"
)} :`}</Typography.Text> data-testid="user-email-label">{`${t(
'label.email'
)} :`}</Typography.Text>
<Typography.Paragraph className="m-b-0" data-testid="user-email-value"> <Typography.Paragraph
{userData.email} className="m-b-0"
</Typography.Paragraph> data-testid="user-email-value">
</Space> {userData.email}
), </Typography.Paragraph>
</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();
});
}); });