diff --git a/public/tabs/chat/chat_page.test.tsx b/public/tabs/chat/chat_page.test.tsx index 01cf43dd..d768a183 100644 --- a/public/tabs/chat/chat_page.test.tsx +++ b/public/tabs/chat/chat_page.test.tsx @@ -9,8 +9,9 @@ import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import { coreMock } from '../../../../../src/core/public/mocks'; import { SessionLoadService } from '../../services/session_load_service'; import { ChatPage } from './chat_page'; -import * as contextExports from '../../contexts'; -import * as hookExports from '../../hooks'; +import * as chatContextExports from '../../contexts/chat_context'; +import * as coreContextExports from '../../contexts/core_context'; +import * as hookExports from '../../hooks/use_chat_state'; jest.mock('./controls/chat_input_controls', () => { return { ChatInputControls: () =>
}; @@ -32,13 +33,14 @@ describe('', () => { createdTimeMs: new Date().getTime(), updatedTimeMs: new Date().getTime(), messages: [], + interactions: [], }); const sessionLoadService = new SessionLoadService(coreMock.createStart().http); beforeEach(() => { jest.spyOn(sessionLoadService, 'load').mockImplementation(loadMock); - jest.spyOn(contextExports, 'useChatContext').mockReturnValue({ + jest.spyOn(chatContextExports, 'useChatContext').mockReturnValue({ sessionId: 'mocked_session_id', chatEnabled: true, }); @@ -48,7 +50,7 @@ describe('', () => { chatState: { messages: [], llmResponding: false }, }); - jest.spyOn(contextExports, 'useCore').mockReturnValue({ + jest.spyOn(coreContextExports, 'useCore').mockReturnValue({ services: { sessionLoad: sessionLoadService, }, @@ -65,12 +67,15 @@ describe('', () => { expect(loadMock).toHaveBeenCalledWith('mocked_session_id'); await waitFor(() => { - expect(dispatchMock).toHaveBeenCalledWith({ type: 'receive', payload: [] }); + expect(dispatchMock).toHaveBeenCalledWith({ + type: 'receive', + payload: { messages: [], interactions: [] }, + }); }); }); it('should NOT call reload if current conversation is not set', async () => { - jest.spyOn(contextExports, 'useChatContext').mockReturnValue({ + jest.spyOn(chatContextExports, 'useChatContext').mockReturnValue({ sessionId: undefined, chatEnabled: true, }); diff --git a/public/tabs/chat/controls/chat_input_controls.test.tsx b/public/tabs/chat/controls/chat_input_controls.test.tsx index 14d3286d..c15528d7 100644 --- a/public/tabs/chat/controls/chat_input_controls.test.tsx +++ b/public/tabs/chat/controls/chat_input_controls.test.tsx @@ -7,8 +7,8 @@ import React from 'react'; import { render, screen, fireEvent, waitFor, getByRole } from '@testing-library/react'; import { ChatInputControls } from './chat_input_controls'; -import * as contextExports from '../../../contexts'; -import * as hookExports from '../../../hooks'; +import * as contextExports from '../../../contexts/chat_context'; +import * as hookExports from '../../../hooks/use_chat_actions'; describe('', () => { const sendMock = jest.fn(); diff --git a/test/setup.jest.ts b/test/setup.jest.ts index ff545840..c7c9ed97 100644 --- a/test/setup.jest.ts +++ b/test/setup.jest.ts @@ -5,9 +5,7 @@ import { configure } from '@testing-library/react'; import { TextDecoder, TextEncoder } from 'util'; -import 'web-streams-polyfill'; import '@testing-library/jest-dom'; -import '../server/fetch-polyfill'; configure({ testIdAttribute: 'data-test-subj' });