test: added test case
This commit is contained in:
committed by
Muhammad Faraz Maqsood
parent
44d47f8783
commit
ce337aedef
@@ -9,7 +9,7 @@ import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { closestCorners } from '@dnd-kit/core';
|
||||
|
||||
import { logError } from '@edx/frontend-platform/logging';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import {
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
getCourseItemApiUrl,
|
||||
getXBlockBaseApiUrl,
|
||||
exportTags,
|
||||
createDiscussionsTopics,
|
||||
} from './data/api';
|
||||
import { RequestStatus } from '../data/constants';
|
||||
import {
|
||||
@@ -115,6 +116,10 @@ jest.mock('../library-authoring/component-picker', () => ({
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('@edx/frontend-platform/logging', () => ({
|
||||
logError: jest.fn(),
|
||||
}));
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
jest.mock('@dnd-kit/core', () => ({
|
||||
@@ -192,6 +197,16 @@ describe('<CourseOutline />', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('logs an error when syncDiscussionsTopics encounters an API failure', async () => {
|
||||
axiosMock
|
||||
.onGet(createDiscussionsTopics(courseId))
|
||||
.reply(500, 'some internal error');
|
||||
|
||||
await executeThunk(syncDiscussionsTopics(), store.dispatch);
|
||||
|
||||
expect(logError).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('handles course outline fetch api errors', async () => {
|
||||
axiosMock
|
||||
.onGet(getCourseOutlineIndexApiUrl(courseId))
|
||||
|
||||
@@ -3149,6 +3149,7 @@ module.exports = {
|
||||
selectedGroupsLabel: '',
|
||||
},
|
||||
},
|
||||
createdOn: new Date(),
|
||||
deprecatedBlocksInfo: {
|
||||
deprecatedEnabledBlockTypes: [],
|
||||
blocks: [],
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { logError } from '@edx/frontend-platform/logging';
|
||||
import { RequestStatus } from '../../data/constants';
|
||||
import { NOTIFICATION_MESSAGES } from '../../constants';
|
||||
import { COURSE_BLOCK_NAMES } from '../constants';
|
||||
@@ -100,8 +101,7 @@ export function syncDiscussionsTopics(courseId) {
|
||||
try {
|
||||
await createDiscussionsTopics(courseId);
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('There was an issue in discussion topic sync', error);
|
||||
logError(error);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user