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(
() => (
<Space align="center">
<Typography.Text
className="text-grey-muted"
data-testid="user-email-label">{`${t(
'label.email'
)} :`}</Typography.Text>
() =>
userData.email && (
<>
<Space align="center">
<Typography.Text
className="text-grey-muted"
data-testid="user-email-label">{`${t(
'label.email'
)} :`}</Typography.Text>
<Typography.Paragraph className="m-b-0" data-testid="user-email-value">
{userData.email}
</Typography.Paragraph>
</Space>
),
<Typography.Paragraph
className="m-b-0"
data-testid="user-email-value">
{userData.email}
</Typography.Paragraph>
</Space>
<Divider type="vertical" />
</>
),
[userData.email]
);

View File

@ -263,4 +263,20 @@ describe('Test User Profile Details Component', () => {
'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();
});
});