From c07b8736450de583fc1684a4bfc1c1ea7da32a7d Mon Sep 17 00:00:00 2001 From: Dmitry Kurmanov Date: Fri, 4 Aug 2023 16:39:53 +0400 Subject: [PATCH] PR: Ranking question with only one choice does not show choice (#6648) * fixed https://github.com/surveyjs/survey-library/issues/6622 * fix func test --- src/question_ranking.ts | 9 +++++---- testCafe/questions/ranking.js | 2 +- tests/question_ranking_tests.ts | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/question_ranking.ts b/src/question_ranking.ts index 3e6fc5df25..77b6e3567b 100644 --- a/src/question_ranking.ts +++ b/src/question_ranking.ts @@ -143,6 +143,7 @@ export class QuestionRankingModel extends QuestionCheckboxModel { // ranking question with only one choice doesn't make sense if (this.visibleChoices.length === 1) { this.value = []; + this.value.push(this.visibleChoices[0].value); this.updateRankingChoices(); return; } @@ -221,10 +222,10 @@ export class QuestionRankingModel extends QuestionCheckboxModel { const newRankingChoices: ItemValue[] = []; // ranking question with only one choice doesn't make sense - if (this.visibleChoices.length === 1) { - this.setPropertyValue("rankingChoices", newRankingChoices); - return; - } + // if (this.visibleChoices.length === 1) { + // this.setPropertyValue("rankingChoices", newRankingChoices); + // return; + // } if (forceUpdate) this.setPropertyValue("rankingChoices", []); diff --git a/testCafe/questions/ranking.js b/testCafe/questions/ranking.js index a44c752af8..3020843604 100644 --- a/testCafe/questions/ranking.js +++ b/testCafe/questions/ranking.js @@ -189,7 +189,7 @@ frameworks.forEach((framework) => { .click(checkboxToyotaItem); let data = await getData(); - await t.expect(typeof data.bestcar).eql("undefined"); + await t.expect(typeof data.bestcar).ok(); await t.hover(rankAudiItem); await t.dragToElement(rankAudiItem, rankMercedesBenzItem); diff --git a/tests/question_ranking_tests.ts b/tests/question_ranking_tests.ts index d9e78b6034..477bc00a5c 100644 --- a/tests/question_ranking_tests.ts +++ b/tests/question_ranking_tests.ts @@ -133,7 +133,7 @@ QUnit.test("Ranking: Carry Forward", function(assert) { // ranking question with only one choice doesn't make sense q1.value = ["2"]; - assert.deepEqual(q2.isEmpty(), true); + assert.deepEqual(q2.isEmpty(), false); assert.deepEqual(survey.data, { q1: [2], });