fix: passed course id and fixed test cases

This commit is contained in:
sundasnoreen12
2025-05-26 18:18:30 +05:00
committed by Muhammad Faraz Maqsood
parent afd6afdbb9
commit 36e57a0cfb
2 changed files with 21 additions and 21 deletions

View File

@@ -257,8 +257,8 @@ describe('<CourseOutline />', () => {
async () => fireEvent.change(optionDropdown, { target: { value: VIDEO_SHARING_OPTIONS.allOff } }), async () => fireEvent.change(optionDropdown, { target: { value: VIDEO_SHARING_OPTIONS.allOff } }),
); );
expect(axiosMock.history.post.length).toBe(2); expect(axiosMock.history.post.length).toBe(3);
expect(axiosMock.history.post[1].data).toBe(JSON.stringify({ expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
metadata: { metadata: {
video_sharing_options: VIDEO_SHARING_OPTIONS.allOff, video_sharing_options: VIDEO_SHARING_OPTIONS.allOff,
}, },
@@ -280,8 +280,8 @@ describe('<CourseOutline />', () => {
async () => fireEvent.change(optionDropdown, { target: { value: VIDEO_SHARING_OPTIONS.allOff } }), async () => fireEvent.change(optionDropdown, { target: { value: VIDEO_SHARING_OPTIONS.allOff } }),
); );
expect(axiosMock.history.post.length).toBe(2); expect(axiosMock.history.post.length).toBe(3);
expect(axiosMock.history.post[1].data).toBe(JSON.stringify({ expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
metadata: { metadata: {
video_sharing_options: VIDEO_SHARING_OPTIONS.allOff, video_sharing_options: VIDEO_SHARING_OPTIONS.allOff,
}, },
@@ -426,10 +426,10 @@ describe('<CourseOutline />', () => {
}); });
const newUnitButton = await within(subsectionElement).findByTestId('new-unit-button'); const newUnitButton = await within(subsectionElement).findByTestId('new-unit-button');
await act(async () => fireEvent.click(newUnitButton)); 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 [section] = courseOutlineIndexMock.courseStructure.childInfo.children;
const [subsection] = section.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, parent_locator: subsection.id,
category: COURSE_BLOCK_NAMES.vertical.id, category: COURSE_BLOCK_NAMES.vertical.id,
display_name: COURSE_BLOCK_NAMES.vertical.name, display_name: COURSE_BLOCK_NAMES.vertical.name,
@@ -464,7 +464,7 @@ describe('<CourseOutline />', () => {
const [section] = courseOutlineIndexMock.courseStructure.childInfo.children; const [section] = courseOutlineIndexMock.courseStructure.childInfo.children;
const [subsection] = section.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, type: COMPONENT_TYPES.libraryV2,
category: 'vertical', category: 'vertical',
parent_locator: subsection.id, parent_locator: subsection.id,
@@ -905,8 +905,8 @@ describe('<CourseOutline />', () => {
const saveButton = await findByTestId('configure-save-button'); const saveButton = await findByTestId('configure-save-button');
await act(async () => fireEvent.click(saveButton)); await act(async () => fireEvent.click(saveButton));
expect(axiosMock.history.post.length).toBe(2); expect(axiosMock.history.post.length).toBe(3);
expect(axiosMock.history.post[1].data).toBe(JSON.stringify({ expect(axiosMock.history.post[2].data).toBe(JSON.stringify({
publish: 'republish', publish: 'republish',
metadata: { metadata: {
visible_to_staff_only: true, visible_to_staff_only: true,
@@ -1005,8 +1005,8 @@ describe('<CourseOutline />', () => {
await act(async () => fireEvent.click(saveButton)); await act(async () => fireEvent.click(saveButton));
// verify request // verify request
expect(axiosMock.history.post.length).toBe(2); expect(axiosMock.history.post.length).toBe(3);
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData));
// reopen modal and check values // reopen modal and check values
await act(async () => fireEvent.click(subsectionDropdownButton)); await act(async () => fireEvent.click(subsectionDropdownButton));
@@ -1141,8 +1141,8 @@ describe('<CourseOutline />', () => {
await act(async () => fireEvent.click(saveButton)); await act(async () => fireEvent.click(saveButton));
// verify request // verify request
expect(axiosMock.history.post.length).toBe(2); expect(axiosMock.history.post.length).toBe(3);
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData));
// reopen modal and check values // reopen modal and check values
await act(async () => fireEvent.click(subsectionDropdownButton)); await act(async () => fireEvent.click(subsectionDropdownButton));
@@ -1261,8 +1261,8 @@ describe('<CourseOutline />', () => {
await act(async () => fireEvent.click(saveButton)); await act(async () => fireEvent.click(saveButton));
// verify request // verify request
expect(axiosMock.history.post.length).toBe(2); expect(axiosMock.history.post.length).toBe(3);
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData));
// reopen modal and check values // reopen modal and check values
await act(async () => fireEvent.click(subsectionDropdownButton)); await act(async () => fireEvent.click(subsectionDropdownButton));
@@ -1361,8 +1361,8 @@ describe('<CourseOutline />', () => {
await act(async () => fireEvent.click(saveButton)); await act(async () => fireEvent.click(saveButton));
// verify request // verify request
expect(axiosMock.history.post.length).toBe(2); expect(axiosMock.history.post.length).toBe(3);
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData));
// reopen modal and check values // reopen modal and check values
await act(async () => fireEvent.click(subsectionDropdownButton)); await act(async () => fireEvent.click(subsectionDropdownButton));
@@ -1457,8 +1457,8 @@ describe('<CourseOutline />', () => {
await act(async () => fireEvent.click(saveButton)); await act(async () => fireEvent.click(saveButton));
// verify request // verify request
expect(axiosMock.history.post.length).toBe(2); expect(axiosMock.history.post.length).toBe(3);
expect(axiosMock.history.post[1].data).toBe(JSON.stringify(expectedRequestData)); expect(axiosMock.history.post[2].data).toBe(JSON.stringify(expectedRequestData));
// reopen modal and check values // reopen modal and check values
await act(async () => fireEvent.click(subsectionDropdownButton)); await act(async () => fireEvent.click(subsectionDropdownButton));

View File

@@ -296,9 +296,9 @@ const useCourseOutline = ({ courseId }) => {
useEffect(() => { useEffect(() => {
if (createdOn && moment(new Date(createdOn)).isAfter(moment().subtract(31, 'days'))) { if (createdOn && moment(new Date(createdOn)).isAfter(moment().subtract(31, 'days'))) {
dispatch(syncDiscussionsTopics); dispatch(syncDiscussionsTopics(courseId));
} }
}, [createdOn]); }, [createdOn, courseId]);
useEffect(() => { useEffect(() => {
setShowSuccessAlert(reIndexLoadingStatus === RequestStatus.SUCCESSFUL); setShowSuccessAlert(reIndexLoadingStatus === RequestStatus.SUCCESSFUL);