Skip to content

Commit 7cf01de

Browse files
authored
fix: grading settings save button stuck in pending state (#2614)
1 parent a1abd43 commit 7cf01de

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/grading-settings/GradingSettings.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const GradingSettings = ({ courseId }) => {
4242
} = useCourseSettings(courseId);
4343
const {
4444
mutate: updateGradingSettings,
45-
isLoading: savePending,
45+
isPending: savePending,
4646
isSuccess: savingStatus,
4747
isError: savingFailed,
4848
} = useGradingSettingUpdater(courseId);

src/grading-settings/GradingSettings.test.jsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ describe('<GradingSettings />', () => {
3939
},
4040
});
4141

42+
// jsdom doesn't implement scrollTo; mock to avoid noisy console errors.
43+
Object.defineProperty(window, 'scrollTo', { value: jest.fn(), writable: true });
44+
4245
store = initializeStore();
4346
axiosMock = new MockAdapter(getAuthenticatedHttpClient());
4447
axiosMock
@@ -99,6 +102,26 @@ describe('<GradingSettings />', () => {
99102
testSaving();
100103
});
101104

105+
it('should show success alert and hide save prompt after successful save', async () => {
106+
// Trigger change to show save prompt
107+
const segmentInputs = await screen.findAllByTestId('grading-scale-segment-input');
108+
const segmentInput = segmentInputs[2];
109+
fireEvent.change(segmentInput, { target: { value: 'PatchTest' } });
110+
// Click save and verify pending state appears
111+
const saveBtnInitial = screen.getByText(messages.buttonSaveText.defaultMessage);
112+
fireEvent.click(saveBtnInitial);
113+
expect(screen.getByText(messages.buttonSavingText.defaultMessage)).toBeInTheDocument();
114+
// Wait for success alert to appear (mutation success)
115+
const successAlert = await screen.findByText(messages.alertSuccess.defaultMessage);
116+
expect(successAlert).toBeVisible();
117+
// Pending label should disappear and save prompt should be hidden (button removed)
118+
expect(screen.queryByText(messages.buttonSavingText.defaultMessage)).toBeNull();
119+
const saveAlert = screen.queryByTestId('grading-settings-save-alert');
120+
expect(saveAlert).toBeNull();
121+
// Ensure original save button text is no longer present because the prompt closed
122+
expect(screen.queryByText(messages.buttonSaveText.defaultMessage)).toBeNull();
123+
});
124+
102125
it('should handle being offline gracefully', async () => {
103126
setOnlineStatus(false);
104127
const segmentInputs = await screen.findAllByTestId('grading-scale-segment-input');

0 commit comments

Comments
 (0)