From 2403684309c9ce1426e8f4a9b7dfab7f700cad1f Mon Sep 17 00:00:00 2001 From: OlgaLarina Date: Fri, 10 Jan 2025 17:38:19 +0300 Subject: [PATCH] replace toggleVisibility -> show/hide --- .../tests/creator-base.tests.ts | 26 +++++++-------- .../tests/question-adorner.tests.ts | 32 +++++++++---------- .../tests/tabs/test.tests.ts | 4 +-- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/packages/survey-creator-core/tests/creator-base.tests.ts b/packages/survey-creator-core/tests/creator-base.tests.ts index 6f98ac4b8e..73be8afa84 100644 --- a/packages/survey-creator-core/tests/creator-base.tests.ts +++ b/packages/survey-creator-core/tests/creator-base.tests.ts @@ -1343,7 +1343,7 @@ test("Question type custom widgets", (): any => { expect(creator.addNewQuestionText).toEqual("Add Question"); const selectorModel = creator.getQuestionTypeSelectorModel(() => { }); const listModel: ListModel = selectorModel.popupModel.contentComponentData.model; - selectorModel.popupModel.toggleVisibility(); + selectorModel.popupModel.show(); const actionPopupViewModel = new PopupDropdownViewModel(selectorModel.popupModel); // need for popupModel.onShow selectorModel.popupModel.show(); const customItem = listModel.actions.filter((item) => item.id == "test_widget")[0]; @@ -2295,7 +2295,7 @@ test("ConvertTo, show the current question type selected", (): any => { const popup = questionModel.getActionById("convertTo").popupModel; expect(popup).toBeTruthy(); const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; expect(list).toBeTruthy(); expect(list.selectedItem).toBeTruthy(); @@ -2324,7 +2324,7 @@ test("ConvertTo, show it for a panel", (): any => { const popup = panelModel.getActionById("convertTo").popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow expect(popup).toBeTruthy(); - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; expect(list).toBeTruthy(); expect(list.selectedItem).toBeTruthy(); @@ -2428,23 +2428,23 @@ test("ConvertTo & addNewQuestion refresh items", (): any => { expect(convertToAction.data.actions.length).toBe(0); expect(questionTypeSelectorListModel.actions.length).toBe(0); - convertToAction.popupModel.toggleVisibility(); + convertToAction.popupModel.show(); expect(convertToAction.data.actions.length).toBe(21); - convertToAction.popupModel.toggleVisibility(); + convertToAction.popupModel.hide(); - questionTypeSelectorModel.popupModel.toggleVisibility(); + questionTypeSelectorModel.popupModel.show(); expect(questionTypeSelectorListModel.actions.length).toBe(21); - questionTypeSelectorModel.popupModel.toggleVisibility(); + questionTypeSelectorModel.popupModel.hide(); pageModel.addNewQuestion("text", "q2"); - convertToAction.popupModel.toggleVisibility(); + convertToAction.popupModel.show(); expect(convertToAction.data.actions.length).toBe(20); - convertToAction.popupModel.toggleVisibility(); + convertToAction.popupModel.hide(); - questionTypeSelectorModel.popupModel.toggleVisibility(); + questionTypeSelectorModel.popupModel.show(); expect(questionTypeSelectorListModel.actions.length).toBe(20); - questionTypeSelectorModel.popupModel.toggleVisibility(); + questionTypeSelectorModel.popupModel.hide(); const q2AdornerModel = new QuestionAdornerViewModel(creator, creator.survey.getQuestionByName("q2"), undefined); const convertToAction2 = q2AdornerModel.actionContainer.actions.filter(action => action.id === "convertTo")[0]; @@ -3285,7 +3285,7 @@ test("Add new question to Panel and Page", (): any => { const selectorModelPage = pageAdornerModel.questionTypeSelectorModel; const listModelPage: ListModel = selectorModelPage.popupModel.contentComponentData.model; actionPopupViewModel = new PopupDropdownViewModel(selectorModelPage.popupModel); // need for popupModel.onShow - selectorModelPage.popupModel.toggleVisibility(); + selectorModelPage.popupModel.show(); const rankingItem = listModelPage.actions.filter((item) => item.id == "ranking")[0]; listModelPage.onItemClick(rankingItem); @@ -3297,7 +3297,7 @@ test("Add new question to Panel and Page", (): any => { const selectorModelPage2 = pageAdornerModel2.questionTypeSelectorModel; const listModelPage2: ListModel = selectorModelPage2.popupModel.contentComponentData.model; actionPopupViewModel = new PopupDropdownViewModel(selectorModelPage2.popupModel); // need for popupModel.onShow - selectorModelPage2.popupModel.toggleVisibility(); + selectorModelPage2.popupModel.show(); const htmlItem = listModelPage2.actions.filter((item) => item.id == "html")[0]; listModelPage2.onItemClick(htmlItem); diff --git a/packages/survey-creator-core/tests/question-adorner.tests.ts b/packages/survey-creator-core/tests/question-adorner.tests.ts index 83c77f9fbf..d740fecd52 100644 --- a/packages/survey-creator-core/tests/question-adorner.tests.ts +++ b/packages/survey-creator-core/tests/question-adorner.tests.ts @@ -250,7 +250,7 @@ function getQuestionConverterList(creator: CreatorTester, questionName: string) const convertToAction = questionAdorner.actionContainer.getActionById("convertTo"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; return list; } @@ -274,7 +274,7 @@ test("Check question converter no subitems", (): any => { const convertToAction = questionAdorner.actionContainer.getActionById("convertTo"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; expect((list.getActionById("text").items || []).length).toBe(0); @@ -299,13 +299,13 @@ test("Check question converter selected item for subitems", (): any => { const convertToAction = questionAdorner.actionContainer.getActionById("convertTo"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; expect(list.selectedItem.id).toBe("text"); const popupSubtype = list.selectedItem.popupModel; const popupViewModelSubtype = new PopupDropdownViewModel(popupSubtype); // need for popupModel.onShow - popupSubtype.toggleVisibility(); + popupSubtype.show(); const listSubtype = popupSubtype.contentComponentData.model; expect(listSubtype.selectedItem.id).toBe("email"); @@ -342,13 +342,13 @@ test("Check question converter selected item for customized subitems (types)", ( const convertToAction = questionAdorner.actionContainer.getActionById("convertTo"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; expect(list.selectedItem.id).toBe("matrix"); const popupSubtype = list.selectedItem.popupModel; const popupViewModelSubtype = new PopupDropdownViewModel(popupSubtype); // need for popupModel.onShow - popupSubtype.toggleVisibility(); + popupSubtype.show(); const listSubtype = popupSubtype.contentComponentData.model; expect(listSubtype.selectedItem.id).toBe("matrixdropdown"); @@ -380,13 +380,13 @@ test("Check question converter selected item for customized subitems (json)", () const convertToAction = questionAdorner.actionContainer.getActionById("convertTo"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; expect(list.selectedItem.id).toBe("boolean"); const popupSubtype = list.selectedItem.popupModel; const popupViewModelSubtype = new PopupDropdownViewModel(popupSubtype); // need for popupModel.onShow - popupSubtype.toggleVisibility(); + popupSubtype.show(); const listSubtype = popupSubtype.contentComponentData.model; expect(listSubtype.selectedItem.id).toBe("boolradio"); @@ -422,13 +422,13 @@ test("Check question converter selected item for single subitems (json)", (): an const convertToAction = questionAdorner.actionContainer.getActionById("convertTo"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; expect(list.selectedItem.id).toBe("comment"); const popupSubtype = list.selectedItem.popupModel; const popupViewModelSubtype = new PopupDropdownViewModel(popupSubtype); // need for popupModel.onShow - popupSubtype.toggleVisibility(); + popupSubtype.show(); const listSubtype = popupSubtype.contentComponentData.model; expect(listSubtype.selectedItem.id).toBe("limitedLongText"); @@ -441,13 +441,13 @@ test("Check question converter selected item for single subitems (json)", (): an const convertToAction2 = questionAdorner2.actionContainer.getActionById("convertTo"); const popup2 = convertToAction2.popupModel; const popupViewModel2 = new PopupDropdownViewModel(popup2); // need for popupModel.onShow - popup2.toggleVisibility(); + popup2.show(); const list2 = popup2.contentComponentData.model; expect(list2.selectedItem.id).toBe("comment"); const popupSubtype2 = list2.selectedItem.popupModel; const popupViewModelSubtype2 = new PopupDropdownViewModel(popupSubtype2); // need for popupModel.onShow - popupSubtype2.toggleVisibility(); + popupSubtype2.show(); const listSubtype2 = popupSubtype2.contentComponentData.model; expect(listSubtype2.actions.length).toBe(2); expect(listSubtype2.selectedItem.title).toBe("Long Text"); @@ -485,7 +485,7 @@ test("Check question converter with subitems (json)", (): any => { const convertToAction = questionAdorner.actionContainer.getActionById("convertTo"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); const list = popup.contentComponentData.model; const booleanAction = list.getActionById("boolean"); @@ -494,7 +494,7 @@ test("Check question converter with subitems (json)", (): any => { const questionConverted = creator.survey.getQuestionByName("q1"); expect(questionConverted.renderAs).toBe("checkbox"); - popup.toggleVisibility(); + popup.show(); const booleanCheckAction2 = booleanAction.items[0]; booleanCheckAction2.action(); const questionConverted2 = creator.survey.getQuestionByName("q1"); @@ -533,7 +533,7 @@ test("Check question converter with subitems for input type", (): any => { const convertToAction = questionAdorner.actionContainer.getActionById("convertInputType"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); return popup.contentComponentData.model; } @@ -613,7 +613,7 @@ test("Check question converter with subitems for input type, bug #5884", (): any const convertToAction = questionAdorner.actionContainer.getActionById("convertInputType"); const popup = convertToAction.popupModel; const popupViewModel = new PopupDropdownViewModel(popup); // need for popupModel.onShow - popup.toggleVisibility(); + popup.show(); return popup.contentComponentData.model; } diff --git a/packages/survey-creator-core/tests/tabs/test.tests.ts b/packages/survey-creator-core/tests/tabs/test.tests.ts index 09e10ac35a..8b8a92d1a7 100644 --- a/packages/survey-creator-core/tests/tabs/test.tests.ts +++ b/packages/survey-creator-core/tests/tabs/test.tests.ts @@ -259,7 +259,7 @@ test("Check popup viewType", (): any => { expect(options.menuType).toEqual("popup"); }); - question.dropdownListModel.popupModel.toggleVisibility(); + question.dropdownListModel.popupModel.show(); expect(question.dropdownListModel.popupModel.isVisible).toBeTruthy(); _setIsTouch(false); }); @@ -751,7 +751,7 @@ test("Check that popups inside survey are closed when scrolling container", (): const model: TestSurveyTabViewModel = testPlugin.model; const question = model.survey.getAllQuestions()[0]; - question.dropdownListModel.popupModel.toggleVisibility(); + question.dropdownListModel.popupModel.show(); expect(model.survey["onScrollCallback"]).toBeDefined(); expect(question.dropdownListModel.popupModel.isVisible).toBeTruthy(); model.onScroll();