1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

feat: change request ui updates (#4574)

This commit is contained in:
Jaanus Sellin 2023-08-27 20:35:27 +03:00 committed by GitHub
parent cc62db46fb
commit b2aa3ea049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 30 deletions

View File

@ -25,7 +25,8 @@ export const ChangeItemWrapper = styled(Box)({
const ChangeItemCreateEditWrapper = styled(Box)(({ theme }) => ({
display: 'grid',
gridTemplateColumns: 'auto 40px',
gridTemplateColumns: 'auto auto',
justifyContent: 'space-between',
gap: theme.spacing(1),
alignItems: 'center',
marginBottom: theme.spacing(2),

View File

@ -17,7 +17,7 @@ test.each(['', undefined])(
).toBeNull();
// expect ins element with new strategy name
await screen.findByText(newName, { selector: 'ins' });
await screen.findByText(newName, { selector: 'p' });
}
);
@ -30,9 +30,7 @@ test.each(['', undefined])(
);
// expect no ins elements
expect(
screen.queryByText(newName || '', { selector: 'ins' })
).toBeNull();
expect(screen.queryByText(newName || '', { selector: 'p' })).toBeNull();
// expect del element with old strategy name
await screen.findByText(previousName, { selector: 'del' });
@ -50,25 +48,13 @@ test('Should render the old name as deleted and the new name as inserted if the
await screen.findByText(previousName, { selector: 'del' });
// expect ins element with new strategy name
await screen.findByText(newName, { selector: 'ins' });
});
test('Should render the name in a span if it has not changed', async () => {
const name = 'name';
render(<NameWithChangeInfo newName={name} previousName={name} />);
// expect no del or ins elements
expect(screen.queryByText(name, { selector: 'ins' })).toBeNull();
expect(screen.queryByText(name, { selector: 'del' })).toBeNull();
// expect span element with the strategy name
await screen.findByText(name, { selector: 'span' });
await screen.findByText(newName, { selector: 'p' });
});
test('Should render nothing if there was no name and there is still no name', async () => {
render(<NameWithChangeInfo newName={undefined} previousName={undefined} />);
expect(screen.queryByText('', { selector: 'ins' })).toBeNull();
expect(screen.queryByText('', { selector: 'p' })).toBeNull();
expect(screen.queryByText('', { selector: 'del' })).toBeNull();
expect(screen.queryByText('', { selector: 'span' })).toBeNull();
});

View File

@ -14,10 +14,6 @@ export const NameWithChangeInfo: FC<{
}> = ({ newName, previousName }) => {
const titleHasChanged = Boolean(previousName && previousName !== newName);
const titleHasChangedOrBeenAdded = Boolean(
titleHasChanged || (!previousName && newName)
);
return (
<>
<ConditionallyRender
@ -34,13 +30,7 @@ export const NameWithChangeInfo: FC<{
condition={Boolean(newName)}
show={
<Truncated>
<Typography
component={
titleHasChangedOrBeenAdded ? 'ins' : 'span'
}
>
{newName}
</Typography>
<Typography>{newName}</Typography>
</Truncated>
}
/>