File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
src/Glpi/Form/QuestionType
tests/cypress/e2e/form/editor Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -405,6 +405,10 @@ public function getConditionHandlers(
405405 throw new InvalidArgumentException ();
406406 }
407407
408+ if (!$ question_config ->getItemtype ()) {
409+ return parent ::getConditionHandlers ($ question_config );
410+ }
411+
408412 return array_merge (
409413 parent ::getConditionHandlers ($ question_config ),
410414 [
Original file line number Diff line number Diff line change @@ -148,6 +148,40 @@ describe ('Form editor', () => {
148148 } ) ;
149149 } ) ;
150150
151+ it ( 'can create an item question' , ( ) => {
152+ cy . createFormWithAPI ( ) . visitFormTab ( 'Form' ) ;
153+
154+ cy . addQuestion ( "My question" ) ;
155+ cy . findByRole ( 'region' , { 'name' : 'Question details' } ) . within ( ( ) => {
156+ cy . findByRole ( 'checkbox' , { 'name' : 'Mandatory' } )
157+ . should ( 'not.be.checked' )
158+ . check ( )
159+ ;
160+ cy . findByLabelText ( "Question description" )
161+ . awaitTinyMCE ( )
162+ . type ( "My question description" )
163+ ;
164+ } ) ;
165+
166+ // We catch the ajax request when Item question type is selected
167+ cy . intercept (
168+ {
169+ method : 'POST' ,
170+ url : '/Form/Condition/Editor/SupportedValueOperators' ,
171+ }
172+ ) . as ( 'itemQuestionQuery' ) ;
173+
174+ cy . getDropdownByLabelText ( "Question type" )
175+ . selectDropdownValue ( "Item" ) ;
176+
177+ cy . wait ( '@itemQuestionQuery' ) . then ( ( interception ) => {
178+ assert . equal ( interception . response . statusCode , 200 ) ;
179+ } ) ;
180+
181+ // Save form and reload page to force new data to be displayed.
182+ cy . saveFormEditorAndReload ( ) ;
183+ } ) ;
184+
151185 it ( 'can duplicate a question' , ( ) => {
152186 cy . createFormWithAPI ( ) . visitFormTab ( 'Form' ) ;
153187
You can’t perform that action at this time.
0 commit comments