Skip to content

Commit

Permalink
fix: Fixed tests and made chat history error silent
Browse files Browse the repository at this point in the history
  • Loading branch information
rijuma committed Nov 8, 2024
1 parent ee2c068 commit 586b83a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export function clearMessages() {

export function getLearningAssistantMessageHistory(courseId) {
return async (dispatch) => {
dispatch(resetApiError());
dispatch(setApiIsLoading(true));

try {
Expand All @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/Xpert.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);

Expand Down Expand Up @@ -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(<Xpert courseId={courseId} contentToolsEnabled={false} unitId={unitId} />, { preloadedState: initialState });

Expand All @@ -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(<Xpert courseId={courseId} contentToolsEnabled={false} unitId={unitId} />, { preloadedState: initialState });

Expand Down

0 comments on commit 586b83a

Please sign in to comment.