From 586b83ab2b0ce09987795fc0542ca1619b2dde1a Mon Sep 17 00:00:00 2001 From: Marcos Date: Fri, 8 Nov 2024 18:04:06 -0300 Subject: [PATCH] fix: Fixed tests and made chat history error silent --- src/data/thunks.js | 3 +-- src/widgets/Xpert.test.jsx | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/data/thunks.js b/src/data/thunks.js index ea9007d5..891c0f4d 100644 --- a/src/data/thunks.js +++ b/src/data/thunks.js @@ -83,7 +83,6 @@ export function clearMessages() { export function getLearningAssistantMessageHistory(courseId) { return async (dispatch) => { - dispatch(resetApiError()); dispatch(setApiIsLoading(true)); try { @@ -102,7 +101,7 @@ export function getLearningAssistantMessageHistory(courseId) { dispatch(setDisclosureAcknowledged(true)); } } catch (e) { - dispatch(setApiError()); + // If fetching the messages fail, we just won't show it. } dispatch(setApiIsLoading(false)); diff --git a/src/widgets/Xpert.test.jsx b/src/widgets/Xpert.test.jsx index f1ecede5..4fb133e3 100644 --- a/src/widgets/Xpert.test.jsx +++ b/src/widgets/Xpert.test.jsx @@ -46,7 +46,7 @@ const assertSidebarElementsNotInDOM = () => { beforeEach(() => { const responseMessage = createRandomResponseForTesting(); - jest.spyOn(api, 'default').mockResolvedValue(responseMessage); + jest.spyOn(api, 'fetchChatResponse').mockResolvedValue(responseMessage); jest.spyOn(api, 'fetchLearningAssistantEnabled').mockResolvedValue({ enabled: true }); usePromptExperimentDecision.mockReturnValue([]); @@ -165,7 +165,7 @@ test('response text appears as message in the sidebar', async () => { // re-mock the fetchChatResponse API function so that we can assert that the // responseMessage appears in the DOM const responseMessage = createRandomResponseForTesting(); - jest.spyOn(api, 'default').mockResolvedValue(responseMessage); + jest.spyOn(api, 'fetchChatResponse').mockResolvedValue(responseMessage); render(, { preloadedState: initialState }); @@ -189,7 +189,7 @@ test('clicking the clear button clears messages in the sidebar', async () => { // re-mock the fetchChatResponse API function so that we can assert that the // responseMessage appears in the DOM and then is successfully cleared const responseMessage = createRandomResponseForTesting(); - jest.spyOn(api, 'default').mockImplementation(() => responseMessage); + jest.spyOn(api, 'fetchChatResponse').mockImplementation(() => responseMessage); render(, { preloadedState: initialState });