Skip to content

Commit 2e8c52f

Browse files
committed
fix tests
1 parent d8f73c0 commit 2e8c52f

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

redisinsight/ui/src/components/side-panels/panels/ai-assistant/components/assistance-chat/AssistanceChat.spec.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import React from 'react'
22
import { cloneDeep } from 'lodash'
3-
import { act, cleanup, fireEvent, mockedStore, render, screen, waitForEuiPopoverVisible } from 'uiSrc/utils/test-utils'
3+
import {
4+
act,
5+
cleanup,
6+
fireEvent,
7+
mockedStore,
8+
mockedStoreFn,
9+
render,
10+
screen,
11+
waitForEuiPopoverVisible
12+
} from 'uiSrc/utils/test-utils'
413

514
import {
615
aiAssistantChatSelector,
@@ -28,25 +37,25 @@ jest.mock('uiSrc/slices/panels/aiAssistant', () => ({
2837
let store: typeof mockedStore
2938
beforeEach(() => {
3039
cleanup()
31-
store = cloneDeep(mockedStore)
40+
store = cloneDeep(mockedStoreFn())
3241
store.clearActions()
3342
})
3443

3544
describe('AssistanceChat', () => {
3645
it('should render', () => {
37-
expect(render(<AssistanceChat />)).toBeTruthy()
46+
expect(render(<AssistanceChat />, { store })).toBeTruthy()
3847
})
3948

4049
it('should proper components render by default', () => {
41-
render(<AssistanceChat />)
50+
render(<AssistanceChat />, { store })
4251

4352
expect(screen.getByTestId('ai-general-restart-session-btn')).toBeInTheDocument()
4453
expect(screen.getByTestId('ai-chat-empty-history')).toBeInTheDocument()
4554
expect(screen.getByTestId('ai-submit-message-btn')).toBeInTheDocument()
4655
})
4756

4857
it('should call proper actions by default', () => {
49-
render(<AssistanceChat />)
58+
render(<AssistanceChat />, { store })
5059

5160
expect(store.getActions()).toEqual([])
5261
})
@@ -56,7 +65,7 @@ describe('AssistanceChat', () => {
5665
id: '1',
5766
messages: []
5867
})
59-
render(<AssistanceChat />)
68+
render(<AssistanceChat />, { store })
6069

6170
expect(store.getActions()).toEqual([getAssistantChatHistory()])
6271
})
@@ -66,7 +75,7 @@ describe('AssistanceChat', () => {
6675
id: '',
6776
messages: []
6877
})
69-
render(<AssistanceChat />)
78+
render(<AssistanceChat />, { store })
7079

7180
act(() => {
7281
fireEvent.change(
@@ -88,7 +97,7 @@ describe('AssistanceChat', () => {
8897
id: '1',
8998
messages: []
9099
})
91-
render(<AssistanceChat />)
100+
render(<AssistanceChat />, { store })
92101

93102
const afterRenderActions = [...store.getActions()]
94103

@@ -124,7 +133,7 @@ describe('AssistanceChat', () => {
124133
messages: [{}]
125134
})
126135

127-
render(<AssistanceChat />)
136+
render(<AssistanceChat />, { store })
128137

129138
const afterRenderActions = [...store.getActions()]
130139

0 commit comments

Comments
 (0)