@@ -4,6 +4,8 @@ import { initializeMockApp } from '@edx/frontend-platform';
44import { render , waitFor , fireEvent } from '@testing-library/react' ;
55
66import GradingScale from './GradingScale' ;
7+ import GradingScaleHandle from './components/GradingScaleHandle' ;
8+ import GradingScaleSegment from './components/GradingScaleSegment.tsx' ;
79
810const gradeCutoffs = { A : 0.9 , B : 0.8 , C : 0.7 } ;
911
@@ -122,6 +124,73 @@ describe('<GradingScale />', () => {
122124 } ) ;
123125 } ) ;
124126
127+ it ( 'renders GradingScaleHandle with default isEditable=true when prop is omitted' , ( ) => {
128+ const gradingSegments = [
129+ { current : 90 , previous : 0 } ,
130+ { current : 100 , previous : 90 } ,
131+ ] ;
132+ const { container } = render (
133+ < GradingScaleHandle
134+ idx = { 0 }
135+ value = { 90 }
136+ gradingSegments = { gradingSegments }
137+ getHandleProps = { ( ) => ( { } ) }
138+ /> ,
139+ ) ;
140+ const btn = container . querySelector ( '.grading-scale-segment-btn-resize' ) ;
141+ expect ( btn ) . toBeInTheDocument ( ) ;
142+ expect ( btn ) . not . toBeDisabled ( ) ;
143+ } ) ;
144+
145+ it ( 'renders GradingScaleSegment with default isEditable=true when prop is omitted' , async ( ) => {
146+ const gradingSegments = [
147+ { current : 100 , previous : 0 } ,
148+ { current : 50 , previous : 0 } ,
149+ { current : 30 , previous : 0 } ,
150+ ] ;
151+ const { getAllByTestId } = render (
152+ < IntlProvider locale = "en" messages = { { } } >
153+ < GradingScaleSegment
154+ idx = { 1 }
155+ value = { 50 }
156+ getSegmentProps = { ( ) => ( { } ) }
157+ handleLetterChange = { jest . fn ( ) }
158+ letters = { [ 'A' , 'B' , 'C' ] }
159+ gradingSegments = { gradingSegments }
160+ removeGradingSegment = { jest . fn ( ) }
161+ />
162+ </ IntlProvider > ,
163+ ) ;
164+ await waitFor ( ( ) => {
165+ getAllByTestId ( 'grading-scale-segment-input' ) . forEach ( ( input ) => expect ( input ) . not . toBeDisabled ( ) ) ;
166+ } ) ;
167+ } ) ;
168+
169+ it ( 'should disable inputs and buttons when isEditable is false' , async ( ) => {
170+ const { getAllByTestId, queryAllByTestId } = render (
171+ < IntlProvider locale = "en" messages = { { } } >
172+ < GradingScale
173+ gradeCutoffs = { gradeCutoffs }
174+ gradeLetters = { gradeLetters }
175+ sortedGrades = { sortedGrades }
176+ resetDataRef = { { current : false } }
177+ showSavePrompt = { jest . fn ( ) }
178+ setShowSuccessAlert = { jest . fn ( ) }
179+ setGradingData = { jest . fn ( ) }
180+ setOverrideInternetConnectionAlert = { jest . fn ( ) }
181+ setEligibleGrade = { jest . fn ( ) }
182+ isEditable = { false }
183+ />
184+ </ IntlProvider > ,
185+ ) ;
186+ await waitFor ( ( ) => {
187+ const segmentInputs = getAllByTestId ( 'grading-scale-segment-input' ) ;
188+ segmentInputs . forEach ( ( input ) => expect ( input ) . toBeDisabled ( ) ) ;
189+ const removeButtons = queryAllByTestId ( 'grading-scale-btn-remove' ) ;
190+ removeButtons . forEach ( ( btn ) => expect ( btn ) . toBeDisabled ( ) ) ;
191+ } ) ;
192+ } ) ;
193+
125194 it ( 'should render GradingScale component with more than 5 grades' , async ( ) => {
126195 const { getAllByTestId } = render (
127196 < IntlProvider locale = "en" messages = { { } } >
0 commit comments