Skip to content

Commit 6cf87e6

Browse files
Merge branch 'release/2.52.0' of https://github.com/RedisInsight/RedisInsight into fe/bugfix/RI-5856_incorrect_yaml
2 parents ab87695 + 5dffe0c commit 6cf87e6

File tree

12 files changed

+139
-20
lines changed

12 files changed

+139
-20
lines changed

redisinsight/api/src/modules/rdi/client/api.rdi.client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ export class ApiRdiClient extends RdiClient {
197197
const { status, data, error } = response.data;
198198

199199
if (status === 'failed') {
200-
throw new RdiPipelineInternalServerErrorException(error);
200+
throw new RdiPipelineInternalServerErrorException(error?.message);
201201
}
202202

203203
if (status === 'completed') {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React from 'react'
2+
import { act, render, screen } from 'uiSrc/utils/test-utils'
3+
4+
import { rdiDryRunJobSelector } from 'uiSrc/slices/rdi/dryRun'
5+
import DryRunJobCommands from './DryRunJobCommands'
6+
7+
jest.mock('uiSrc/slices/rdi/dryRun', () => ({
8+
...jest.requireActual('uiSrc/slices/rdi/dryRun'),
9+
rdiDryRunJobSelector: jest.fn().mockReturnValue({
10+
results: null,
11+
})
12+
}))
13+
14+
describe('DryRunJobCommands', () => {
15+
it('should render', () => {
16+
expect(render(<DryRunJobCommands />)).toBeTruthy()
17+
})
18+
19+
it('should render no commands message', async () => {
20+
const rdiDryRunJobSelectorMock = jest.fn().mockReturnValue({
21+
results: { output: {} },
22+
});
23+
(rdiDryRunJobSelector as jest.Mock).mockImplementationOnce(rdiDryRunJobSelectorMock)
24+
25+
await act(async () => {
26+
render(<DryRunJobCommands />)
27+
})
28+
29+
expect(screen.getByTestId('commands-output')).toHaveTextContent('No Redis commands provided.')
30+
})
31+
32+
it('should render transformations', async () => {
33+
const rdiDryRunJobSelectorMock = jest.fn().mockReturnValue({
34+
results: {
35+
output: [
36+
{
37+
connection: 'target',
38+
commands: [
39+
'HSET person:Yossi:Shirizli FNAME Yossi LAST_NAME Shirizli COUNTRY IL'
40+
]
41+
}
42+
],
43+
},
44+
});
45+
(rdiDryRunJobSelector as jest.Mock).mockImplementationOnce(rdiDryRunJobSelectorMock)
46+
47+
await act(async () => {
48+
render(<DryRunJobCommands target="target" />)
49+
})
50+
expect(screen.getByTestId('commands-output')).toHaveTextContent('HSET person:Yossi:Shirizli FNAME Yossi LAST_NAME Shirizli COUNTRY IL')
51+
})
52+
})

redisinsight/ui/src/pages/rdi/pipeline-management/components/dry-run-job-commands/DryRunJobCommands.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,28 @@ export interface Props {
1111
target?: string
1212
}
1313

14+
const NO_COMMANDS_MESSAGE = 'No Redis commands provided.'
15+
1416
const DryRunJobCommands = ({ target }: Props) => {
1517
const { results } = useSelector(rdiDryRunJobSelector)
1618
const [commands, setCommands] = useState<string>('')
1719

1820
useEffect(() => {
19-
const targetCommands = results?.output
20-
?.find((el) => el.connection === target)
21-
?.commands
21+
if (!results) {
22+
return
23+
}
2224

2325
try {
26+
const targetCommands = results?.output
27+
?.find((el) => el.connection === target)
28+
?.commands
29+
2430
monaco.editor.colorize((targetCommands ?? []).join('\n').trim(), MonacoLanguage.Redis, {})
2531
.then((data) => {
2632
setCommands(data)
2733
})
2834
} catch (e) {
29-
setCommands((targetCommands ?? []).join(''))
35+
setCommands(NO_COMMANDS_MESSAGE)
3036
}
3137
}, [results, target])
3238

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import React from 'react'
2+
import { render, screen } from 'uiSrc/utils/test-utils'
3+
4+
import { rdiDryRunJobSelector } from 'uiSrc/slices/rdi/dryRun'
5+
import DryRunJobTransformations from './DryRunJobTransformations'
6+
7+
jest.mock('uiSrc/slices/rdi/dryRun', () => ({
8+
...jest.requireActual('uiSrc/slices/rdi/dryRun'),
9+
rdiDryRunJobSelector: jest.fn().mockReturnValue({
10+
results: null,
11+
})
12+
}))
13+
14+
describe('DryRunJobTransformations', () => {
15+
it('should render', () => {
16+
expect(render(<DryRunJobTransformations />)).toBeTruthy()
17+
})
18+
19+
it('should render no transformation message', () => {
20+
const rdiDryRunJobSelectorMock = jest.fn().mockReturnValue({
21+
results: {},
22+
});
23+
(rdiDryRunJobSelector as jest.Mock).mockImplementationOnce(rdiDryRunJobSelectorMock)
24+
25+
render(<DryRunJobTransformations />)
26+
expect(screen.getByTestId('transformations-output')).toHaveTextContent('No transformation results provided.')
27+
})
28+
29+
it('should render transformations', () => {
30+
const rdiDryRunJobSelectorMock = jest.fn().mockReturnValue({
31+
results: { transformation: [] },
32+
});
33+
(rdiDryRunJobSelector as jest.Mock).mockImplementationOnce(rdiDryRunJobSelectorMock)
34+
35+
render(<DryRunJobTransformations />)
36+
expect(screen.getByTestId('transformations-output')).toHaveTextContent('[]')
37+
})
38+
})

redisinsight/ui/src/pages/rdi/pipeline-management/components/dry-run-job-transformations/DryRunJobTransformations.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ import { useSelector } from 'react-redux'
44
import { rdiDryRunJobSelector } from 'uiSrc/slices/rdi/dryRun'
55
import MonacoJson from 'uiSrc/components/monaco-editor/components/monaco-json'
66

7+
const NO_TRANSFORMATION_MESSAGE = 'No transformation results provided.'
8+
79
const DryRunJobTransformations = () => {
810
const { results } = useSelector(rdiDryRunJobSelector)
911

1012
const [transformations, setTransformations] = useState('')
1113

1214
useEffect(() => {
15+
if (!results) {
16+
return
17+
}
18+
1319
try {
1420
const transformations = JSON.stringify(results?.transformation, null, 2)
15-
setTransformations(transformations)
21+
setTransformations(transformations || NO_TRANSFORMATION_MESSAGE)
1622
} catch (e) {
17-
// ignore error
23+
setTransformations(NO_TRANSFORMATION_MESSAGE)
1824
}
1925
}, [results])
2026

redisinsight/ui/src/pages/rdi/pipeline-management/components/jobs-panel/Panel.spec.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ describe('JobsPanel', () => {
5353
expect(screen.getByTestId('dry-run-btn')).toBeDisabled()
5454

5555
// set valid json value
56-
fireEvent.change(screen.getByTestId('input-value'), { target: { value: 1 } })
56+
fireEvent.change(screen.getByTestId('input-value'), { target: { value: '[]' } })
5757

5858
expect(screen.getByTestId('dry-run-btn')).not.toBeDisabled()
5959
})
6060

6161
it('should call proper telemetry events', () => {
6262
render(<JobsPanel {...instance(mockedProps)} />)
6363

64-
fireEvent.change(screen.getByTestId('input-value'), { target: { value: 1 } })
64+
fireEvent.change(screen.getByTestId('input-value'), { target: { value: '[]' } })
6565
fireEvent.click(screen.getByTestId('dry-run-btn'))
6666

6767
expect(sendEventTelemetry).toBeCalledWith({
@@ -92,7 +92,7 @@ describe('JobsPanel', () => {
9292
it('should fetch dry run job results', () => {
9393
render(<JobsPanel {...instance(mockedProps)} />)
9494

95-
fireEvent.change(screen.getByTestId('input-value'), { target: { value: 1 } })
95+
fireEvent.change(screen.getByTestId('input-value'), { target: { value: '[]' } })
9696
fireEvent.click(screen.getByTestId('dry-run-btn'))
9797

9898
const expectedActions = [

redisinsight/ui/src/pages/rdi/pipeline-management/components/jobs-panel/Panel.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from '@elastic/eui'
1414
import { useDispatch, useSelector } from 'react-redux'
1515
import { useParams } from 'react-router-dom'
16+
import { isArray } from 'lodash'
1617

1718
import { PipelineJobsTabs } from 'uiSrc/slices/interfaces/rdi'
1819
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
@@ -64,8 +65,8 @@ const DryRunJobPanel = (props: Props) => {
6465

6566
useEffect(() => {
6667
try {
67-
JSON.parse(input)
68-
setIsFormValid(true)
68+
const jsonValue = JSON.parse(input)
69+
setIsFormValid(isArray(jsonValue))
6970
} catch (e) {
7071
setIsFormValid(false)
7172
}
@@ -77,9 +78,11 @@ const DryRunJobPanel = (props: Props) => {
7778
}, [])
7879

7980
useEffect(() => {
80-
if (!results?.output) return
81+
if (!results?.output || !isArray(results.output)) return
8182

82-
const targets = results.output.map(({ connection }) => getTargetOption(connection))
83+
const targets = results.output
84+
.filter(({ connection }) => connection)
85+
.map(({ connection }) => getTargetOption(connection))
8386
setTargetOptions(targets)
8487
setSelectedTarget(targets[0]?.value)
8588
}, [results])
@@ -113,6 +116,7 @@ const DryRunJobPanel = (props: Props) => {
113116
const isSelectAvailable = selectedTab === PipelineJobsTabs.Output
114117
&& !!results?.output
115118
&& (results?.output?.length > 1)
119+
&& !!targetOptions.length
116120

117121
const Tabs = useCallback(() => (
118122
<EuiTabs className={styles.tabs}>

redisinsight/ui/src/pages/rdi/statistics/StatisticsPage.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ describe('StatisticsPage', () => {
128128
it('renders the empty state when pipeline data is empty', () => {
129129
(rdiPipelineStatusSelector as jest.Mock).mockReturnValueOnce({
130130
data: {
131-
components: { processor: 'ready' },
131+
components: { processor: 'not-ready' },
132132
pipelines: {
133133
default: {
134-
status: 'not ready',
134+
status: 'not-ready',
135135
state: 'some',
136136
tasks: 'none',
137137
}

redisinsight/ui/src/pages/rdi/statistics/StatisticsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const isPipelineDeployed = (data: Nullable<IPipelineStatus>) => {
2626
return false
2727
}
2828

29-
return get(data, 'pipelines.default.status') === PipelineStatus.Ready
29+
return get(data, 'pipelines.default.status') !== PipelineStatus.NotReady
3030
}
3131

3232
const StatisticsPage = () => {

redisinsight/ui/src/slices/interfaces/rdi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export interface InitialStateRdiInstances {
192192

193193
// Rdi test target connections
194194
export enum TestConnectionStatus {
195-
Fail = 'fail',
195+
Fail = 'failed',
196196
Success = 'success',
197197
}
198198

0 commit comments

Comments
 (0)