Skip to content

Commit 03b0500

Browse files
#RI-5750 - update rdi with latest changes
1 parent 33f457d commit 03b0500

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,17 @@ interface IErrorDetail {
213213
message: string;
214214
}
215215

216-
interface ISourceDetail {
216+
interface ITargetDetail {
217217
status: TestConnectionStatus;
218218
error?: IErrorDetail;
219219
}
220220

221-
export interface ISources {
222-
[key: string]: ISourceDetail;
221+
export interface ITargets {
222+
[key: string]: ITargetDetail;
223223
}
224224

225225
export interface TestConnectionsResponse {
226-
sources: ISources
226+
targets: ITargets
227227
}
228228

229229
export interface IRdiConnectionResult {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function testConnectionsAction(
8888
testConnectionsController = null
8989

9090
if (isStatusSuccessful(status)) {
91-
dispatch(testConnectionsSuccess(transformConnectionResults(data?.sources)))
91+
dispatch(testConnectionsSuccess(transformConnectionResults(data?.targets)))
9292
onSuccessAction?.()
9393
}
9494
} catch (_err) {

redisinsight/ui/src/slices/tests/rdi/pipeline.spec.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ import reducer, {
2626
deployPipelineAction,
2727
fetchRdiPipelineSchema,
2828
fetchPipelineStrategies,
29-
fetchPipelineTemplate,
29+
fetchConfigTemplate,
30+
fetchJobTemplate,
3031
setJobFunctions,
3132
fetchRdiPipelineJobFunctions,
3233
getPipelineStatusAction,
@@ -689,9 +690,8 @@ describe('rdi pipe slice', () => {
689690
})
690691
})
691692

692-
describe('fetchPipelineTemplate', () => {
693+
describe('fetchJobTemplate', () => {
693694
it('failed to fetch data', async () => {
694-
const mockOptions = { dbType: 'db type' }
695695
const errorMessage = 'Something was wrong!'
696696
const responsePayload = {
697697
response: {
@@ -704,7 +704,33 @@ describe('rdi pipe slice', () => {
704704

705705
// Act
706706
await store.dispatch<any>(
707-
fetchPipelineTemplate('123', mockOptions)
707+
fetchJobTemplate('123', 'db_type')
708+
)
709+
710+
// Assert
711+
const expectedActions = [
712+
addErrorNotification(responsePayload as AxiosError),
713+
]
714+
715+
expect(store.getActions()).toEqual(expectedActions)
716+
})
717+
})
718+
719+
describe('fetchConfigTemplate', () => {
720+
it('failed to fetch data', async () => {
721+
const errorMessage = 'Something was wrong!'
722+
const responsePayload = {
723+
response: {
724+
status: 500,
725+
data: { message: errorMessage },
726+
},
727+
}
728+
729+
apiService.get = jest.fn().mockRejectedValue(responsePayload)
730+
731+
// Act
732+
await store.dispatch<any>(
733+
fetchConfigTemplate('123', 'ingest','db_type')
708734
)
709735

710736
// Assert

redisinsight/ui/src/slices/tests/rdi/testConnections.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { apiService } from 'uiSrc/services'
1313
import { addErrorNotification } from 'uiSrc/slices/app/notifications'
1414

1515
const mockData = {
16-
sources: {
16+
targets: {
1717
target: {
1818
status: 'success',
1919
}
@@ -54,14 +54,15 @@ describe('rdi test connections slice', () => {
5454
describe('testConnectionsSuccess', () => {
5555
it('should properly set state', () => {
5656
// Arrange
57+
const data = { success: [{ target: 'target' }], fail: [] }
5758
const state = {
5859
...initialState,
59-
results: mockData,
60+
results: data,
6061
loading: false,
6162
}
6263

6364
// Act
64-
const nextState = reducer(initialState, testConnectionsSuccess(mockData))
65+
const nextState = reducer(initialState, testConnectionsSuccess(data))
6566

6667
// Assert
6768
const rootState = Object.assign(initialStateDefault, {

redisinsight/ui/src/utils/transformers/transformRdiPipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const pipelineToJson = ({ config, jobs }: IPipeline): IPipelineJSON => <I
1919

2020
export const transformConnectionResults = (sources: ISources): TransformResult => {
2121
const result: TransformResult = { success: [], fail: [] }
22-
22+
console.log(sources)
2323
if (!sources) {
2424
return result
2525
}

0 commit comments

Comments
 (0)