diff --git a/src/course-outline/CourseOutline.test.jsx b/src/course-outline/CourseOutline.test.jsx index 6f5cd9213..ea680daef 100644 --- a/src/course-outline/CourseOutline.test.jsx +++ b/src/course-outline/CourseOutline.test.jsx @@ -257,8 +257,8 @@ describe('', () => { async () => fireEvent.change(optionDropdown, { target: { value: VIDEO_SHARING_OPTIONS.allOff } }), ); - expect(axiosMock.history.post.length).toBe(2); - expect(axiosMock.history.post[1].data).toBe(JSON.stringify({ + expect(axiosMock.history.post.length).toBe(3); + expect(axiosMock.history.post[2].data).toBe(JSON.stringify({ metadata: { video_sharing_options: VIDEO_SHARING_OPTIONS.allOff, }, @@ -280,8 +280,8 @@ describe('', () => { async () => fireEvent.change(optionDropdown, { target: { value: VIDEO_SHARING_OPTIONS.allOff } }), ); - expect(axiosMock.history.post.length).toBe(2); - expect(axiosMock.history.post[1].data).toBe(JSON.stringify({ + expect(axiosMock.history.post.length).toBe(3); + expect(axiosMock.history.post[2].data).toBe(JSON.stringify({ metadata: { video_sharing_options: VIDEO_SHARING_OPTIONS.allOff, }, @@ -426,10 +426,10 @@ describe('', () => { }); const newUnitButton = await within(subsectionElement).findByTestId('new-unit-button'); await act(async () => fireEvent.click(newUnitButton)); - expect(axiosMock.history.post.length).toBe(2); + expect(axiosMock.history.post.length).toBe(3); const [section] = courseOutlineIndexMock.courseStructure.childInfo.children; const [subsection] = section.childInfo.children; - expect(axiosMock.history.post[1].data).toBe(JSON.stringify({ + expect(axiosMock.history.post[2].data).toBe(JSON.stringify({ parent_locator: subsection.id, category: COURSE_BLOCK_NAMES.vertical.id, display_name: COURSE_BLOCK_NAMES.vertical.name, @@ -464,7 +464,7 @@ describe('', () => { const [section] = courseOutlineIndexMock.courseStructure.childInfo.children; const [subsection] = section.childInfo.children; - expect(axiosMock.history.post[1].data).toBe(JSON.stringify({ + expect(axiosMock.history.post[2].data).toBe(JSON.stringify({ type: COMPONENT_TYPES.libraryV2, category: 'vertical', parent_locator: subsection.id, @@ -905,8 +905,8 @@ describe('', () => { const saveButton = await findByTestId('configure-save-button'); await act(async () => fireEvent.click(saveButton)); - expect(axiosMock.history.post.length).toBe(2); - expect(axiosMock.history.post[1].data).toBe(JSON.stringify({ + expect(axiosMock.history.post.length).toBe(3); + expect(axiosMock.history.post[2].data).toBe(JSON.stringify({ publish: 'republish', metadata: { visible_to_staff_only: true, @@ -1005,8 +1005,8 @@ describe('', () => { await act(async () => fireEvent.click(saveButton)); // verify request - expect(axiosMock.history.post.length).toBe(2); - expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); + expect(axiosMock.history.post.length).toBe(3); + expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData)); // reopen modal and check values await act(async () => fireEvent.click(subsectionDropdownButton)); @@ -1141,8 +1141,8 @@ describe('', () => { await act(async () => fireEvent.click(saveButton)); // verify request - expect(axiosMock.history.post.length).toBe(2); - expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); + expect(axiosMock.history.post.length).toBe(3); + expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData)); // reopen modal and check values await act(async () => fireEvent.click(subsectionDropdownButton)); @@ -1261,8 +1261,8 @@ describe('', () => { await act(async () => fireEvent.click(saveButton)); // verify request - expect(axiosMock.history.post.length).toBe(2); - expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); + expect(axiosMock.history.post.length).toBe(3); + expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData)); // reopen modal and check values await act(async () => fireEvent.click(subsectionDropdownButton)); @@ -1361,8 +1361,8 @@ describe('', () => { await act(async () => fireEvent.click(saveButton)); // verify request - expect(axiosMock.history.post.length).toBe(2); - expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); + expect(axiosMock.history.post.length).toBe(3); + expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData)); // reopen modal and check values await act(async () => fireEvent.click(subsectionDropdownButton)); @@ -1457,8 +1457,8 @@ describe('', () => { await act(async () => fireEvent.click(saveButton)); // verify request - expect(axiosMock.history.post.length).toBe(2); - expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); + expect(axiosMock.history.post.length).toBe(3); + expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData)); // reopen modal and check values await act(async () => fireEvent.click(subsectionDropdownButton)); diff --git a/src/course-outline/hooks.jsx b/src/course-outline/hooks.jsx index 25a9bb5be..ae1b5000f 100644 --- a/src/course-outline/hooks.jsx +++ b/src/course-outline/hooks.jsx @@ -296,9 +296,9 @@ const useCourseOutline = ({ courseId }) => { useEffect(() => { if (createdOn && moment(new Date(createdOn)).isAfter(moment().subtract(31, 'days'))) { - dispatch(syncDiscussionsTopics); + dispatch(syncDiscussionsTopics(courseId)); } - }, [createdOn]); + }, [createdOn, courseId]); useEffect(() => { setShowSuccessAlert(reIndexLoadingStatus === RequestStatus.SUCCESSFUL);