diff --git a/plugins/course-apps/xpert_unit_summary/Settings.test.jsx b/plugins/course-apps/xpert_unit_summary/Settings.test.jsx index 1c52c59e05..c0e917e0ea 100644 --- a/plugins/course-apps/xpert_unit_summary/Settings.test.jsx +++ b/plugins/course-apps/xpert_unit_summary/Settings.test.jsx @@ -206,7 +206,7 @@ describe('XpertUnitSummarySettings', () => { }); }); - describe('removing course configuration', () => { + describe('disabling course configuration', () => { beforeEach(() => { axiosMock.onGet(API.getXpertSettingsUrl(courseId)) .reply(200, generateCourseLevelAPIResponse({ @@ -214,23 +214,23 @@ describe('XpertUnitSummarySettings', () => { enabled: true, })); - axiosMock.onDelete(API.getXpertSettingsUrl(courseId)) + axiosMock.onPost(API.getXpertSettingsUrl(courseId)) .reply(200, generateCourseLevelAPIResponse({ success: true, - enabled: undefined, + enabled: false, })); renderComponent(); }); - test('Deleting course configuration', async () => { - jest.spyOn(API, 'deleteXpertSettings'); + test('Disabling course configuration', async () => { + jest.spyOn(API, 'postXpertSettings'); await waitFor(() => expect(container.querySelector('#enable-xpert_unit_summary-toggle')).toBeTruthy()); fireEvent.click(container.querySelector('#enable-xpert_unit_summary-toggle')); fireEvent.click(getByText(container, 'Save')); await waitFor(() => expect(container.querySelector('#enable-xpert_unit_summary-toggle')).toBeTruthy()); - expect(API.deleteXpertSettings).toBeCalled(); + expect(API.postXpertSettings).toBeCalledWith(courseId, { enabled: false }); }); }); diff --git a/plugins/course-apps/xpert_unit_summary/settings-modal/SettingsModal.jsx b/plugins/course-apps/xpert_unit_summary/settings-modal/SettingsModal.jsx index 87c99afac6..4a9dcfb93a 100644 --- a/plugins/course-apps/xpert_unit_summary/settings-modal/SettingsModal.jsx +++ b/plugins/course-apps/xpert_unit_summary/settings-modal/SettingsModal.jsx @@ -36,7 +36,7 @@ import { updateSavingStatus, updateResetStatus } from 'CourseAuthoring/pages-and import AppConfigFormDivider from 'CourseAuthoring/pages-and-resources/discussions/app-config-form/apps/shared/AppConfigFormDivider'; import { PagesAndResourcesContext } from 'CourseAuthoring/pages-and-resources/PagesAndResourcesProvider'; -import { updateXpertSettings, resetXpertSettings, removeXpertSettings } from '../data/thunks'; +import { updateXpertSettings, resetXpertSettings } from '../data/thunks'; import messages from './messages'; import appInfo from '../appInfo'; import ResetIcon from './ResetIcon'; @@ -235,13 +235,11 @@ const SettingsModal = ({ const handleFormSubmit = async ({ enabled, checked, ...rest }) => { let success; - const values = { ...rest, enabled: enabled ? checked === 'true' : undefined }; + const values = { ...rest, enabled: enabled ? checked === 'true' : false }; - if (enabled) { - success = await dispatch(updateXpertSettings(courseId, values)); - } else { - success = await dispatch(removeXpertSettings(courseId)); - } + // Always update settings to save the enabled state (true/false) + // Don't delete the record when disabling, as that would fall back to system default + success = await dispatch(updateXpertSettings(courseId, values)); if (onSettingsSave) { success = success && await onSettingsSave(values);