Clusters Style change during initializing phase + implement tests suites (#1787)
This commit is contained in:
parent
e113e36348
commit
15ef0364ca
3 changed files with 63 additions and 8 deletions
|
@ -12,7 +12,7 @@ export const Wrapper = styled.li.attrs({ role: 'menuitem' })<{
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: min-content min-content auto min-content;
|
grid-template-columns: min-content min-content auto min-content;
|
||||||
grid-template-areas: 'title status . chevron';
|
grid-template-areas: 'title status . chevron';
|
||||||
gap: 0px 5px;
|
gap: 0 5px;
|
||||||
|
|
||||||
padding: 0.5em 0.75em;
|
padding: 0.5em 0.75em;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -52,13 +52,20 @@ export const StatusIcon = styled.circle.attrs({
|
||||||
cx: 2,
|
cx: 2,
|
||||||
cy: 2,
|
cy: 2,
|
||||||
r: 2,
|
r: 2,
|
||||||
})<{ status: ServerStatus }>(
|
role: 'status-circle',
|
||||||
({ theme, status }) => css`
|
})<{ status: ServerStatus }>(({ theme, status }) => {
|
||||||
fill: ${status === ServerStatus.ONLINE
|
const statusColor: {
|
||||||
? theme.menu.statusIconColor.online
|
[k in ServerStatus]: string;
|
||||||
: theme.menu.statusIconColor.offline};
|
} = {
|
||||||
`
|
[ServerStatus.ONLINE]: theme.menu.statusIconColor.online,
|
||||||
);
|
[ServerStatus.OFFLINE]: theme.menu.statusIconColor.offline,
|
||||||
|
[ServerStatus.INITIALIZING]: theme.menu.statusIconColor.initializing,
|
||||||
|
};
|
||||||
|
|
||||||
|
return css`
|
||||||
|
fill: ${statusColor[status]};
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
|
||||||
export const ChevronWrapper = styled.svg.attrs({
|
export const ChevronWrapper = styled.svg.attrs({
|
||||||
viewBox: '0 0 10 6',
|
viewBox: '0 0 10 6',
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { render } from 'lib/testHelpers';
|
||||||
|
import theme from 'theme/theme';
|
||||||
|
import { screen } from '@testing-library/react';
|
||||||
|
import * as S from 'components/Nav/ClusterTab/ClusterTab.styled';
|
||||||
|
import { ServerStatus } from 'generated-sources';
|
||||||
|
|
||||||
|
describe('Cluster Styled Components', () => {
|
||||||
|
describe('Wrapper Component', () => {
|
||||||
|
it('should check the rendering and correct Styling when it is open', () => {
|
||||||
|
render(<S.Wrapper isOpen />);
|
||||||
|
expect(screen.getByRole('menuitem')).toHaveStyle(
|
||||||
|
`color:${theme.menu.color.isOpen}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
it('should check the rendering and correct Styling when it is Not open', () => {
|
||||||
|
render(<S.Wrapper isOpen={false} />);
|
||||||
|
expect(screen.getByRole('menuitem')).toHaveStyle(
|
||||||
|
`color:${theme.menu.color.normal}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('StatusIcon Component', () => {
|
||||||
|
it('should check the rendering and correct Styling when it is online', () => {
|
||||||
|
render(<S.StatusIcon status={ServerStatus.ONLINE} />);
|
||||||
|
|
||||||
|
expect(screen.getByRole('status-circle')).toHaveStyle(
|
||||||
|
`fill:${theme.menu.statusIconColor.online}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should check the rendering and correct Styling when it is offline', () => {
|
||||||
|
render(<S.StatusIcon status={ServerStatus.OFFLINE} />);
|
||||||
|
expect(screen.getByRole('status-circle')).toHaveStyle(
|
||||||
|
`fill:${theme.menu.statusIconColor.offline}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should check the rendering and correct Styling when it is Initializing', () => {
|
||||||
|
render(<S.StatusIcon status={ServerStatus.INITIALIZING} />);
|
||||||
|
expect(screen.getByRole('status-circle')).toHaveStyle(
|
||||||
|
`fill:${theme.menu.statusIconColor.initializing}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -225,6 +225,7 @@ const theme = {
|
||||||
statusIconColor: {
|
statusIconColor: {
|
||||||
online: Colors.green[40],
|
online: Colors.green[40],
|
||||||
offline: Colors.red[50],
|
offline: Colors.red[50],
|
||||||
|
initializing: Colors.yellow[20],
|
||||||
},
|
},
|
||||||
chevronIconColor: Colors.neutral[50],
|
chevronIconColor: Colors.neutral[50],
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue