Skip to content

Commit 4c1b017

Browse files
authored
fix(form): Quesion of type item throw 500 exception in the console (#21212)
1 parent aff30ba commit 4c1b017

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/Glpi/Form/QuestionType/QuestionTypeItem.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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
[

tests/cypress/e2e/form/editor/editor.cy.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)