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

feat: display strategy title and type (#3908)

This commit is contained in:
Mateusz Kwasniewski 2023-06-06 15:04:55 +02:00 committed by GitHub
parent 6ab62d5bfa
commit 44f752e714
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 5 deletions

View File

@ -0,0 +1,34 @@
import { screen } from '@testing-library/react';
import { render } from 'utils/testRenderer';
import { StrategyItemContainer } from './StrategyItemContainer';
import { IFeatureStrategy } from 'interfaces/strategy';
import { testServerRoute, testServerSetup } from 'utils/testServer';
import { UIProviderContainer } from '../../providers/UIProvider/UIProviderContainer';
const server = testServerSetup();
testServerRoute(server, '/api/admin/ui-config', {
flags: { strategyImprovements: true },
});
test('should render strategy name, custom title and description', async () => {
const strategy: IFeatureStrategy = {
id: 'irrelevant',
name: 'strategy name',
title: 'custom title',
constraints: [],
parameters: {},
};
render(
<UIProviderContainer>
<StrategyItemContainer
strategy={strategy}
description={'description'}
/>
</UIProviderContainer>
);
expect(screen.getByText('strategy name')).toBeInTheDocument();
expect(screen.getByText('description')).toBeInTheDocument();
await screen.findByText('custom title'); // behind async flag
});

View File

@ -50,6 +50,13 @@ const StyledDescription = styled('div')(({ theme }) => ({
display: 'block',
},
}));
const StyledCustomTitle = styled('div')(({ theme }) => ({
fontWeight: 'normal',
display: 'none',
[theme.breakpoints.up('md')]: {
display: 'block',
},
}));
const StyledHeaderContainer = styled('div')({
flexDirection: 'column',
justifyContent: 'center',
@ -141,11 +148,19 @@ export const StrategyItemContainer: FC<IStrategyItemContainerProps> = ({
<StringTruncator
maxWidth="400"
maxLength={15}
text={formatStrategyName(
uiConfig?.flags?.strategyImprovements
? strategy.title || strategy.name
: strategy.name
)}
text={formatStrategyName(strategy.name)}
/>
<ConditionallyRender
condition={
Boolean(
uiConfig?.flags?.strategyImprovements
) && Boolean(strategy.title)
}
show={
<StyledCustomTitle>
{formatStrategyName(String(strategy.title))}
</StyledCustomTitle>
}
/>
<ConditionallyRender
condition={Boolean(description)}