@@ -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