Skip to content

Commit b2bd443

Browse files
committed
extend IAddInstanceErrorPayload to also include message so that it matches how it is called everywhere
fix Config.spec.tsx
1 parent 8b4099a commit b2bd443

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

redisinsight/ui/src/pages/rdi/pipeline-management/pages/config/Config.spec.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
22
import { cloneDeep } from 'lodash'
3-
import { AxiosError } from 'axios'
43
import {
54
rdiPipelineSelector,
65
setChangedFile,
@@ -25,7 +24,10 @@ import {
2524
TelemetryEvent,
2625
} from 'uiSrc/telemetry'
2726
import { FileChangeType } from 'uiSrc/slices/interfaces'
28-
import { addErrorNotification } from 'uiSrc/slices/app/notifications'
27+
import {
28+
addErrorNotification,
29+
IAddInstanceErrorPayload,
30+
} from 'uiSrc/slices/app/notifications'
2931
import Config from './Config'
3032

3133
jest.mock('uiSrc/telemetry', () => ({
@@ -90,7 +92,7 @@ describe('Config', () => {
9092

9193
render(<Config />)
9294

93-
expect(sendPageViewTelemetry).toBeCalledWith({
95+
expect(sendPageViewTelemetry).toHaveBeenCalledWith({
9496
name: TelemetryPageView.RDI_CONFIG,
9597
eventData: {
9698
rdiInstanceId: 'rdiInstanceId',
@@ -215,7 +217,7 @@ describe('Config', () => {
215217
),
216218
},
217219
},
218-
} as AxiosError),
220+
} as IAddInstanceErrorPayload),
219221
]
220222

221223
expect(store.getActions().slice(0, expectedActions.length)).toEqual(
@@ -248,8 +250,8 @@ describe('Config', () => {
248250
const { getByTestId } = render(<Config />)
249251

250252
// check is btn has loader
251-
const child = getByTestId('rdi-test-connection-btn').children[0].children[0]
252-
expect(child.tagName.toLowerCase()).toEqual('svg')
253+
const child = getByTestId('rdi-test-connection-btn')
254+
expect(child.querySelector('svg')).toBeTruthy()
253255
})
254256

255257
it('should render loader on btn', () => {
@@ -263,8 +265,8 @@ describe('Config', () => {
263265
const { getByTestId } = render(<Config />)
264266

265267
// check is btn has loader
266-
const child = getByTestId('rdi-test-connection-btn').children[0].children[0]
267-
expect(child.tagName.toLowerCase()).toEqual('svg')
268+
const child = getByTestId('rdi-test-connection-btn')
269+
expect(child.querySelector('svg')).toBeTruthy()
268270
})
269271

270272
it('should send telemetry event when clicking Test Connection button', async () => {

redisinsight/ui/src/pages/rdi/pipeline-management/pages/config/Config.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
import { appContextPipelineManagement } from 'uiSrc/slices/app/context'
3232
import { createAxiosError, isEqualPipelineFile, yamlToJson } from 'uiSrc/utils'
3333

34-
import { addErrorNotification } from 'uiSrc/slices/app/notifications'
34+
import { addErrorNotification, IAddInstanceErrorPayload } from 'uiSrc/slices/app/notifications'
3535
import { PrimaryButton } from 'uiSrc/components/base/forms/buttons'
3636
import { Text } from 'uiSrc/components/base/text'
3737

@@ -88,7 +88,7 @@ const Config = () => {
8888
addErrorNotification(
8989
createAxiosError({
9090
message: rdiErrorMessages.invalidStructure('config', msg),
91-
}),
91+
}) as IAddInstanceErrorPayload,
9292
),
9393
)
9494
})

redisinsight/ui/src/slices/app/notifications.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface IAddInstanceErrorPayload extends AxiosError {
3939
instanceId?: string
4040
response?: AxiosError['response'] & {
4141
data: {
42+
message?: string | JSX.Element
4243
title?: string
4344
additionalInfo?: Record<string, any>
4445
}

0 commit comments

Comments
 (0)