Skip to content

Commit 5885a27

Browse files
authored
RI-7731: Adjust RDI: General info - update text (#5204)
* Fix General info data and component structure for responsiveness * add unit tests for the component * create and use factory for pipeline status data
1 parent 2f5e8c0 commit 5885a27

File tree

3 files changed

+100
-13
lines changed

3 files changed

+100
-13
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Factory } from 'fishery'
2+
import { faker } from '@faker-js/faker'
3+
4+
import {
5+
IRdiPipelineStatus,
6+
PipelineState,
7+
PipelineStatus,
8+
} from 'uiSrc/slices/interfaces'
9+
10+
export const rdiPipelineStatusFactory = Factory.define<IRdiPipelineStatus>(
11+
() => ({
12+
rdiVersion: faker.system.semver(),
13+
address: `${faker.internet.ip()}:${faker.internet.port()}`,
14+
runStatus: faker.helpers.arrayElement([
15+
PipelineStatus.Validating,
16+
PipelineStatus.Starting,
17+
PipelineStatus.Stopping,
18+
PipelineStatus.Resetting,
19+
PipelineStatus.Ready,
20+
PipelineStatus.NotReady,
21+
PipelineStatus.Stopped,
22+
]),
23+
syncMode: faker.helpers.arrayElement([
24+
PipelineState.CDC,
25+
PipelineState.InitialSync,
26+
PipelineState.NotRunning,
27+
]),
28+
}),
29+
)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React from 'react'
2+
3+
import { render, screen } from 'uiSrc/utils/test-utils'
4+
import { rdiPipelineStatusFactory } from 'uiSrc/mocks/factories/rdi/RdiPipelineStatus.factory'
5+
import Status from './Status'
6+
7+
const mockedProps = rdiPipelineStatusFactory.build()
8+
9+
describe('Status', () => {
10+
it('should render', () => {
11+
const { container } = render(<Status data={mockedProps} />)
12+
expect(container).toBeInTheDocument()
13+
})
14+
15+
it('should render the title correctly', () => {
16+
render(<Status data={mockedProps} />)
17+
expect(screen.getByText('General info')).toBeInTheDocument()
18+
})
19+
20+
it('should render all status labels correctly', () => {
21+
render(<Status data={mockedProps} />)
22+
23+
expect(screen.getByText('RDI version')).toBeInTheDocument()
24+
expect(screen.getByText('RDI database address')).toBeInTheDocument()
25+
expect(screen.getByText('Run status')).toBeInTheDocument()
26+
expect(screen.getByText('Sync mode')).toBeInTheDocument()
27+
})
28+
29+
it('should render with different data values', () => {
30+
const customProps = rdiPipelineStatusFactory.build({
31+
rdiVersion: '2.0.0',
32+
address: 'localhost:6380',
33+
runStatus: 'stopped',
34+
syncMode: 'initial-sync',
35+
})
36+
37+
render(<Status data={customProps} />)
38+
39+
expect(screen.getByText('2.0.0')).toBeInTheDocument()
40+
expect(screen.getByText('localhost:6380')).toBeInTheDocument()
41+
expect(screen.getByText('stopped')).toBeInTheDocument()
42+
expect(screen.getByText('initial-sync')).toBeInTheDocument()
43+
})
44+
45+
it('should handle empty string values', () => {
46+
const emptyProps = rdiPipelineStatusFactory.build({
47+
rdiVersion: '',
48+
address: '',
49+
runStatus: '',
50+
syncMode: '',
51+
})
52+
53+
render(<Status data={emptyProps} />)
54+
55+
expect(screen.getByText('RDI version')).toBeInTheDocument()
56+
expect(screen.getByText('RDI database address')).toBeInTheDocument()
57+
expect(screen.getByText('Run status')).toBeInTheDocument()
58+
expect(screen.getByText('Sync mode')).toBeInTheDocument()
59+
})
60+
})

redisinsight/ui/src/pages/rdi/statistics/status/Status.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ import { StyledPanel } from 'uiSrc/pages/rdi/statistics/status/styles'
88
import { Text, Title } from 'uiSrc/components/base/text'
99

1010
const StatusItem = ({ label, value }: { label: string; value: string }) => (
11-
<FlexItem grow>
12-
<Row gap="m" responsive>
13-
<FlexItem grow>
14-
<Text>{label}</Text>
15-
</FlexItem>
16-
<FlexItem grow>
17-
<Text color="primary">{value}</Text>
18-
</FlexItem>
19-
</Row>
20-
</FlexItem>
11+
<Row gap="m" responsive>
12+
<FlexItem grow>
13+
<Text>{label}</Text>
14+
</FlexItem>
15+
<FlexItem grow>
16+
<Text color="primary">{value}</Text>
17+
</FlexItem>
18+
</Row>
2119
)
2220

2321
interface Props {
@@ -34,13 +32,13 @@ const Status = ({ data }: Props) => {
3432
General info
3533
</Title>
3634
<Row gap="m" responsive>
37-
<StatusItem label="RDI DB Version" value={rdiVersion} />
35+
<StatusItem label="RDI version" value={rdiVersion} />
3836
<VerticalDivider />
39-
<StatusItem label="Address" value={address} />
37+
<StatusItem label="RDI database address" value={address} />
4038
<VerticalDivider />
4139
<StatusItem label="Run status" value={runStatus} />
4240
<VerticalDivider />
43-
<StatusItem label="Sync Mode" value={syncMode} />
41+
<StatusItem label="Sync mode" value={syncMode} />
4442
</Row>
4543
</Col>
4644
</StyledPanel>

0 commit comments

Comments
 (0)