@@ -23319,3 +23319,57 @@ QUnit.test("Re-run expressions on changing the related object properties, Bug#10
2331923319 assert.equal(q2.visible, true, "q2 is visible after locale change to ''");
2332023320 assert.equal(q3.visibleChoices.length, 2, "q3 has two visible choices after locale change to ''");
2332123321});
23322+ QUnit.test("visibleIf with $q.containsErrors and checkErrorsMode=onValueChanged", function (assert) {
23323+ const survey = new SurveyModel({
23324+ checkErrorsMode: "onValueChanged",
23325+ elements: [
23326+ {
23327+ type: "text",
23328+ name: "q1",
23329+ inputType: "number",
23330+ min: 10
23331+ },
23332+ {
23333+ type: "text",
23334+ name: "q2",
23335+ visibleIf: "{q1} notempty and {$q1.containsErrors} = false"
23336+ }
23337+ ]
23338+ });
23339+ const q1 = survey.getQuestionByName("q1");
23340+ const q2 = survey.getQuestionByName("q2");
23341+ assert.equal(q2.isVisible, false, "q2 is invisible initially, q1 is empty");
23342+ q1.value = 20;
23343+ assert.equal(q1.errors.length, 0, "q1 has no errors, value=20 >= min=10");
23344+ assert.equal(q2.isVisible, true, "q2 is visible, q1=20 and no errors");
23345+ q1.value = 5;
23346+ assert.equal(q1.errors.length, 1, "q1 has error, value=5 < min=10");
23347+ assert.equal(q2.isVisible, false, "q2 is invisible, q1=5 contains errors");
23348+ }); QUnit.test("Panel visibleIf with $q.containsErrors and checkErrorsMode=onValueChanged", function (assert) {
23349+ const survey = new SurveyModel({
23350+ checkErrorsMode: "onValueChanged",
23351+ elements: [
23352+ {
23353+ type: "text",
23354+ name: "q1",
23355+ inputType: "number",
23356+ min: 10
23357+ },
23358+ {
23359+ type: "panel",
23360+ name: "panel1",
23361+ visibleIf: "{q1} notempty and {$q1.containsErrors} = false",
23362+ elements: [{ type: "text", name: "q2" }]
23363+ }
23364+ ]
23365+ });
23366+ const q1 = survey.getQuestionByName("q1");
23367+ const panel1 = survey.getPanelByName("panel1");
23368+ assert.equal(panel1.isVisible, false, "panel1 is invisible initially, q1 is empty");
23369+ q1.value = 20;
23370+ assert.equal(q1.errors.length, 0, "q1 has no errors, value=20 >= min=10");
23371+ assert.equal(panel1.isVisible, true, "panel1 is visible, q1=20 and no errors");
23372+ q1.value = 5;
23373+ assert.equal(q1.errors.length, 1, "q1 has error, value=5 < min=10");
23374+ assert.equal(panel1.isVisible, false, "panel1 is invisible, q1=5 contains errors");
23375+ });
0 commit comments