-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update TestState component to include progress bar (#507)
- Loading branch information
Showing
14 changed files
with
183 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Typography} from 'antd'; | ||
import styled from 'styled-components'; | ||
|
||
export const Container = styled.div<{hasMinWidth?: boolean}>` | ||
display: flex; | ||
flex-direction: column; | ||
height: 28px; | ||
justify-content: center; | ||
max-width: 204px; | ||
min-width: ${({hasMinWidth}) => hasMinWidth && '115px'}; | ||
.ant-progress { | ||
font-size: 6px; | ||
line-height: 6px; | ||
} | ||
`; | ||
|
||
export const Text = styled(Typography.Text)` | ||
color: rgba(3, 24, 73, 0.3); | ||
font-size: 12px; | ||
margin-top: 2px; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import TestStateBadge from './TestStateBadge'; | ||
import TestStateProgress from './TestStateProgress'; | ||
import {TestStateMap} from '../../constants/TestRunResult.constants'; | ||
import {ITestRunResult} from '../../types/TestRunResult.types'; | ||
|
||
interface IProps { | ||
testState: ITestRunResult['state']; | ||
} | ||
|
||
const TestState = ({testState}: IProps) => { | ||
const {label, percent, status} = TestStateMap[testState]; | ||
|
||
return percent ? ( | ||
<TestStateProgress label={label} percent={percent} /> | ||
) : ( | ||
<TestStateBadge label={label} status={status} /> | ||
); | ||
}; | ||
|
||
export default TestState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {Badge} from 'antd'; | ||
import * as S from './TestState.styled'; | ||
|
||
interface IProps { | ||
label: string; | ||
status: 'success' | 'processing' | 'error' | 'default' | 'warning'; | ||
} | ||
|
||
const TestStateBadge = ({label, status}: IProps) => ( | ||
<S.Container> | ||
<Badge status={status} text={label} /> | ||
</S.Container> | ||
); | ||
|
||
export default TestStateBadge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {Progress} from 'antd'; | ||
import * as S from './TestState.styled'; | ||
|
||
interface IProps { | ||
label: string; | ||
percent: number; | ||
} | ||
|
||
const TestStateProgress = ({label, percent}: IProps) => ( | ||
<S.Container hasMinWidth> | ||
<Progress | ||
percent={percent} | ||
showInfo={false} | ||
status="active" | ||
strokeLinecap="square" | ||
strokeWidth={6} | ||
trailColor="rgba(154, 163, 171, 0.3)" | ||
/> | ||
<S.Text>{label}</S.Text> | ||
</S.Container> | ||
); | ||
|
||
export default TestStateProgress; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import {render} from '@testing-library/react'; | ||
import TestState from '../TestState'; | ||
import {TestState as TestStateEnum, TestStateMap} from '../../../constants/TestRunResult.constants'; | ||
|
||
describe('TestState', () => { | ||
it('should render badge component', () => { | ||
const {container, getByText} = render(<TestState testState={TestStateEnum.CREATED} />); | ||
const badge = container.getElementsByClassName('ant-badge'); | ||
|
||
expect(badge.length).toBe(1); | ||
expect(getByText(TestStateMap.CREATED.label)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render progress component', () => { | ||
const {container, getByText} = render(<TestState testState={TestStateEnum.EXECUTING} />); | ||
const progress = container.getElementsByClassName('ant-progress'); | ||
|
||
expect(progress.length).toBe(1); | ||
expect(getByText(TestStateMap.EXECUTING.label)).toBeInTheDocument(); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
web/src/components/TestStateBadge/index.ts → web/src/components/TestState/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// eslint-disable-next-line no-restricted-exports | ||
export {default} from './TestStateBadge'; | ||
export {default} from './TestState'; |
Oops, something went wrong.