Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/grading-settings/GradingSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const GradingSettings = ({ courseId }) => {
} = useCourseSettings(courseId);
const {
mutate: updateGradingSettings,
isLoading: savePending,
Copy link
Copy Markdown
Contributor

@bradenmacdonald bradenmacdonald Nov 13, 2025

Choose a reason for hiding this comment

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

There is a simpler fix here.

You just need to change this line to

    isPending: savePending,

and it will work. The reason is the new version of React Query uses isPending instead of isLoading, so isLoading is actually undefined.

If you put // @ts-check on the first line, you'll see that right away:

Image

isPending: savePending,
isSuccess: savingStatus,
isError: savingFailed,
} = useGradingSettingUpdater(courseId);
Expand Down
23 changes: 23 additions & 0 deletions src/grading-settings/GradingSettings.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ describe('<GradingSettings />', () => {
},
});

// jsdom doesn't implement scrollTo; mock to avoid noisy console errors.
Object.defineProperty(window, 'scrollTo', { value: jest.fn(), writable: true });

store = initializeStore();
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
axiosMock
Expand Down Expand Up @@ -99,6 +102,26 @@ describe('<GradingSettings />', () => {
testSaving();
});

it('should show success alert and hide save prompt after successful save', async () => {
// Trigger change to show save prompt
const segmentInputs = await screen.findAllByTestId('grading-scale-segment-input');
const segmentInput = segmentInputs[2];
fireEvent.change(segmentInput, { target: { value: 'PatchTest' } });
// Click save and verify pending state appears
const saveBtnInitial = screen.getByText(messages.buttonSaveText.defaultMessage);
fireEvent.click(saveBtnInitial);
expect(screen.getByText(messages.buttonSavingText.defaultMessage)).toBeInTheDocument();
// Wait for success alert to appear (mutation success)
const successAlert = await screen.findByText(messages.alertSuccess.defaultMessage);
expect(successAlert).toBeVisible();
// Pending label should disappear and save prompt should be hidden (button removed)
expect(screen.queryByText(messages.buttonSavingText.defaultMessage)).toBeNull();
const saveAlert = screen.queryByTestId('grading-settings-save-alert');
expect(saveAlert).toBeNull();
// Ensure original save button text is no longer present because the prompt closed
expect(screen.queryByText(messages.buttonSaveText.defaultMessage)).toBeNull();
});

it('should handle being offline gracefully', async () => {
setOnlineStatus(false);
const segmentInputs = await screen.findAllByTestId('grading-scale-segment-input');
Expand Down