mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 05:34:05 -08:00
React UI: Starting Screen Progress Bar Should Start at 0 (#8908)
* Removed min value Signed-off-by: Levi Harrison <git@leviharrison.dev> * Added tests Signed-off-by: Levi Harrison <git@leviharrison.dev> * Set min value Signed-off-by: Levi Harrison <git@leviharrison.dev>
This commit is contained in:
parent
7bc11dcb06
commit
d44b4c5f1d
45
web/ui/react-app/src/pages/starting/Starting.test.tsx
Normal file
45
web/ui/react-app/src/pages/starting/Starting.test.tsx
Normal file
|
@ -0,0 +1,45 @@
|
|||
import * as React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { WALReplayData } from '../../types/types';
|
||||
import { StartingContent } from './Starting';
|
||||
import { Progress } from 'reactstrap';
|
||||
|
||||
describe('Starting', () => {
|
||||
describe('progress bar', () => {
|
||||
it('does not show when replay not started', () => {
|
||||
const status: WALReplayData = {
|
||||
min: 0,
|
||||
max: 0,
|
||||
current: 0,
|
||||
};
|
||||
const starting = shallow(<StartingContent status={status} isUnexpected={false} />);
|
||||
const progress = starting.find(Progress);
|
||||
expect(progress).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('renders progress correctly', () => {
|
||||
const status: WALReplayData = {
|
||||
min: 0,
|
||||
max: 20,
|
||||
current: 1,
|
||||
};
|
||||
const starting = shallow(<StartingContent status={status} isUnexpected={false} />);
|
||||
const progress = starting.find(Progress);
|
||||
expect(progress.prop('value')).toBe(2);
|
||||
expect(progress.prop('min')).toBe(0);
|
||||
expect(progress.prop('max')).toBe(21);
|
||||
});
|
||||
|
||||
it('shows done when replay done', () => {
|
||||
const status: WALReplayData = {
|
||||
min: 0,
|
||||
max: 20,
|
||||
current: 20,
|
||||
};
|
||||
const starting = shallow(<StartingContent status={status} isUnexpected={false} />);
|
||||
const progress = starting.find(Progress);
|
||||
expect(progress.prop('value')).toBe(21);
|
||||
expect(progress.prop('color')).toBe('success');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -31,9 +31,9 @@ export const StartingContent: FC<StartingContentProps> = ({ status, isUnexpected
|
|||
</p>
|
||||
<Progress
|
||||
animated
|
||||
value={status?.current}
|
||||
value={status?.current! - status?.min! + 1}
|
||||
min={status?.min}
|
||||
max={status?.max}
|
||||
max={status?.max! - status?.min! + 1}
|
||||
color={status?.max === status?.current ? 'success' : undefined}
|
||||
style={{ width: '10%', margin: 'auto' }}
|
||||
/>
|
||||
|
|
Loading…
Reference in a new issue