Skip to content

Commit

Permalink
feat: display strategy title and type (#3908)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew committed Jun 6, 2023
1 parent 6ab62d5 commit 44f752e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
@@ -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
});
Expand Up @@ -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',
Expand Down Expand Up @@ -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)}
Expand Down

0 comments on commit 44f752e

Please sign in to comment.