From 6435e5f64a4a33b42ce620aa1ea410b972a2b59c Mon Sep 17 00:00:00 2001 From: Dmitry Kurmanov Date: Tue, 26 Oct 2021 17:24:40 +0300 Subject: [PATCH] fixed https://github.com/surveyjs/survey-creator/issues/2122 (#2124) --- .../survey-creator-core/src/creator-base.ts | 4 +- testCafe/designer/inplace-editors.ts | 99 ++++++++++++++++++- 2 files changed, 100 insertions(+), 3 deletions(-) diff --git a/packages/survey-creator-core/src/creator-base.ts b/packages/survey-creator-core/src/creator-base.ts index 8792db3323..efdd402cda 100644 --- a/packages/survey-creator-core/src/creator-base.ts +++ b/packages/survey-creator-core/src/creator-base.ts @@ -2582,7 +2582,7 @@ export function getItemValueWrapperComponentName( item: ItemValue, question: QuestionSelectBase ): string { - if (!!question["parentQuestionValue"] || question.isContentElement) { + if (question.isContentElement) { return SurveyModel.TemplateRendererComponentName; } if (question.getType() === "imagepicker") { @@ -2595,7 +2595,7 @@ export function getItemValueWrapperComponentData( question: QuestionSelectBase, creator: CreatorBase ): any { - if (!!question["parentQuestionValue"] || question.isContentElement) { + if (question.isContentElement) { return item; } return { diff --git a/testCafe/designer/inplace-editors.ts b/testCafe/designer/inplace-editors.ts index 49f6b2f64f..b905491206 100644 --- a/testCafe/designer/inplace-editors.ts +++ b/testCafe/designer/inplace-editors.ts @@ -1,4 +1,4 @@ -import { getVisibleElement, url } from "../helper"; +import { getVisibleElement, setJSON, url } from "../helper"; import { ClientFunction, Selector } from "testcafe"; const title = "Inplace editors"; @@ -162,6 +162,103 @@ test("Radiogroup question inplace editor", async (t) => { .expect(items.nth(4).find("span").withText("Other (describe)").exists).ok(); }); +test("Radiogroup inside PanelDynamic question inplace editor", async (t) => { + const json = { + "pages": [ + { + "name": "page1", + "elements": [ + { + "type": "paneldynamic", + "name": "paneldynamic1", + "templateElements": [ + { + "type": "radiogroup", + "name": "question1", + "choices": [ + "item1", + "item2", + "item3" + ] + } + ] + } + ] + } + ] + }; + await setJSON(json); + + await t + .click(Selector("[name='question1']")) + .expect(items.count).eql(6) + .expect(items.nth(0).hasClass("svc-item-value--new")).notOk() + .expect(items.nth(0).find(".svc-item-value-controls__add").visible).notOk() + .expect(items.nth(0).find(".svc-item-value-controls__remove").visible).ok() + .expect(items.nth(0).find(".svc-item-value-controls__drag").visible).ok() + .expect(items.nth(0).find("span").withText("item1").exists).ok() + .expect(items.nth(1).hasClass("svc-item-value--new")).notOk() + .expect(items.nth(1).find(".svc-item-value-controls__add").visible).notOk() + .expect(items.nth(1).find(".svc-item-value-controls__remove").visible).ok() + .expect(items.nth(1).find(".svc-item-value-controls__drag").visible).ok() + .expect(items.nth(1).find("span").withText("item2").exists).ok() + .expect(items.nth(2).hasClass("svc-item-value--new")).notOk() + .expect(items.nth(2).find(".svc-item-value-controls__add").visible).notOk() + .expect(items.nth(2).find(".svc-item-value-controls__remove").visible).ok() + .expect(items.nth(2).find(".svc-item-value-controls__drag").visible).ok() + .expect(items.nth(2).find("span").withText("item3").exists).ok() + .expect(items.nth(3).hasClass("svc-item-value--new")).ok() + .expect(items.nth(3).find(".svc-item-value-controls__add").visible).ok() + .expect(items.nth(3).find(".svc-item-value-controls__remove").visible).notOk() + .expect(items.nth(3).find(".svc-item-value-controls__drag").visible).notOk() + .expect(items.nth(3).find("span").withText("item4").exists).ok() + .expect(items.nth(4).hasClass("svc-item-value--new")).ok() + .expect(items.nth(4).find(".svc-item-value-controls__add").visible).ok() + .expect(items.nth(4).find(".svc-item-value-controls__remove").visible).notOk() + .expect(items.nth(4).find(".svc-item-value-controls__drag").visible).notOk() + .expect(items.nth(4).find("span").withText("Other (describe)").exists).ok() + .expect(items.nth(5).hasClass("svc-item-value--new")).ok() + .expect(items.nth(5).find(".svc-item-value-controls__add").visible).ok() + .expect(items.nth(5).find(".svc-item-value-controls__remove").visible).notOk() + .expect(items.nth(5).find(".svc-item-value-controls__drag").visible).notOk() + .expect(items.nth(5).find("span").withText("None").exists).ok() + + .click(items.nth(5).find(".svc-item-value-controls__add")) + .expect(items.nth(5).hasClass("svc-item-value--new")).notOk() + .expect(items.nth(5).find(".svc-item-value-controls__add").visible).notOk() + .expect(items.nth(5).find(".svc-item-value-controls__remove").visible).ok() + .expect(items.nth(5).find(".svc-item-value-controls__drag").visible).notOk() + + .click(items.nth(5).find(".svc-item-value-controls__remove")) + .expect(items.nth(5).hasClass("svc-item-value--new")).ok() + .expect(items.nth(5).find(".svc-item-value-controls__add").visible).ok() + .expect(items.nth(5).find(".svc-item-value-controls__remove").visible).notOk() + .expect(items.nth(5).find(".svc-item-value-controls__drag").visible).notOk() + + .click(items.nth(3).find(".svc-item-value-controls__add")) + .expect(items.count).eql(7) + .expect(items.nth(3).hasClass("svc-item-value--new")).notOk() + .expect(items.nth(3).find(".svc-item-value-controls__add").visible).notOk() + .expect(items.nth(3).find(".svc-item-value-controls__remove").visible).ok() + .expect(items.nth(3).find(".svc-item-value-controls__drag").visible).ok() + .expect(items.nth(4).hasClass("svc-item-value--new")).ok() + .expect(items.nth(4).find(".svc-item-value-controls__add").visible).ok() + .expect(items.nth(4).find(".svc-item-value-controls__remove").visible).notOk() + .expect(items.nth(4).find(".svc-item-value-controls__drag").visible).notOk() + .expect(items.nth(4).find("span").withText("item5").exists).ok() + + .click(items.nth(3).find(".svc-item-value-controls__remove")) + .expect(items.count).eql(6) + .expect(items.nth(3).hasClass("svc-item-value--new")).ok() + .expect(items.nth(3).find(".svc-item-value-controls__add").visible).ok() + .expect(items.nth(3).find(".svc-item-value-controls__remove").visible).notOk() + .expect(items.nth(3).find(".svc-item-value-controls__drag").visible).notOk() + .expect(items.nth(4).find(".svc-item-value-controls__add").visible).ok() + .expect(items.nth(4).find(".svc-item-value-controls__remove").visible).notOk() + .expect(items.nth(4).find(".svc-item-value-controls__drag").visible).notOk() + .expect(items.nth(4).find("span").withText("Other (describe)").exists).ok(); +}); + test("Dropdown question inplace editor", async (t) => { await t .expect(getVisibleElement(".svc-question__content").exists).notOk()