fix: updated failing tests
This commit is contained in:
committed by
Muhammad Faraz Maqsood
parent
5167b167eb
commit
9906901262
@@ -47,7 +47,7 @@ import CourseOutline from './CourseOutline';
|
||||
import configureModalMessages from '../generic/configure-modal/messages';
|
||||
import pasteButtonMessages from '../generic/clipboard/paste-component/messages';
|
||||
import messages from './messages';
|
||||
import { getClipboardUrl } from '../generic/data/api';
|
||||
import {getApiBaseUrl, getClipboardUrl} from '../generic/data/api';
|
||||
import headerMessages from './header-navigations/messages';
|
||||
import cardHeaderMessages from './card-header/messages';
|
||||
import enableHighlightsModalMessages from './enable-highlights-modal/messages';
|
||||
@@ -126,10 +126,6 @@ jest.mock('@dnd-kit/core', () => ({
|
||||
closestCorners: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('./data/api', () => ({
|
||||
...jest.requireActual('./data/api'),
|
||||
createDiscussionsTopics: jest.fn().mockResolvedValue(undefined),
|
||||
}));
|
||||
// eslint-disable-next-line no-promise-executor-return
|
||||
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
@@ -176,6 +172,10 @@ describe('<CourseOutline />', () => {
|
||||
courseId, gradedOnly: true, validateOras: true, all: true,
|
||||
}))
|
||||
.reply(200, courseLaunchMock);
|
||||
// add mock for getApiBaseUrl()}/api/discussions/v0/course/${courseId}/sync_discussion_topics
|
||||
axiosMock
|
||||
.onPost(`${getApiBaseUrl()}/api/discussions/v0/course/${courseId}/sync_discussion_topics`)
|
||||
.reply(200, {});
|
||||
await executeThunk(fetchCourseOutlineIndexQuery(courseId), store.dispatch);
|
||||
await executeThunk(syncDiscussionsTopics(courseId), store.dispatch);
|
||||
});
|
||||
@@ -243,8 +243,8 @@ describe('<CourseOutline />', () => {
|
||||
async () => fireEvent.change(optionDropdown, { target: { value: VIDEO_SHARING_OPTIONS.allOff } }),
|
||||
);
|
||||
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify({
|
||||
expect(axiosMock.history.post.length).çÏ(2);
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify({
|
||||
metadata: {
|
||||
video_sharing_options: VIDEO_SHARING_OPTIONS.allOff,
|
||||
},
|
||||
@@ -266,8 +266,8 @@ describe('<CourseOutline />', () => {
|
||||
async () => fireEvent.change(optionDropdown, { target: { value: VIDEO_SHARING_OPTIONS.allOff } }),
|
||||
);
|
||||
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify({
|
||||
expect(axiosMock.history.post.length).toBe(2);
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify({
|
||||
metadata: {
|
||||
video_sharing_options: VIDEO_SHARING_OPTIONS.allOff,
|
||||
},
|
||||
@@ -412,10 +412,10 @@ describe('<CourseOutline />', () => {
|
||||
});
|
||||
const newUnitButton = await within(subsectionElement).findByTestId('new-unit-button');
|
||||
await act(async () => fireEvent.click(newUnitButton));
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post.length).toBe(2);
|
||||
const [section] = courseOutlineIndexMock.courseStructure.childInfo.children;
|
||||
const [subsection] = section.childInfo.children;
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify({
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify({
|
||||
parent_locator: subsection.id,
|
||||
category: COURSE_BLOCK_NAMES.vertical.id,
|
||||
display_name: COURSE_BLOCK_NAMES.vertical.name,
|
||||
@@ -446,11 +446,11 @@ describe('<CourseOutline />', () => {
|
||||
const dummyBtn = await screen.findByRole('button', { name: 'Dummy button' });
|
||||
fireEvent.click(dummyBtn);
|
||||
|
||||
waitFor(() => expect(axiosMock.history.post.length).toBe(1));
|
||||
waitFor(() => expect(axiosMock.history.post.length).toBe(2));
|
||||
|
||||
const [section] = courseOutlineIndexMock.courseStructure.childInfo.children;
|
||||
const [subsection] = section.childInfo.children;
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify({
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify({
|
||||
type: COMPONENT_TYPES.libraryV2,
|
||||
category: 'vertical',
|
||||
parent_locator: subsection.id,
|
||||
@@ -891,8 +891,8 @@ describe('<CourseOutline />', () => {
|
||||
const saveButton = await findByTestId('configure-save-button');
|
||||
await act(async () => fireEvent.click(saveButton));
|
||||
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify({
|
||||
expect(axiosMock.history.post.length).toBe(2);
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify({
|
||||
publish: 'republish',
|
||||
metadata: {
|
||||
visible_to_staff_only: true,
|
||||
@@ -991,8 +991,8 @@ describe('<CourseOutline />', () => {
|
||||
await act(async () => fireEvent.click(saveButton));
|
||||
|
||||
// verify request
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify(expectedRequestData));
|
||||
expect(axiosMock.history.post.length).toBe(2);
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData));
|
||||
|
||||
// reopen modal and check values
|
||||
await act(async () => fireEvent.click(subsectionDropdownButton));
|
||||
@@ -1127,8 +1127,8 @@ describe('<CourseOutline />', () => {
|
||||
await act(async () => fireEvent.click(saveButton));
|
||||
|
||||
// verify request
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify(expectedRequestData));
|
||||
expect(axiosMock.history.post.length).toBe(2);
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData));
|
||||
|
||||
// reopen modal and check values
|
||||
await act(async () => fireEvent.click(subsectionDropdownButton));
|
||||
@@ -1247,8 +1247,8 @@ describe('<CourseOutline />', () => {
|
||||
await act(async () => fireEvent.click(saveButton));
|
||||
|
||||
// verify request
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify(expectedRequestData));
|
||||
expect(axiosMock.history.post.length).toBe(2);
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData));
|
||||
|
||||
// reopen modal and check values
|
||||
await act(async () => fireEvent.click(subsectionDropdownButton));
|
||||
@@ -1347,8 +1347,8 @@ describe('<CourseOutline />', () => {
|
||||
await act(async () => fireEvent.click(saveButton));
|
||||
|
||||
// verify request
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify(expectedRequestData));
|
||||
expect(axiosMock.history.post.length).toBe(2);
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData));
|
||||
|
||||
// reopen modal and check values
|
||||
await act(async () => fireEvent.click(subsectionDropdownButton));
|
||||
@@ -1443,8 +1443,8 @@ describe('<CourseOutline />', () => {
|
||||
await act(async () => fireEvent.click(saveButton));
|
||||
|
||||
// verify request
|
||||
expect(axiosMock.history.post.length).toBe(1);
|
||||
expect(axiosMock.history.post[0].data).toBe(JSON.stringify(expectedRequestData));
|
||||
expect(axiosMock.history.post.length).toBe(2);
|
||||
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData));
|
||||
|
||||
// reopen modal and check values
|
||||
await act(async () => fireEvent.click(subsectionDropdownButton));
|
||||
|
||||
Reference in New Issue
Block a user