Skip to content

fix: resolve issue with Xpert unit summary toggle not updating state#85

Merged
Alam-2U merged 2 commits intorelease-ulmofrom
ealam/COSMO2-841
Mar 20, 2026
Merged

fix: resolve issue with Xpert unit summary toggle not updating state#85
Alam-2U merged 2 commits intorelease-ulmofrom
ealam/COSMO2-841

Conversation

@Alam-2U
Copy link
Copy Markdown

@Alam-2U Alam-2U commented Mar 20, 2026

Description

Xpert Unit Summary toggle in Pages & Resources doesn't toggle between enable/disable .

Cause

Toggling OFF deletes the DB record, so the backend treats it as missing and returns enabled_by_default = true, making it impossible to disable in stage.

Ticket

COSMO2-841

Copilot AI review requested due to automatic review settings March 20, 2026 07:13
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the Xpert Unit Summary settings toggle/state sync by aligning the frontend’s app/model identifier with the backend-provided id (xpert_unit_summary) and updating how settings are persisted when disabling.

Changes:

  • Update the Xpert Unit Summary app id from xpert-unit-summary to xpert_unit_summary across app metadata, Settings wiring, thunks, and tests.
  • Change the settings submit behavior to always POST updates (persist enabled: true/false) instead of deleting the record when disabling.
  • Update unit tests to use the new toggle DOM id and to exercise the new disable-via-POST behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
plugins/course-apps/xpert_unit_summary/settings-modal/SettingsModal.jsx Persist disabled state via update thunk instead of deleting configuration.
plugins/course-apps/xpert_unit_summary/data/thunks.js Align model ids with backend (xpert_unit_summary) for add/update/remove flows.
plugins/course-apps/xpert_unit_summary/appInfo.js Update exported course app id to underscore format.
plugins/course-apps/xpert_unit_summary/Settings.jsx Pass updated appId into the settings modal.
plugins/course-apps/xpert_unit_summary/Settings.test.jsx Update selectors/expectations for new toggle id and disable behavior.
Comments suppressed due to low confidence (1)

plugins/course-apps/xpert_unit_summary/Settings.test.jsx:125

  • This test name/expectation combination is inconsistent: it says "disabled from backend" but asserts the enable toggle is checked and the enable badge is shown. If enabled: false is meant to represent a disabled state, this should assert the toggle is unchecked and the badge is not present (or rename the test to reflect that the toggle represents something other than the backend enabled flag).
    test('Shows switch on if disabled from backend', async () => {
      axiosMock.onGet(API.getXpertSettingsUrl(courseId))
        .reply(200, generateCourseLevelAPIResponse({
          success: true,
          enabled: false,
        }));

      renderComponent();
      await waitFor(() => expect(container.querySelector('#enable-xpert_unit_summary-toggle')).toBeTruthy());
      expect(container.querySelector('#enable-xpert_unit_summary-toggle').checked).toBeTruthy();
      expect(queryByTestId(container, 'enable-badge')).toBeTruthy();
    });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Alam-2U Alam-2U merged commit d94c1e2 into release-ulmo Mar 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants