@@ -78,7 +78,7 @@ describe("renderFormSections()", () => {
78
78
it ( "renders summary fields disabled" , ( ) => {
79
79
const externalForms = ( ) => { } ;
80
80
const selectedForm = "form1" ;
81
- const userPermittedFormsIds = fromJS ( { selectedForm : "rw" } ) ;
81
+ const userPermittedFormsIds = fromJS ( { form1 : "rw" } ) ;
82
82
const mobileDisplay = false ;
83
83
const handleToggleNav = ( ) => { } ;
84
84
const i18n = ( ) => { } ;
@@ -139,4 +139,69 @@ describe("renderFormSections()", () => {
139
139
expect ( screen . getAllByRole ( "textbox" ) ) . toHaveLength ( 2 ) ;
140
140
expect ( screen . getAllByRole ( "textbox" ) [ 1 ] ) . toHaveClass ( "Mui-disabled" ) ;
141
141
} ) ;
142
+
143
+ it ( "renders fields disabled when disabled is true" , ( ) => {
144
+ const externalForms = ( ) => { } ;
145
+ const selectedForm = "form1" ;
146
+ const userPermittedFormsIds = fromJS ( { form1 : "rw" } ) ;
147
+ const mobileDisplay = false ;
148
+ const handleToggleNav = ( ) => { } ;
149
+ const i18n = ( ) => { } ;
150
+ const recordType = "recordType1" ;
151
+ const attachmentForms = [ ] ;
152
+ const mode = { isEdit : true } ;
153
+ const record = fromJS ( { } ) ;
154
+ const primeroModule = "primeroModule1" ;
155
+
156
+ const formSectionsRender = renderFormSections (
157
+ externalForms ,
158
+ selectedForm ,
159
+ userPermittedFormsIds ,
160
+ mobileDisplay ,
161
+ handleToggleNav ,
162
+ i18n ,
163
+ recordType ,
164
+ attachmentForms ,
165
+ mode ,
166
+ record ,
167
+ primeroModule
168
+ ) ;
169
+
170
+ const formSection = ( ) =>
171
+ formSectionsRender (
172
+ [
173
+ FormSectionRecord ( {
174
+ unique_id : "form1" ,
175
+ visible : true ,
176
+ fields : [
177
+ FieldRecord ( {
178
+ name : "field1" ,
179
+ type : TEXT_FIELD ,
180
+ visible : true ,
181
+ disabled : true
182
+ } ) ,
183
+ FieldRecord ( {
184
+ name : "field2" ,
185
+ type : TEXT_FIELD ,
186
+ visible : true
187
+ } )
188
+ ]
189
+ } )
190
+ ] ,
191
+ ( ) => { } ,
192
+ ( ) => { } ,
193
+ { sex : "male" , age : 19 } ,
194
+ false
195
+ ) ;
196
+
197
+ // eslint-disable-next-line react/display-name
198
+ function RenderedFormSections ( ) {
199
+ return < > { formSection ( ) } </ > ;
200
+ }
201
+
202
+ mountedComponent ( < RenderedFormSections /> , { } , { } , [ ] , { initialValues : { } } ) ;
203
+
204
+ expect ( screen . getAllByRole ( "textbox" ) ) . toHaveLength ( 2 ) ;
205
+ expect ( screen . getAllByRole ( "textbox" ) [ 0 ] ) . toHaveClass ( "Mui-disabled" ) ;
206
+ } ) ;
142
207
} ) ;
0 commit comments