Skip to content

Commit

Permalink
Add functional tests and fix knockout issue #7748
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Jan 26, 2024
1 parent e266677 commit c43b3f8
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/knockout/templates/comment.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script type="text/html" id="survey-comment">
<!--ko if: !question.isReadOnlyRenderDiv() -->
<textarea data-bind="attr: { id: question.commentId, maxLength: question.getOthersMaxLength(), 'aria-required': question.ariaRequired || question.a11y_input_ariaRequired, 'aria-label': question.ariaLabel || question.a11y_input_ariaLabel, placeholder: question.renderedCommentPlaceholder },
event: { input: function(s, e) { $data.question.onCommentInput(s, e); } },
event: { input: function(s, e) { $data.question.onCommentInput(e); } },
value: $data.question.comment,
visible: $data.visible,
disable: $data.question.isInputReadOnly,
Expand All @@ -16,7 +16,7 @@
<script type="text/html" id="survey-other">
<!--ko if: !question.isReadOnlyRenderDiv() -->
<textarea data-bind="attr: { id: question.otherId, maxLength: question.getOthersMaxLength(), 'aria-required': question.ariaRequired || question.a11y_input_ariaRequired, 'aria-label': question.ariaLabel || question.a11y_input_ariaLabel, placeholder: question.otherPlaceholder },
event: { input: function(s, e) { $data.question.onOtherValueInput(s, e); } },
event: { input: function(s, e) { $data.question.onOtherValueInput(e); } },
value: $data.question.otherValue,
visible: $data.visible,
disable: $data.question.isInputReadOnly,
Expand Down
69 changes: 69 additions & 0 deletions testCafe/questions/radiogroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,4 +355,73 @@ frameworks.forEach(framework => {
await t
.expect(Selector(".sv-string-viewer").withText("None").count).eql(1);
});
test("otherItem type in comment, textUpdateMode=onBlur", async t => {
const setOnValueChanged = ClientFunction(() => {
window["survey"].onValueChanged.add((sender, options) => {
if(options.name === "q2") return;
const val = sender.getValue("q2");
sender.setValue("q2", val + 1);
});
});
const currentJson = {
elements: [
{
type: "radiogroup",
showOtherItem: true,
name: "q1",
choices: [
"item1",
"item2",
"item3"
]
},
{ type: "text", name: "q2", defaultValue: 0, inputType: "number" }
]
};
await initSurvey(framework, currentJson);
await setOnValueChanged();

await t.click("input[value=other]")
.click(Selector("textarea"))
.pressKey("A B C D E F tab")
.click("input[value=Complete]");

const surveyResult = await getSurveyResult();
assert.deepEqual(surveyResult, { q1: "other", "q1-Comment": "ABCDEF", q2: 2 });
});
test("otherItem type in comment, textUpdateMode=onTyping", async t => {
const setOnValueChanged = ClientFunction(() => {
window["survey"].onValueChanged.add((sender, options) => {
if(options.name === "q2") return;
const val = sender.getValue("q2");
sender.setValue("q2", val + 1);
});
});
const currentJson = {
textUpdateMode: "onTyping",
elements: [
{
type: "radiogroup",
showOtherItem: true,
name: "q1",
choices: [
"item1",
"item2",
"item3"
]
},
{ type: "text", name: "q2", defaultValue: 0, inputType: "number" }
]
};
await initSurvey(framework, currentJson);
await setOnValueChanged();

await t.click("input[value=other]")
.click(Selector("textarea"))
.pressKey("A B C D E F tab")
.click("input[value=Complete]");

const surveyResult = await getSurveyResult();
assert.deepEqual(surveyResult, { q1: "other", "q1-Comment": "ABCDEF", q2: 7 });
});
});

0 comments on commit c43b3f8

Please sign in to comment.