From 817d305542691973a3c398d07f729ee7d3db813b Mon Sep 17 00:00:00 2001 From: Loc Nguyen Date: Wed, 11 Sep 2024 11:59:21 +0700 Subject: [PATCH] feature/IVYPORTAL-17427-Remove-old-statistics-Area - Remove test --- ...dashboard-has-chart-cases-by-category.json | 67 ---- .../dashboard-has-one-chart-example.json | 71 ---- .../selenium/common/NavigationHelper.java | 6 - .../AdditionalComponentsScreenshotTest.java | 16 - .../screenshot/StatisticScreenshotTest.java | 51 --- .../TaskAnalysisScreenshotTest.java | 62 --- .../portal/selenium/page/MainMenuPage.java | 11 - .../page/NewDashboardDetailsEditPage.java | 5 - .../selenium/page/NewDashboardPage.java | 4 - .../page/StatisticWidgetDashboardPage.java | 58 --- .../selenium/page/StatisticWidgetPage.java | 270 ------------- .../selenium/page/TaskAnalysisWidgetPage.java | 362 ------------------ .../selenium/test/DefaultChartTest.java | 75 ---- .../portal/selenium/test/MenuTest.java | 7 +- .../test/StatisticDashboardWidgetTest.java | 92 ----- .../selenium/test/StatisticWidgetTest.java | 155 -------- .../test/task/TaskAnalysisWidgetTest.java | 348 ----------------- .../variables/Portal/StatisticCharts.json | 25 -- 18 files changed, 3 insertions(+), 1682 deletions(-) delete mode 100644 AxonIvyPortal/portal-selenium-test/resources/testFile/dashboard-has-chart-cases-by-category.json delete mode 100644 AxonIvyPortal/portal-selenium-test/resources/testFile/dashboard-has-one-chart-example.json delete mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/TaskAnalysisScreenshotTest.java delete mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/StatisticWidgetDashboardPage.java delete mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/StatisticWidgetPage.java delete mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskAnalysisWidgetPage.java delete mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/DefaultChartTest.java delete mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/StatisticDashboardWidgetTest.java delete mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/StatisticWidgetTest.java delete mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskAnalysisWidgetTest.java delete mode 100644 AxonIvyPortal/portal/config/variables/Portal/StatisticCharts.json diff --git a/AxonIvyPortal/portal-selenium-test/resources/testFile/dashboard-has-chart-cases-by-category.json b/AxonIvyPortal/portal-selenium-test/resources/testFile/dashboard-has-chart-cases-by-category.json deleted file mode 100644 index 808ab31f2d4..00000000000 --- a/AxonIvyPortal/portal-selenium-test/resources/testFile/dashboard-has-chart-cases-by-category.json +++ /dev/null @@ -1,67 +0,0 @@ -[ - { - "id": "1", - "title": "Dashboard", - "widgets": [ - { - "type": "statistic", - "id": "statistic_1", - "names": [ - { - "locale": "en", - "value": "Cases by Category" - } - ], - "layout": { - "id": null, - "styleClass": "new-widget", - "style": null, - "w": 5, - "h": 5, - "x": 0, - "y": 0 - }, - "chart": { - "id": "0", - "names": [ - { - "locale": "de", - "value": "Vorgänge nach Kategorie" - }, - { - "locale": "en", - "value": "Cases by category" - }, - { - "locale": "fr", - "value": "Affaires par catégorie" - }, - { - "locale": "es", - "value": "Casos por categoría" - } - ], - "type": "CASES_BY_CATEGORY", - "filter": { - "timePeriodSelection": "CUSTOM", - "createdDateFrom": null, - "createdDateTo": null, - "selectedCaseCategories": [], - "isAllCategoriesSelected": false, - "selectedRoles": [], - "isAllRolesSelected": true, - "selectedCaseStates": [], - "isAllCaseStatesSelected": true, - "selectedTaskPriorities": [], - "isAllTaskPrioritiesSelected": true, - "customFieldFilters": null - }, - "position": 0 - } - } - ], - "permissions": [ - "Everybody" - ] - } -] \ No newline at end of file diff --git a/AxonIvyPortal/portal-selenium-test/resources/testFile/dashboard-has-one-chart-example.json b/AxonIvyPortal/portal-selenium-test/resources/testFile/dashboard-has-one-chart-example.json deleted file mode 100644 index 8ba27392dc2..00000000000 --- a/AxonIvyPortal/portal-selenium-test/resources/testFile/dashboard-has-one-chart-example.json +++ /dev/null @@ -1,71 +0,0 @@ -[ - { - "id": "1", - "title": "Dashboard", - "widgets": [ - { - "type": "statistic", - "id": "statistic_1", - "names": [ - { - "locale": "en", - "value": "Tasks by Priority" - } - ], - "layout": { - "id": null, - "styleClass": "new-widget", - "style": null, - "w": 5, - "h": 5, - "x": 0, - "y": 0 - }, - "chart": { - "id": "0", - "names": [ - { - "locale": "de", - "value": "Aufgaben nach Priorit�t" - }, - { - "locale": "en", - "value": "Tasks by Priority" - }, - { - "locale": "fr", - "value": "T�ches par priorit�" - }, - { - "locale": "es", - "value": "Tareas por prioridad" - } - ], - "type": "TASK_BY_PRIORITY", - "filter": { - "timePeriodSelection": "CUSTOM", - "createdDateFrom": null, - "createdDateTo": null, - "selectedCaseCategories": [ - ], - "isAllCategoriesSelected": false, - "selectedRoles": [ - ], - "isAllRolesSelected": true, - "selectedCaseStates": [ - ], - "isAllCaseStatesSelected": true, - "selectedTaskPriorities": [ - ], - "isAllTaskPrioritiesSelected": true, - "customFieldFilters": null - }, - "position": 0 - } - } - ], - "permissions": [ - "Everybody" - ] - } -] diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/NavigationHelper.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/NavigationHelper.java index e057fbf9f42..37851aa5ec0 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/NavigationHelper.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/NavigationHelper.java @@ -4,14 +4,12 @@ import com.axonivy.portal.selenium.page.CaseWidgetPage; import com.axonivy.portal.selenium.page.ProcessWidgetPage; -import com.axonivy.portal.selenium.page.StatisticWidgetPage; import com.axonivy.portal.selenium.page.TaskWidgetPage; public class NavigationHelper { private static final String TASK_LIST_PAGE_URL = "portal/1549F58C18A6C562/DefaultTaskListPage.ivp"; private static final String CASE_LIST_PAGE_URL = "portal/1549F58C18A6C562/CaseListPage.ivp"; private static final String PROCESS_LIST_PAGE_URL = "portal/1549F58C18A6C562/DefaultProcessStartListPage.ivp"; - private static final String STATISTIC_PAGE_URL = "portal/1549F58C18A6C562/StatisticPage.ivp"; public static void navigateToRelativeLink(String relativeProcessStartUrl) { try { @@ -36,8 +34,4 @@ public static ProcessWidgetPage navigateToProcessList() { return new ProcessWidgetPage(); } - public static StatisticWidgetPage navigateToStatisticPage() { - navigateToRelativeLink(STATISTIC_PAGE_URL); - return new StatisticWidgetPage(); - } } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/AdditionalComponentsScreenshotTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/AdditionalComponentsScreenshotTest.java index 3d770f38673..02b81c32cbd 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/AdditionalComponentsScreenshotTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/AdditionalComponentsScreenshotTest.java @@ -17,7 +17,6 @@ import com.axonivy.portal.selenium.page.NewDashboardPage; import com.axonivy.portal.selenium.page.ProcessHistoryPage; import com.axonivy.portal.selenium.page.ProcessViewerPage; -import com.axonivy.portal.selenium.page.StatisticWidgetPage; import com.axonivy.portal.selenium.page.TaskTemplatePage; import com.axonivy.portal.selenium.page.component.DocumentTableComponentPage; import com.axonivy.portal.selenium.page.component.ProcessViewerComponentPage; @@ -94,21 +93,6 @@ public void captureScreenshotDocumentTableComponent() throws IOException { ScreenshotUtils.capturePageScreenshot(ScreenshotUtils.COMPONENTS_FOLDER + "document-table"); } - @Test - public void captureScreenshotTaskAnalysisComponent() throws IOException { - redirectToRelativeLink(create12CasesWithCategoryUrl); - redirectToRelativeLink(createTestingTasksUrl); - login(TestAccount.ADMIN_USER); - showNewDashboard(); - NewDashboardPage homepage = new NewDashboardPage(); - homepage.waitForCaseWidgetLoaded(); - MainMenuPage mainMenuPage = new MainMenuPage(); - StatisticWidgetPage statisticWidgetDashboardPage = mainMenuPage.openStatisticPage(); - statisticWidgetDashboardPage.navigateToTaskAnalysisPage(); - ScreenshotUtils.resizeBrowser(new Dimension(1500, 1000)); - ScreenshotUtils.capturePageScreenshot(ScreenshotUtils.COMPONENTS_FOLDER + "task-analysis"); - } - @Test public void captureScreenshotUserSelectionComponent() throws IOException { redirectToRelativeLink(userSelectionComponentShowcaseUrl); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/StatisticScreenshotTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/StatisticScreenshotTest.java index 766009f13bd..65896b7c228 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/StatisticScreenshotTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/StatisticScreenshotTest.java @@ -13,12 +13,8 @@ import com.axonivy.portal.selenium.common.ScreenshotUtils; import com.axonivy.portal.selenium.common.TestAccount; import com.axonivy.portal.selenium.common.Variable; -import com.axonivy.portal.selenium.common.WaitHelper; import com.axonivy.portal.selenium.page.ClientStatisticWidgetNewDashboardPage; -import com.axonivy.portal.selenium.page.MainMenuPage; import com.axonivy.portal.selenium.page.NewDashboardPage; -import com.axonivy.portal.selenium.page.StatisticWidgetPage; -import com.axonivy.portal.selenium.page.TaskWidgetPage; import ch.ivy.addon.portalkit.enums.PortalVariable; @@ -34,53 +30,6 @@ public void setup() { login(TestAccount.ADMIN_USER); } - @Test - public void screenshotForStatistic() throws IOException { - showNewDashboard(); - NewDashboardPage homePage = new NewDashboardPage(); - homePage.waitForCaseWidgetLoaded(); - MainMenuPage mainMenu = new MainMenuPage(); - - TaskWidgetPage taskWidgetPage = mainMenu.openTaskList(); - taskWidgetPage.openTask("SupportTicket"); - - ScreenshotUtils.resizeBrowser(new Dimension(1460, 800)); - WaitHelper.waitForNavigation(() -> redirectToRelativeLink(createTestingTasksUrl)); - homePage = new NewDashboardPage(); - homePage.waitForCaseWidgetLoaded(); - homePage.waitForGrowlMessageDisappear(); - mainMenu.expandMainMenu(); - - ScreenshotUtils.executeDecorateJs("highlightStatisticNavigation()"); - ScreenshotUtils.capturePageScreenshot(ScreenshotUtils.STATISTIC_WIDGET_FOLDER + "navigate-to-full-statistics-page"); - ScreenshotUtils.resizeBrowser(new Dimension(1386, 2210)); - - StatisticWidgetPage statisticWidgetPage = mainMenu.openStatisticPage(); - statisticWidgetPage.switchCreateMode(); - mainMenu.closeMainMenu(); - - statisticWidgetPage.createTaskByPriorityChart(); - statisticWidgetPage.createTaskByExpiryChart(); - ScreenshotUtils.captureElementScreenshot(statisticWidgetPage.waitAndGetChartCreationContainer(), - ScreenshotUtils.STATISTIC_WIDGET_FOLDER + "available-charts"); - - WebElement chartCreationDialog = statisticWidgetPage.getCaseByFinishedTaskCreationDialog(); - ScreenshotUtils.captureElementWithMarginOptionScreenshot(chartCreationDialog, - ScreenshotUtils.STATISTIC_WIDGET_FOLDER + "chart-creation-dialog", new ScreenshotMargin(10, 10)); - - refreshPage(); - statisticWidgetPage.waitForChartCreationPageRendered(); - statisticWidgetPage.backToDashboard(); - statisticWidgetPage.waitForAllChartLoaded(); - ScreenshotUtils.executeDecorateJs("numberingChartPanel()"); - ScreenshotUtils.captureElementWithMarginOptionScreenshot(statisticWidgetPage.waitAndGetChartPanelByIndex(1), - ScreenshotUtils.STATISTIC_WIDGET_FOLDER + "chart-detail-with-annotation", new ScreenshotMargin(20, 10)); - refreshPage(); - statisticWidgetPage.waitForAllChartLoaded(); - ScreenshotUtils.captureElementWithMarginOptionScreenshot(statisticWidgetPage.getChartInfoDialogOfChart(1), - ScreenshotUtils.STATISTIC_WIDGET_FOLDER + "chart-info-dialog", new ScreenshotMargin(20, 10)); - } - @Test public void screenshotStatisticWidgetList() throws IOException { showNewDashboard(); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/TaskAnalysisScreenshotTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/TaskAnalysisScreenshotTest.java deleted file mode 100644 index 90cf6f7274e..00000000000 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/document/screenshot/TaskAnalysisScreenshotTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.axonivy.portal.selenium.document.screenshot; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.Dimension; - -import com.axonivy.ivy.webtest.IvyWebTest; -import com.axonivy.portal.selenium.common.ScreenshotBaseTest; -import com.axonivy.portal.selenium.common.ScreenshotMargin; -import com.axonivy.portal.selenium.common.ScreenshotUtils; -import com.axonivy.portal.selenium.common.TestAccount; -import com.axonivy.portal.selenium.common.Variable; -import com.axonivy.portal.selenium.page.MainMenuPage; -import com.axonivy.portal.selenium.page.NewDashboardPage; -import com.axonivy.portal.selenium.page.StatisticWidgetPage; -import com.axonivy.portal.selenium.page.TaskAnalysisWidgetPage; - -@IvyWebTest -public class TaskAnalysisScreenshotTest extends ScreenshotBaseTest { - - @Override - @BeforeEach - public void setup() { - super.setup(); - updatePortalSetting(Variable.ENABLE_GROUP_CHAT.getKey(), "true"); - login(TestAccount.ADMIN_USER); - redirectToRelativeLink(createTestingTasksUrl); - } - - @Test - public void screenshotTaskAnalysisPage() throws IOException { - showNewDashboard(); - NewDashboardPage homePage = new NewDashboardPage(); - homePage.waitForCaseWidgetLoaded(); - MainMenuPage mainMenu = new MainMenuPage(); - StatisticWidgetPage statisticWidgetPage = mainMenu.openStatisticPage(); - - ScreenshotUtils.executeDecorateJs("highlightTaskAnalysisNavigationLink()"); - ScreenshotUtils.resizeBrowser(new Dimension(1200, 800)); - ScreenshotUtils - .captureHalfTopRightPageScreenShot(ScreenshotUtils.TASK_ANALYSIS_FOLDER + "navigate-to-task-analysis"); - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - - ScreenshotUtils.resizeBrowser(new Dimension(1400, 900)); - ScreenshotUtils.capturePageScreenshot(ScreenshotUtils.TASK_ANALYSIS_FOLDER + "task-analysis"); - - taskAnalysisWidgetPage.openAdvancedTaskFilter("Priority", "priority"); - List selectedPriorities = new ArrayList<>(); - selectedPriorities.add("NORMAL"); - taskAnalysisWidgetPage.filterByTaskPriority(selectedPriorities); - taskAnalysisWidgetPage.clickApplyFilter(); - ScreenshotUtils.resizeBrowser(new Dimension(1400, 800)); - ScreenshotUtils.capturePageScreenshot(ScreenshotUtils.TASK_ANALYSIS_FOLDER + "filtered-tasks"); - taskAnalysisWidgetPage.enterDataToSaveFilterSet("Normal Priority Task", true); - ScreenshotUtils.captureElementWithMarginOptionScreenshot(taskAnalysisWidgetPage.waitAndGetSavingFilterDialog(), - ScreenshotUtils.TASK_ANALYSIS_FOLDER + "saved-filter", new ScreenshotMargin(20)); - } -} diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/MainMenuPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/MainMenuPage.java index 1ff015374d7..ec55eb14061 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/MainMenuPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/MainMenuPage.java @@ -1,7 +1,6 @@ package com.axonivy.portal.selenium.page; import static com.codeborne.selenide.Condition.appear; - import static com.codeborne.selenide.Condition.disappear; import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; @@ -41,10 +40,6 @@ public ProcessWidgetPage openProcessList() { return NavigationHelper.navigateToProcessList(); } - public StatisticWidgetPage openStatisticPage() { - return NavigationHelper.navigateToStatisticPage(); - } - public void openUserSettingMenu() { $("#top-menu").shouldBe(appear, DEFAULT_TIMEOUT); $("a[id='user-settings-menu']").shouldBe(clickable(), DEFAULT_TIMEOUT).click(); @@ -92,12 +87,6 @@ public CaseWidgetPage selectCaseMenu() { return new CaseWidgetPage(); } - public StatisticWidgetPage selectStatisticDashboard() { - WaitHelper - .waitForNavigation(() -> waitForElementClickableThenClick($(".layout-menu li[role='menuitem'] a.STATISTICS"))); - return new StatisticWidgetPage(); - } - private void waitForProcessesPageAfterSelectProcessesCategory() { waitForElementDisplayed(By.id("process-widget:process-search:non-ajax-keyword-filter"), true); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardDetailsEditPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardDetailsEditPage.java index c81eaa66fb7..a7ed76f4dc6 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardDetailsEditPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardDetailsEditPage.java @@ -17,7 +17,6 @@ public class NewDashboardDetailsEditPage extends TemplatePage { public static final String PROCESS_WIDGET = "Process List"; public static final String PROCESS_VIEWER_WIDGET = "Process Viewer"; public static final String CUSTOM_WIDGET = "Custom Widget"; - public static final String STATISTIC_WIDGET = "Statistic chart"; public static final String WELCOME_WIDGET = "Welcome widget"; public static final String NEWS_WIDGET = "News feed widget"; public static final String TASK_BY_PRIORITY = "Tasks by Priority"; @@ -161,10 +160,6 @@ public StatisticEditWidgetNewDashboardPage addNewStatisticWidget() { return new StatisticEditWidgetNewDashboardPage(); } - public StatisticWidgetDashboardPage selectStatisticWidget() { - return new StatisticWidgetDashboardPage(); - } - public SelenideElement getTitleByIndex(int index) { return $("a[id='dashboard-title-" + index + "']"); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardPage.java index f9b9702d7f8..ba19e930b67 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/NewDashboardPage.java @@ -779,10 +779,6 @@ public void selectDashboard(int index) { selectDashboard.parent().shouldBe(Condition.cssClass("active-menuitem"), DEFAULT_TIMEOUT); } - public StatisticWidgetDashboardPage selectStatisticWidget() { - return new StatisticWidgetDashboardPage(); - } - public void checkDisplayedCaseWidgetContainer() { getCaseWidgetContainer().shouldBe(Condition.appear, DEFAULT_TIMEOUT); } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/StatisticWidgetDashboardPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/StatisticWidgetDashboardPage.java deleted file mode 100644 index c806b5f284f..00000000000 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/StatisticWidgetDashboardPage.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.axonivy.portal.selenium.page; - -import static com.codeborne.selenide.Condition.appear; -import static com.codeborne.selenide.Condition.disappear; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -public class StatisticWidgetDashboardPage extends TemplatePage { - - @Override - protected String getLoadedLocator() { - return ".statistic-chart-widget__content"; - } - - public ElementsCollection countStatisticCharts() { - return $$(".statistic-chart-widget .widget__header-title"); - } - - public SelenideElement getStatisticInfoIconOfChart(String chartId) { - return $(String.format("[id$='chart-%s:info-sidebar-link-0']", chartId)).shouldBe(appear, DEFAULT_TIMEOUT) - .should(getClickableCondition()); - } - - public void openStatisticInfoPanel(String chartId) { - getStatisticInfoIconOfChart(chartId).click(); - $(String.format("[id$='chart-%s:info-overlay-panel-0']", chartId)).shouldBe(appear, DEFAULT_TIMEOUT); - } - - public ElementsCollection countFilterOfStatistic(String chartId) { - return $(String.format("[id$='chart-%s:info-overlay-panel-0']", chartId)).shouldBe(appear, DEFAULT_TIMEOUT) - .$("table[id$=':chart-filter-container']").shouldBe(appear, DEFAULT_TIMEOUT).$$("tr"); - } - - public String getChartName(String chartId) { - return $(String.format("span[id$='chart-%s:widget__header']", chartId)).shouldBe(appear, DEFAULT_TIMEOUT).getText(); - } - - public SelenideElement getEditIconOfChart(String chartId) { - return $(String.format("[id$='chart-%s:widget-header-actions']", chartId)).shouldBe(appear, DEFAULT_TIMEOUT) - .$(String.format("[id$='chart-%s:edit-widget-0']", chartId)).shouldBe(appear, DEFAULT_TIMEOUT); - } - - public String openEditStatisticWidgetDialog(String chartId) { - getEditIconOfChart(chartId).should(getClickableCondition()).click(); - return $("[id$='new-widget-configuration-dialog']").shouldBe(appear, DEFAULT_TIMEOUT) - .$("span[id$='new-widget-configuration-dialog_title']").shouldBe(appear, DEFAULT_TIMEOUT).getText(); - } - - public void clickOnCancelConfiguration() { - $("[id$='new-widget-configuration-dialog']").shouldBe(appear, DEFAULT_TIMEOUT) - .$("a[id$='task-configuration-cancel-link']").shouldBe(appear, DEFAULT_TIMEOUT) - .shouldBe(getClickableCondition()).click(); - $("[id$='new-widget-configuration-dialog']").shouldBe(disappear, DEFAULT_TIMEOUT); - } -} diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/StatisticWidgetPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/StatisticWidgetPage.java deleted file mode 100644 index e84f360483d..00000000000 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/StatisticWidgetPage.java +++ /dev/null @@ -1,270 +0,0 @@ -package com.axonivy.portal.selenium.page; - -import static com.codeborne.selenide.CollectionCondition.size; -import static com.codeborne.selenide.Condition.appear; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -import java.util.Set; -import java.util.stream.Collectors; - -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.axonivy.portal.selenium.common.WaitHelper; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.SelenideElement; -import com.codeborne.selenide.WebDriverRunner; - -public class StatisticWidgetPage extends TemplatePage { - public static final String TASK_BY_PRIORITY_CHART_NAME = "Task by priority chart"; - public static final String CASE_BY_STATE_CHART_NAME = "Case by state chart"; - public static final String TASK_BY_EXPIRY_CHART_NAME = "Task by expiry chart"; - public static final String ELAPSED_TIME_CHART_NAME = "Elapsed time chart"; - public static final String CASE_BY_FINISHED_TASK_CHART_NAME = "Case by finished task chart"; - public static final String CASE_BY_FINISHED_TIME_CHART_NAME = "Case by finished time chart"; - public static final String CASES_BY_CATEGORY_CHART_NAME = "Cases by category chart"; - - @Override - protected String getLoadedLocator() { - return "[id='statistics-widget']"; - } - - public TaskAnalysisWidgetPage navigateToTaskAnalysisPage() { - waitForPageLoad(); - var taskAnalysLink = $("a[id='statistics-widget:task-analysis-page-navigation-link']") - .shouldBe(Condition.appear, DEFAULT_TIMEOUT).shouldBe(getClickableCondition(), DEFAULT_TIMEOUT); - WaitHelper.waitForNavigation(() -> waitForElementClickableThenClick(taskAnalysLink)); - $("[id='task-widget']").shouldBe(Condition.appear, DEFAULT_TIMEOUT); - return new TaskAnalysisWidgetPage(); - } - - public Set getAllChartNames() { - $(By.id("chart-name-0")).shouldBe(Condition.appear, DEFAULT_TIMEOUT); - return $$("div[id$=':chart-name-container'] .chart-name").shouldHave(size(1), DEFAULT_TIMEOUT).asFixedIterable() - .stream().map(e -> e.getText()).collect(Collectors.toSet()); - } - - public String getRestoreDefaultButtonName() { - return findElementByCssSelector("span[id$='restore-default-chart-link-label']").getText(); - } - - public boolean hasCreateChartsLink() { - return isElementPresent(By.id("statistics-widget:create-chart-link-label")); - } - - private boolean isCompactMode() { - waitPageLoaded(); - waitForElementDisplayed(By.id("statistics-widget:widget-container"), true); - WebElement statisticContainer = findElementById("statistics-widget:widget-container"); - return statisticContainer.getAttribute(CLASS_PROPERTY).contains("compact-mode"); - } - - public boolean isFullMode() { - return !isCompactMode(); - } - - public void createCaseByStateChart() { - waitForElementDisplayed( - By.id("statistics-widget:chart-creation-widget:chart-management-form:create-case-by-state-link"), true, 30); - SelenideElement createCaseByStateLink = - findElementById("statistics-widget:chart-creation-widget:chart-management-form:create-case-by-state-link"); - waitForElementClickableThenClick(createCaseByStateLink); - - waitForElementDisplayed(By.cssSelector("div[id$='add-chart-dialog']"), true); - - inputNameForSupportedLanguages(CASE_BY_STATE_CHART_NAME); - waitForElementClickableThenClick("button[id$='chart-save-command']"); - - waitForElementExisted(By.cssSelector("span[class='ui-growl-title']"), true); - } - - public void createCaseByFinishTime() { - waitForElementDisplayed( - By.id("statistics-widget:chart-creation-widget:chart-management-form:create-case-by-finished-time-link"), true, - 30); - SelenideElement createCaseByFinishedTaskLink = findElementById( - "statistics-widget:chart-creation-widget:chart-management-form:create-case-by-finished-time-link"); - waitForElementClickableThenClick(createCaseByFinishedTaskLink); - - waitForElementDisplayed(By.cssSelector("div[id$='add-chart-dialog']"), true); - inputNameForSupportedLanguages(CASE_BY_FINISHED_TIME_CHART_NAME); - waitForElementClickableThenClick("button[id$='chart-save-command']"); - - waitForElementExisted(By.cssSelector("span[class='ui-growl-title']"), true); - } - - public void createTaskByPriorityChartMultiLanguage() { - waitForElementDisplayed( - By.id("statistics-widget:chart-creation-widget:chart-management-form:create-task-by-priority-link"), true, 30); - waitForElementClickableThenClick( - $(By.id("statistics-widget:chart-creation-widget:chart-management-form:create-task-by-priority-link"))); - - waitForElementDisplayed(By.cssSelector("div[id$='add-chart-dialog']"), true); - - findElementByCssSelector("input[id$='0:chart-name-input']") - .sendKeys(TASK_BY_PRIORITY_CHART_NAME.concat(" English")); - findElementByCssSelector("input[id$='1:chart-name-input']").sendKeys(TASK_BY_PRIORITY_CHART_NAME.concat(" French")); - findElementByCssSelector("input[id$='2:chart-name-input']").sendKeys(TASK_BY_PRIORITY_CHART_NAME.concat(" German")); - findElementByCssSelector("input[id$='3:chart-name-input']") - .sendKeys(TASK_BY_PRIORITY_CHART_NAME.concat(" Spanish")); - - waitForElementClickableThenClick("button[id$='chart-save-command']"); - waitForElementExisted(By.cssSelector("span[class='ui-growl-title']"), true); - } - - public void createCasesByCategory() { - waitForElementDisplayed( - By.id("statistics-widget:chart-creation-widget:chart-management-form:create-cases-by-category-link"), true, 30); - SelenideElement createCaseByFinishedTaskLink = - findElementById("statistics-widget:chart-creation-widget:chart-management-form:create-cases-by-category-link"); - waitForElementClickableThenClick(createCaseByFinishedTaskLink); - - waitForElementDisplayed(By.cssSelector("div[id$='add-chart-dialog']"), true); - inputNameForSupportedLanguages(CASES_BY_CATEGORY_CHART_NAME); - waitForElementClickableThenClick("button[id$='chart-save-command']"); - - waitForElementExisted(By.cssSelector("span[class='ui-growl-title']"), true); - } - - public void createElapsedTimeChart() { - waitForElementDisplayed( - By.id("statistics-widget:chart-creation-widget:chart-management-form:create-elapsed-time-link"), true, 30); - SelenideElement createElapsedTimeLink = - findElementById("statistics-widget:chart-creation-widget:chart-management-form:create-elapsed-time-link"); - waitForElementClickableThenClick(createElapsedTimeLink); - - waitForElementDisplayed(By.cssSelector("div[id$='add-chart-dialog']"), true); - inputNameForSupportedLanguages(ELAPSED_TIME_CHART_NAME); - waitForElementClickableThenClick("button[id$='chart-save-command']"); - - waitForElementExisted(By.cssSelector("span[class='ui-growl-title']"), true); - } - - public void createCaseByFinishedTask() { - var caseByFinishedTaskSelector = "button[id$=':chart-management-form:create-case-by-finished-task-link']"; - waitForElementClickableThenClick($(caseByFinishedTaskSelector)); - waitForElementDisplayed(By.cssSelector("div[id$='add-chart-dialog']"), true); - - inputNameForSupportedLanguages(CASE_BY_FINISHED_TASK_CHART_NAME); - waitForElementClickableThenClick($(By.cssSelector("button[id$='chart-save-command']"))); - waitForElementDisplayed(By.cssSelector("div[id$='add-chart-dialog']"), false); - waitForElementExisted(By.cssSelector("span[class='ui-growl-title']"), true); - } - - public void restoreDefaultCharts() { - new WebDriverWait(WebDriverRunner.getWebDriver(), DEFAULT_TIMEOUT).until((webDriver) -> { - WebElement restoreDefault = findElementByCssSelector("span[id$='restore-default-chart-link-label']"); - try { - return restoreDefault.getText().contains("Restore default"); - } catch (WebDriverException e) { - System.out.println("Exception when waiting for element existed, try again."); - } - return false; - }); - waitForElementClickableThenClick($("span[id$='restore-default-chart-link-label']")); - waitForElementDisplayed(By.id("statistics-widget:restore-confirmation-dialog"), true, 30); - waitForElementClickableThenClick($(By.id("statistics-widget:confirm-restore"))); - } - - public String getChartName(int chartIndex) { - new WebDriverWait(WebDriverRunner.getWebDriver(), DEFAULT_TIMEOUT).until((webDriver) -> { - try { - return findElementByCssSelector(String.format("div[id$='%d:chart-name-container'] .chart-name", chartIndex)) - .getText().length() > 1; - } catch (WebDriverException e) { - System.out.println("Exception when waiting for element existed, try again."); - } - return false; - }); - WebElement chartName = - findElementByCssSelector(String.format("div[id$='%d:chart-name-container'] .chart-name", chartIndex)); - return chartName.getText(); - } - - public void switchCreateMode() { - $("a[id$='create-chart-link']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("a[id$='statistics-widget:back-from-chart-creation']").shouldBe(appear, DEFAULT_TIMEOUT); - } - - public void waitForAllChartLoaded() { - SelenideElement element = - $("[id$='statistics-widget:statistic-dashboard-widget:statistic-chart-repeater:0:chart-name-container'] a"); - element.shouldBe(clickable(), DEFAULT_TIMEOUT).click(); - $("[id$='statistics-widget:statistic-dashboard-widget:chart-details-dialog']").shouldBe(appear, DEFAULT_TIMEOUT) - .$("button.ui-button-text-icon-left").shouldBe(appear, DEFAULT_TIMEOUT).click(); - } - - public void createTaskByPriorityChart() { - $("[id='statistics-widget:chart-creation-widget:chart-management-form:create-task-by-priority-link']") - .shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("div[id$='add-chart-dialog']").shouldBe(appear, DEFAULT_TIMEOUT); - - inputNameForSupportedLanguages(TASK_BY_PRIORITY_CHART_NAME); - $("button[id$='chart-save-command']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("span[class='ui-growl-title']").shouldBe(appear, DEFAULT_TIMEOUT); - } - - private void inputNameForSupportedLanguages(String value) { - for (int i = 0; i < 4; i++) { - $("input[id$='" + i + ":chart-name-input']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).sendKeys(value); - } - } - - public void createTaskByExpiryChart() { - $("[id='statistics-widget:chart-creation-widget:chart-management-form:create-task-by-expiry-link']") - .shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - - $("div[id$='add-chart-dialog']").shouldBe(appear, DEFAULT_TIMEOUT); - inputNameForSupportedLanguages(TASK_BY_EXPIRY_CHART_NAME); - $("button[id$='chart-save-command']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - - $("span[class='ui-growl-title']").shouldBe(appear, DEFAULT_TIMEOUT); - } - - public SelenideElement getChartCreationContainer() { - return $("[id='statistics-widget:chart-creation-widget:chart-management-form:chart-list']"); - } - - public WebElement waitAndGetChartCreationContainer() { - return getChartCreationContainer().shouldBe(appear, DEFAULT_TIMEOUT); - } - - public WebElement getCaseByFinishedTaskCreationDialog() { - $("[id='statistics-widget:chart-creation-widget:chart-management-form:create-case-by-finished-task-link']") - .shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("div[id$='add-chart-dialog']").shouldBe(appear, DEFAULT_TIMEOUT); - - inputNameForSupportedLanguages(CASE_BY_FINISHED_TASK_CHART_NAME); - return $("div[id$='add-chart-dialog']").shouldBe(appear, DEFAULT_TIMEOUT); - } - - public void waitForChartCreationPageRendered() { - $("[id='statistics-widget:back-from-chart-creation']").shouldBe(appear, DEFAULT_TIMEOUT); - } - - public void backToDashboard() { - $("a[id$='back-from-chart-creation']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("a[id$='create-chart-link']").shouldBe(appear, DEFAULT_TIMEOUT); - } - - public SelenideElement getChartPanelByIndex(int index) { - return $(String.format("span[id$='%d:chart-panel']", index)); - } - - public WebElement waitAndGetChartPanelByIndex(int index) { - return getChartPanelByIndex(index).shouldBe(appear, DEFAULT_TIMEOUT); - } - - public WebElement getChartInfoDialogOfChart(int chartIndex) { - $("[id='" - + String.format("statistics-widget:statistic-dashboard-widget:statistic-chart-repeater:%d:chart-name-container", - chartIndex) - + "']").shouldBe(appear, DEFAULT_TIMEOUT).$("a.chart-info").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT) - .click(); - return $("[id='statistics-widget:statistic-dashboard-widget:chart-details-dialog']").shouldBe(appear, - DEFAULT_TIMEOUT); - } -} diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskAnalysisWidgetPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskAnalysisWidgetPage.java deleted file mode 100644 index 9b690d99d2e..00000000000 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskAnalysisWidgetPage.java +++ /dev/null @@ -1,362 +0,0 @@ -package com.axonivy.portal.selenium.page; - -import static com.codeborne.selenide.Condition.appear; -import static com.codeborne.selenide.Selenide.$; -import static com.codeborne.selenide.Selenide.$$; - -import java.util.List; - -import org.openqa.selenium.By; -import org.openqa.selenium.NoSuchElementException; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.WebDriverWait; - -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; -import com.codeborne.selenide.WebDriverRunner; - -public class TaskAnalysisWidgetPage extends TemplatePage { - - private static final String TASK_FILTER_SELECTION = "task-widget:task-filter-add-form:task-filter-selection"; - - @Override - protected String getLoadedLocator() { - return "div[id='task-widget']"; - } - - public void openAdvancedTaskFilter(String filterName, String filterIdName) { - findTaskFilterButton().shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("[id='" + TASK_FILTER_SELECTION + "']").shouldBe(appear, DEFAULT_TIMEOUT).$$("label").asFixedIterable().stream() - .filter(filter -> filter.getText().contentEquals(filterName)).findFirst().get() - .shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("[id='task-widget:task-filter-add-form:update-task-filter-selected-command']") - .shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("span[id$='" + filterIdName + "-filter:filter-open-form:advanced-filter-item-container']").shouldBe(appear, - DEFAULT_TIMEOUT); - } - - public void filterByTaskPriority(List selectedPriorities) { - $("[id$='priority-filter:filter-open-form:advanced-filter-command']") - .shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("[id$='priority-filter:filter-input-form:advanced-filter-panel-content']").shouldBe(appear, DEFAULT_TIMEOUT) - .$$("label").asFixedIterable().stream().filter(filter -> !selectedPriorities.contains(filter.getText())) - .forEach(filter -> filter.shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click()); - - $("[id$='priority-filter:filter-input-form:update-command']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT) - .click(); - } - - public void clickApplyFilter() { - $("button[id$='task-widget:apply-filter']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - } - - private SelenideElement findTaskFilterButton() { - return $("[id='task-widget:task-filter-add-action']"); - } - - public void enterDataToSaveFilterSet(String filterSetName, boolean isPersonalFilter) { - $("[id='task-widget:filter-save-action']").shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click(); - $("[id='task-widget:filter-save-form:save-filter-set-name-input']").shouldBe(appear, DEFAULT_TIMEOUT) - .sendKeys(filterSetName); - - SelenideElement filterVisibilityContainer = findElementById("task-widget:filter-save-form:save-filter-type-radio"); - if (isPersonalFilter) { - filterVisibilityContainer.$$(By.tagName("LABEL")).get(0).shouldBe(clickable(), DEFAULT_TIMEOUT).click(); - } else { - filterVisibilityContainer.$$(By.tagName("LABEL")).get(1).shouldBe(clickable(), DEFAULT_TIMEOUT).click(); - } - } - - public WebElement waitAndGetSavingFilterDialog() { - return $("div[id$='save-filter-set-dialog']").shouldBe(appear, DEFAULT_TIMEOUT); - } - - public StatisticWidgetPage navigateToStatisticPage() { - String backButtonId = "task-widget:back-button"; - waitForElementDisplayed(By.id(backButtonId), true); - SelenideElement backButton = findElementById(backButtonId); - - clickByJavaScript(backButton); - waitForElementDisplayed(By.id("statistics-widget"), true); - return new StatisticWidgetPage(); - } - - public void clickOnColumnToggler() { - String togglerId = "task-widget:statistic-result-form:toggler"; - waitForElementDisplayed(By.id(togglerId), true); - clickByJavaScript(findElementById(togglerId)); - } - - public void filterByTaskName(String text) { - waitForElementClickableThenClick($("[id$='task-name-filter:filter-open-form:advanced-filter-command']")); - $("input[id$='task-name-filter:filter-input-form:name']").shouldBe(appear, DEFAULT_TIMEOUT).sendKeys(text); - waitForElementClickableThenClick($("[id$='task-name-filter:filter-input-form:update-command']")); - } - - public ElementsCollection getRowsInTaskTable() { - return findElementById("task-widget:statistic-result-form:task-table_data") - .$$(By.cssSelector("tr.ui-widget-content")); - } - - private SelenideElement findCaseFilterButton() { - String caseFilterButtonId = "task-widget:case-filter-add-action"; - waitForElementDisplayed(By.id(caseFilterButtonId), true); - return findElementById(caseFilterButtonId); - } - - public void openAdvancedCaseFilter(String filterName, String filterIdName) { - waitForElementClickableThenClick(findCaseFilterButton()); - waitForElementDisplayed(findElementById("task-widget:case-filter-add-form:case-filter-selection"), true); - SelenideElement filterSelectionElement = findElementById("task-widget:case-filter-add-form:case-filter-selection"); - for (SelenideElement filterElement : filterSelectionElement.$$(By.tagName("LABEL"))) { - if (filterName.equals(filterElement.getText())) { - waitForElementClickableThenClick(filterElement); - waitForElementClickableThenClick( - $("button[id$='task-widget:case-filter-add-form:update-task-filter-selected-command']")); - break; - } - } - waitForElementDisplayed( - By.cssSelector("span[id$='" + filterIdName + "-filter:filter-open-form:advanced-filter-item-container']"), - true); - } - - public void filterByCaseName(String text) { - waitForElementClickableThenClick($("[id$='case-name-filter:filter-open-form:advanced-filter-command']")); - findElementByCssSelector("input[id$='case-name-filter:filter-input-form:name']").shouldBe(appear, DEFAULT_TIMEOUT) - .sendKeys(text); - waitForElementClickableThenClick($("[id$='case-name-filter:filter-input-form:update-command']")); - } - - public void filterByCaseState(List selectedPriorities) { - waitForElementClickableThenClick($( - "div[id$='task-widget:case-filters-container'] button[id$='state-filter:filter-open-form:advanced-filter-command']")); - SelenideElement selectionElement = findElementByCssSelector( - "div[id$='task-widget:case-filters-container'] div[id$='state-filter:filter-input-form:advanced-filter-panel-content']"); - for (SelenideElement labelElement : selectionElement.$$(By.tagName("LABEL"))) { - if (!selectedPriorities.contains(labelElement.getText())) { - waitForElementClickableThenClick(labelElement); - } - } - waitForElementClickableThenClick( - $("div[id$='task-widget:case-filters-container'] button[id$='state-filter:filter-input-form:update-command']")); - } - - public void filterByTaskCategory(String selectedCategory) { - waitForElementClickableThenClick($("[id$='task-category-filter:filter-open-form:advanced-filter-command']")); - waitForElementDisplayed($("div[id$=':task-category-filter-tree']"), true); - SelenideElement selectionElement = - findElementByCssSelector("[id$='task-category-filter:filter-input-form:advanced-filter-panel-content']"); - List categoryTreeLabels = selectionElement.$$(By.className("ui-treenode-label")); - // Find parent node of tree first and uncheck it - SelenideElement parentNodeOfTree = categoryTreeLabels.stream().findFirst().get(); - waitForElementDisplayed(parentNodeOfTree, true); - waitForElementClickableThenClick(parentNodeOfTree); - for (SelenideElement labelElement : categoryTreeLabels) { - if (selectedCategory.contains(labelElement.getText())) { - waitForElementClickableThenClick(labelElement); - break; - } - } - waitForElementClickableThenClick($("[id$='task-category-filter:filter-input-form:update-command']")); - } - - public void filterByCaseCategory(String selectedCategory) { - waitForElementClickableThenClick($("[id$='case-category-filter:filter-open-form:advanced-filter-command']")); - waitForElementDisplayed($("div[id$=':case-category-filter-tree']"), true); - SelenideElement selectionElement = - findElementByCssSelector("[id$='case-category-filter:filter-input-form:advanced-filter-panel-content']"); - List categoryTreeLabels = selectionElement.$$(By.className("ui-treenode-label")); - // Find parent node of tree first and uncheck it - SelenideElement parentNodeOfTree = categoryTreeLabels.stream().findFirst().get(); - waitForElementDisplayed(parentNodeOfTree, true); - waitForElementClickableThenClick(parentNodeOfTree); - for (SelenideElement labelElement : categoryTreeLabels) { - if (selectedCategory.contains(labelElement.getText())) { - waitForElementClickableThenClick(labelElement); - break; - } - } - waitForElementClickableThenClick($("button[id$='case-category-filter:filter-input-form:update-command']")); - } - - public void filterByOwner(String user) { - openAdvancedCaseFilter("Owner", "owner"); - waitForElementClickableThenClick($("button[id$='owner-filter:filter-open-form:advanced-filter-command']")); - findElementByCssSelector("input[id$='owner-filter:filter-input-form:owner_input']").sendKeys(user); - waitForElementDisplayed($("span[id$='owner-filter:filter-input-form:owner_panel']"), true); - waitForElementDisplayed($("div[id*='owner-filter'] .ui-avatar-text"), true); - waitForElementClickableThenClick($("[id$=':owner-filter:filter-input-form:owner_panel']")); - waitForElementClickableThenClick($("button[id$='owner-filter:filter-input-form:update-command']")); - } - - public void saveFilterSet(String filterSetName, boolean isPersonalFilter) { - enterDataToSaveFilterSet(filterSetName, isPersonalFilter); - SelenideElement saveButton = - $("button[id$='task-widget:filter-save-form:filter-save-command']").shouldBe(appear, DEFAULT_TIMEOUT); - waitForElementClickableThenClick(saveButton); - $("[id='task-widget:save-filter-set-dialog']").shouldBe(Condition.disappear, DEFAULT_TIMEOUT); - saveButton.shouldBe(Condition.disappear, DEFAULT_TIMEOUT); - } - - public void waitForTaskDataChangeToSpecificSize(int size) { - new WebDriverWait(WebDriverRunner.getWebDriver(), DEFAULT_TIMEOUT).until((driver) -> { - return getRowsInTaskTable().size() == size; - }); - } - - public boolean loadFilterSet(String filterSetName, boolean isPersonalFilter) { - waitPageLoaded(); - waitForElementDisplayed( - $("a[id$='task-widget:filter-selection-form:filter-name']"), true); - waitForElementClickableThenClick( - "a[id$='task-widget:filter-selection-form:filter-name']"); - waitForElementDisplayed( - findElementById( - "task-widget:filter-selection-form:filter-name-overlay-panel"), - true); - SelenideElement filterContainer = null; - if (isPersonalFilter) { - try { - filterContainer = findElementById( - "task-widget:filter-selection-form:private-filters"); - } catch (NoSuchElementException e) { - return false; - } - } else { - try { - filterContainer = findElementById( - "task-widget:filter-selection-form:public-filters"); - } catch (NoSuchElementException e) { - return false; - } - } - - if (!filterContainer.$(By.linkText(filterSetName)).isDisplayed()) { - return false; - } - clickByJavaScript(filterContainer.$(By.linkText(filterSetName)) - .shouldBe(appear, DEFAULT_TIMEOUT)); - return true; - } - - public String getFilterName() { - new WebDriverWait(WebDriverRunner.getWebDriver(), DEFAULT_TIMEOUT).until((driver) -> - - $("a[id$='task-widget:filter-selection-form:filter-name'] > span:nth-child(2)").getText().length() > 1); - WebElement filterName = - findElementByCssSelector("a[id$='task-widget:filter-selection-form:filter-name'] > span:nth-child(2)"); - return filterName.getText(); - } - - private void filterByUserName(String user, String filterIdName) { - waitForElementClickableThenClick( - $("button[id$='" + filterIdName + "-filter:filter-open-form:advanced-filter-command']")); - $("input[id*='" + filterIdName + "-filter:filter-input-form:']").sendKeys(user); - waitForElementExisted(By.cssSelector("div[id*='" + filterIdName + "-filter'] .ui-avatar-text"), true); - waitForElementClickableThenClick($("tr[class$='ui-state-highlight']")); - waitForElementClickableThenClick($("button[id$='" + filterIdName + "-filter:filter-input-form:update-command']")); - } - - public void filterByResponsible(String user, String filterName, String filterIdName) { - openAdvancedTaskFilter(filterName, filterIdName); - waitForElementClickableThenClick($("button[id$='responsible-filter:filter-open-form:advanced-filter-command']")); - $("input[id$='responsible-filter:filter-input-form:responsible_input']").sendKeys(user); - waitForElementDisplayed($("span[id$='responsible-filter:filter-input-form:responsible_panel']"), true); - waitForElementDisplayed($("div[id*='responsible-filter'] .ui-avatar-text"), true); - waitForElementClickableThenClick($("[id$=':responsible-filter:filter-input-form:responsible_panel']")); - waitForElementClickableThenClick($("button[id$='responsible-filter:filter-input-form:update-command']")); - } - - public void removeUserInFilter() { - waitForElementDisplayed(By.cssSelector("button[id$='creator-filter:filter-open-form:advanced-filter-command']"), - true); - waitForElementClickableThenClick($("button[id$='creator-filter:filter-open-form:advanced-filter-command']")); - waitForElementDisplayed( - By.cssSelector("input[id$='creator-filter:filter-input-form:creator-component:creator-select_input']"), true); - findElementByCssSelector("input[id$='creator-filter:filter-input-form:creator-component:creator-select_input']") - .click(); - findElementByCssSelector("input[id$='creator-filter:filter-input-form:creator-component:creator-select_input']") - .clear(); - waitForElementClickableThenClick($("button[id$='creator-filter:filter-input-form:update-command']")); - } - - public void filterUserInCase(String user, String filterName, String filterIdName) { - openAdvancedCaseFilter(filterName, filterIdName); - filterByUserName(user, filterIdName); - } - - public void removeResponsible() { - waitForElementDisplayed(By.cssSelector("button[id$='responsible-filter:filter-open-form:advanced-filter-command']"), - true); - waitForElementClickableThenClick($("button[id$='responsible-filter:filter-open-form:advanced-filter-command']")); - waitForElementDisplayed(By.cssSelector("input[id$='responsible-filter:filter-input-form:responsible_input']"), - true); - findElementByCssSelector("input[id$='responsible-filter:filter-input-form:responsible_input']").click(); - findElementByCssSelector("input[id$='responsible-filter:filter-input-form:responsible_input']").clear(); - waitForElementClickableThenClick($("button[id$='responsible-filter:filter-input-form:update-command']")); - } - - public void openNoActivatorFilter(String filterName) { - findTaskFilterButton().click(); - SelenideElement filterSelectionElement = findElementById(TASK_FILTER_SELECTION); - for (SelenideElement filterElement : filterSelectionElement.$$(By.tagName("LABEL"))) { - if (filterName.equals(filterElement.getText())) { - filterElement.click(); - waitForElementClickableThenClick( - $("button[id$='task-widget:task-filter-add-form:update-task-filter-selected-command']")); - break; - } - } - } - - public void filterByUnavailableActivator() { - waitForElementDisplayed( - By.cssSelector("button[id$='available-activator-filter:filter-open-form:advanced-filter-command']"), true); - waitForElementClickableThenClick( - $("button[id$='available-activator-filter:filter-open-form:advanced-filter-command']")); - - waitForElementDisplayed(By.cssSelector("[id$='available-activator-filter:filter-input-form:available-activator']"), - true); - WebElement displayOnlyUnavailableTaskCheckbox = - findElementByCssSelector("[id$='available-activator-filter:filter-input-form:available-activator']"); - displayOnlyUnavailableTaskCheckbox.click(); - waitForElementClickableThenClick($("button[id$='available-activator-filter:filter-input-form:update-command']")); - } - - public boolean isResetButtonShown() { - waitForElementDisplayed(By.cssSelector("[id$='task-widget:filter-reset-action']"), true); - return isElementDisplayed(By.cssSelector("[id$='task-widget:filter-reset-action']")); - } - - public String getUser(String filterName) { - waitForElementDisplayed($("button[id$='" + filterName + "-filter:filter-open-form:advanced-filter-command']"), - true); - new WebDriverWait(WebDriverRunner.getWebDriver(), DEFAULT_TIMEOUT).until((driver) -> findElementByCssSelector( - "button[id$='" + filterName + "-filter:filter-open-form:advanced-filter-command'] > span").getText() - .length() > 1); - return findElementByCssSelector( - "button[id$='" + filterName + "-filter:filter-open-form:advanced-filter-command'] > span").getText(); - } - - public void resetFilter() { - waitForElementClickableThenClick($("[id$='task-widget:filter-reset-action']")); - waitForElementDisplayed($("[id$='task-widget:filter-reset-command']"), true); - waitForElementClickableThenClick($("[id$='task-widget:filter-reset-command']")); - new WebDriverWait(WebDriverRunner.getWebDriver(), DEFAULT_TIMEOUT) - .until((driver) -> $("a[id$='task-widget:filter-selection-form:filter-name'] > span:nth-child(2)").getText() - .contains("Default")); - } - - public SelenideElement findColumnContainer() { - return $(By.tagName("body")).$(By.cssSelector(".ui-columntoggler")); - } - - public void countSavedFilter(int size) { - waitForElementDisplayed($("a[id$='task-widget:filter-selection-form:filter-name']"), true); - waitForElementClickableThenClick("a[id$='task-widget:filter-selection-form:filter-name']"); - $$(".user-defined-filter-container").shouldBe(CollectionCondition.sizeGreaterThanOrEqual(size), DEFAULT_TIMEOUT); - } -} diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/DefaultChartTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/DefaultChartTest.java deleted file mode 100644 index 1d5570ff092..00000000000 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/DefaultChartTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.axonivy.portal.selenium.test; - -import static com.codeborne.selenide.Selenide.$; - -import java.util.Set; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.axonivy.ivy.webtest.IvyWebTest; -import com.axonivy.portal.selenium.common.BaseTest; -import com.axonivy.portal.selenium.common.TestAccount; -import com.axonivy.portal.selenium.page.MainMenuPage; -import com.axonivy.portal.selenium.page.NewDashboardPage; -import com.axonivy.portal.selenium.page.StatisticWidgetPage; - -@IvyWebTest -public class DefaultChartTest extends BaseTest { - - private static final String DEFAULT_CHART = "Tasks by Priority"; - private static final String RESTORE_DEFAULT = "Restore default"; - - @Override - @BeforeEach - public void setup() { - super.setup(); - login(TestAccount.ADMIN_USER); - grantPermissionToCreateChart(); - } - - @AfterEach - public void clear() { - resetLanguageOfCurrentUser(); - } - - @Test - public void testCreateDefaultChart() { - new NewDashboardPage(); - MainMenuPage mainMenuPage = new MainMenuPage(); - StatisticWidgetPage statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - statisticWidgetPage.waitForElementDisplayed(By.id("statistics-widget:widget-container"), true); - Set chartNames = statisticWidgetPage.getAllChartNames(); - assertTrue(chartNames.contains(DEFAULT_CHART)); - assertEquals(RESTORE_DEFAULT, statisticWidgetPage.getRestoreDefaultButtonName()); - } - - @Test - public void testRestoreDefaultChart() { - MainMenuPage mainMenuPage = new MainMenuPage(); - StatisticWidgetPage statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - resizeBrowserTo2kResolution(); - statisticWidgetPage.waitForElementDisplayed(By.id("statistics-widget:widget-container"), true); - statisticWidgetPage.switchCreateMode(); - statisticWidgetPage.createCaseByFinishedTask(); - statisticWidgetPage.backToDashboard(); - statisticWidgetPage.restoreDefaultCharts(); - - WebElement taskByExpiryChartName3 = null; - try { - taskByExpiryChartName3 = - $("[id='statistics-widget:statistic-dashboard-widget:statistic-chart-repeater:2:chart-name']"); - } catch (Exception ex) { - } - - assertEquals(DEFAULT_CHART, statisticWidgetPage.getChartName(0)); - assertEquals(false, taskByExpiryChartName3.isDisplayed()); - } - - private void grantPermissionToCreateChart() { - redirectToRelativeLink(grantPortalPermission); - } -} diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/MenuTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/MenuTest.java index 74280e0f9f9..e5350b8ec6f 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/MenuTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/MenuTest.java @@ -1,19 +1,18 @@ package com.axonivy.portal.selenium.test; import org.junit.jupiter.api.Assertions; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import com.axonivy.ivy.webtest.IvyWebTest; import com.axonivy.portal.selenium.common.BaseTest; import com.axonivy.portal.selenium.common.TestAccount; +import com.axonivy.portal.selenium.common.Variable; +import com.axonivy.portal.selenium.page.CaseWidgetPage; import com.axonivy.portal.selenium.page.MainMenuPage; import com.axonivy.portal.selenium.page.NewDashboardPage; -import com.axonivy.portal.selenium.page.StatisticWidgetPage; import com.axonivy.portal.selenium.page.TaskWidgetPage; import com.axonivy.portal.selenium.page.UserProfilePage; -import com.axonivy.portal.selenium.common.Variable; import ch.ivy.addon.portalkit.enums.PortalVariable; @@ -69,7 +68,7 @@ public void testKeepClosedStateWhenNavigateToAnotherPage() { NewDashboardPage newDashboardPage = new NewDashboardPage(); newDashboardPage.waitPageLoaded(); MainMenuPage mainMenuPage = newDashboardPage.openMainMenu(); - StatisticWidgetPage dashboardPage = mainMenuPage.selectStatisticDashboard(); + CaseWidgetPage dashboardPage = mainMenuPage.openCaseList(); dashboardPage.waitForPageLoad(); dashboardPage.closeMainMenu(); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/StatisticDashboardWidgetTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/StatisticDashboardWidgetTest.java deleted file mode 100644 index 9982f833da4..00000000000 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/StatisticDashboardWidgetTest.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.axonivy.portal.selenium.test; - -import org.apache.commons.lang3.StringUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import com.axonivy.ivy.webtest.IvyWebTest; -import com.axonivy.portal.selenium.common.BaseTest; -import com.axonivy.portal.selenium.common.TestAccount; -import com.axonivy.portal.selenium.page.DashboardModificationPage; -import com.axonivy.portal.selenium.page.NewDashboardDetailsEditPage; -import com.axonivy.portal.selenium.page.NewDashboardPage; -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; - -import ch.ivy.addon.portalkit.enums.PortalVariable; - -@IvyWebTest -public class StatisticDashboardWidgetTest extends BaseTest { - - private static final String CHART_ID = "statistic_1"; - private NewDashboardPage newDashboardPage; - - @Override - @BeforeEach - public void setup() { - super.setup(); - newDashboardPage = new NewDashboardPage(); - } - - @Test - public void testShowChartInfo() { - login(TestAccount.ADMIN_USER); - createJSonFile("dashboard-has-one-chart-example.json", PortalVariable.DASHBOARD.key); - redirectToRelativeLink(createTestingTasksUrl); - var chartWidget = newDashboardPage.selectStatisticWidget(); - var chartName = chartWidget.getChartName(CHART_ID); - assertTrue(StringUtils.equalsIgnoreCase("Tasks by Priority", chartName)); - var infoIcon = chartWidget.getStatisticInfoIconOfChart(CHART_ID); - infoIcon.should(Condition.appear); - chartWidget.openStatisticInfoPanel(CHART_ID); - var chartFilter = chartWidget.countFilterOfStatistic(CHART_ID); - chartFilter.shouldHave(CollectionCondition.sizeGreaterThanOrEqual(4)); - } - - @Test - public void testEditStatisticChart() { - login(TestAccount.ADMIN_USER); - createJSonFile("dashboard-has-one-chart-example.json", PortalVariable.DASHBOARD.key); - NewDashboardDetailsEditPage newDashboardDetailsEditPage = gotoEditPublicDashboardPage(); - var chartWidget = newDashboardDetailsEditPage.selectStatisticWidget(); - chartWidget.getEditIconOfChart(CHART_ID).shouldBe(Condition.visible, Condition.enabled); - var editChartDialog = chartWidget.openEditStatisticWidgetDialog(CHART_ID); - assertTrue(StringUtils.equalsIgnoreCase(editChartDialog, "Edit Widget Configuration")); - chartWidget.clickOnCancelConfiguration(); - } - - private NewDashboardDetailsEditPage gotoEditPublicDashboardPage() { - newDashboardPage.waitForAbsencesGrowlMessageDisplay(); - var configurationPage = newDashboardPage.openDashboardConfigurationPage(); - DashboardModificationPage modificationPage = configurationPage.openEditPublicDashboardsPage(); - return modificationPage.navigateToEditDashboardDetailsByName("Dashboard"); - } - - @Test - public void testShowChartCasesByCategoryInfo() { - login(TestAccount.ADMIN_USER); - createJSonFile("dashboard-has-chart-cases-by-category.json", PortalVariable.DASHBOARD.key); - redirectToRelativeLink(createTestingTasksUrl); - var chartWidget = newDashboardPage.selectStatisticWidget(); - var chartName = chartWidget.getChartName(CHART_ID); - assertTrue(StringUtils.equalsIgnoreCase("Cases by Category", chartName)); - var infoIcon = chartWidget.getStatisticInfoIconOfChart(CHART_ID); - infoIcon.should(Condition.appear); - chartWidget.openStatisticInfoPanel(CHART_ID); - var chartFilter = chartWidget.countFilterOfStatistic(CHART_ID); - chartFilter.shouldHave(CollectionCondition.sizeGreaterThanOrEqual(4)); - } - - @Test - public void testEditCasesByCategoryChart() { - login(TestAccount.ADMIN_USER); - createJSonFile("dashboard-has-chart-cases-by-category.json", PortalVariable.DASHBOARD.key); - redirectToRelativeLink(createTestingTasksUrl); - NewDashboardDetailsEditPage newDashboardDetailsEditPage = gotoEditPublicDashboardPage(); - var chartWidget = newDashboardDetailsEditPage.selectStatisticWidget(); - chartWidget.getEditIconOfChart(CHART_ID).shouldBe(Condition.visible, Condition.enabled); - var editChartDialog = chartWidget.openEditStatisticWidgetDialog(CHART_ID); - assertTrue(StringUtils.equalsIgnoreCase(editChartDialog, "Edit Widget Configuration")); - chartWidget.clickOnCancelConfiguration(); - } -} diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/StatisticWidgetTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/StatisticWidgetTest.java deleted file mode 100644 index 07aa7602b15..00000000000 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/StatisticWidgetTest.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.axonivy.portal.selenium.test; - -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; - -import com.axonivy.ivy.webtest.IvyWebTest; -import com.axonivy.portal.selenium.common.BaseTest; -import com.axonivy.portal.selenium.common.TestAccount; -import com.axonivy.portal.selenium.common.WaitHelper; -import com.axonivy.portal.selenium.page.MainMenuPage; -import com.axonivy.portal.selenium.page.NewDashboardPage; -import com.axonivy.portal.selenium.page.StatisticWidgetPage; -import com.axonivy.portal.selenium.page.UserProfilePage; - -@IvyWebTest -public class StatisticWidgetTest extends BaseTest { - private static final String TASK_BY_PRIORITY_DEFAULT_CHART_NAME = "Tasks by Priority"; - public static final String TASK_BY_PRIORITY_CHART_NAME = "Task by priority chart"; - public static final String CASE_BY_STATE_CHART_NAME = "Case by state chart"; - public static final String TASK_BY_EXPIRY_CHART_NAME = "Task by expiry chart"; - public static final String ELAPSED_TIME_CHART_NAME = "Elapsed time chart"; - public static final String CASE_BY_FINISHED_TASK_CHART_NAME = "Case by finished task chart"; - public static final String CASE_BY_FINISHED_TIME_CHART_NAME = "Case by finished time chart"; - public static final String CASES_BY_CATEGORY_CHART_NAME = "Cases by category chart"; - - private NewDashboardPage newDashboardPage; - private StatisticWidgetPage statisticWidgetPage; - private MainMenuPage mainMenuPage; - - @Override - @BeforeEach - public void setup() { - super.setup(); - redirectToRelativeLink(createTestingTasksUrl); - login(TestAccount.ADMIN_USER); - newDashboardPage = new NewDashboardPage(); - } - - @AfterEach - public void clear() { - resetLanguageOfCurrentUser(); - } - - @Test - public void testNavigateToChartFromMenu() { - grantPermissionToCreateChart(); - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - statisticWidgetPage.waitForElementDisplayed(By.id("statistics-widget:widget-container"), true); - assertTrue(statisticWidgetPage.isFullMode()); - } - - @Test - public void testNavigateToChartWithoutPermissionFromMenu() { - String denyPortalPermissionsURL = "portalKitTestHelper/14DE09882B540AD5/denyPortalPermission.ivp"; - redirectToRelativeLink(denyPortalPermissionsURL); - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - assertEquals(false, statisticWidgetPage.hasCreateChartsLink()); - redirectToRelativeLink(grantPortalPermission); - } - - @Test - public void testCreateCharts() { - grantPermissionToCreateChart(); - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - statisticWidgetPage.waitForElementDisplayed(By.id("statistics-widget:widget-container"), true); - statisticWidgetPage.switchCreateMode(); - - statisticWidgetPage.createTaskByPriorityChart(); - statisticWidgetPage.createTaskByExpiryChart(); - statisticWidgetPage.createCaseByStateChart(); - statisticWidgetPage.createElapsedTimeChart(); - statisticWidgetPage.createCaseByFinishedTask(); - statisticWidgetPage.createCaseByFinishTime(); - statisticWidgetPage.createCasesByCategory(); - - statisticWidgetPage.backToDashboard(); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='0:chart-name-container'] .chart-name").getText() - .equals(TASK_BY_PRIORITY_DEFAULT_CHART_NAME)); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='1:chart-name-container'] .chart-name").getText() - .equals(TASK_BY_PRIORITY_CHART_NAME)); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='2:chart-name-container'] .chart-name").getText() - .equals(TASK_BY_EXPIRY_CHART_NAME)); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='3:chart-name-container'] .chart-name").getText() - .equals(CASE_BY_STATE_CHART_NAME)); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='4:chart-name-container'] .chart-name").getText() - .equals(ELAPSED_TIME_CHART_NAME)); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='5:chart-name-container'] .chart-name").getText() - .equals(CASE_BY_FINISHED_TASK_CHART_NAME)); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='6:chart-name-container'] .chart-name").getText() - .equals(CASE_BY_FINISHED_TIME_CHART_NAME)); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='7:chart-name-container'] .chart-name").getText() - .equals(CASES_BY_CATEGORY_CHART_NAME)); - } - - @Test - public void testBreadCrumb() { - grantPermissionToCreateChart(); - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - statisticWidgetPage.waitForElementDisplayed(By.id("statistics-widget:widget-container"), true); - assertEquals("Statistics", statisticWidgetPage.getTextOfCurrentBreadcrumb()); - - statisticWidgetPage.switchCreateMode(); - assertEquals("Statistics", statisticWidgetPage.getTextOfCurrentBreadcrumb()); - - statisticWidgetPage.goToHomeFromBreadcrumb(); - newDashboardPage = new NewDashboardPage(); - assertEquals(true, newDashboardPage.isDisplayed()); - } - - private void grantPermissionToCreateChart() { - redirectToRelativeLink(grantPortalPermission); - } - - @Test - public void testChartNameMultiLanguage() { - resetLanguageOfCurrentUser(); - grantPermissionToCreateChart(); - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - statisticWidgetPage.waitForElementDisplayed(By.id("statistics-widget:widget-container"), true); - - statisticWidgetPage.switchCreateMode(); - statisticWidgetPage.createTaskByPriorityChartMultiLanguage(); - - statisticWidgetPage.backToDashboard(); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='1:chart-name-container'] .chart-name").getText() - .equals("Task by priority chart English")); - - UserProfilePage userProfilePage = statisticWidgetPage.openMyProfilePage(); - userProfilePage.selectLanguage(3); - newDashboardPage = userProfilePage.save(); - - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - WaitHelper.assertTrueWithWait( - () -> statisticWidgetPage.findElementByCssSelector("div[id$='1:chart-name-container'] .chart-name").getText() - .equals("Task by priority chart German")); - } - -} diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskAnalysisWidgetTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskAnalysisWidgetTest.java deleted file mode 100644 index 5129b83d9bc..00000000000 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskAnalysisWidgetTest.java +++ /dev/null @@ -1,348 +0,0 @@ -package com.axonivy.portal.selenium.test.task; - -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.visible; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; - -import com.axonivy.ivy.webtest.IvyWebTest; -import com.axonivy.portal.selenium.common.BaseTest; -import com.axonivy.portal.selenium.common.TestAccount; -import com.axonivy.portal.selenium.common.Variable; -import com.axonivy.portal.selenium.page.MainMenuPage; -import com.axonivy.portal.selenium.page.NewDashboardPage; -import com.axonivy.portal.selenium.page.StatisticWidgetPage; -import com.axonivy.portal.selenium.page.TaskAnalysisWidgetPage; -import com.codeborne.selenide.CollectionCondition; -import com.codeborne.selenide.Condition; -import com.codeborne.selenide.ElementsCollection; -import com.codeborne.selenide.SelenideElement; - -@IvyWebTest -public class TaskAnalysisWidgetTest extends BaseTest { - - private static final String ENABLE_CASE_OWNER_SETTING = Variable.ENABLE_CASE_OWNER.getKey(); - private NewDashboardPage newDashboardPage; - private StatisticWidgetPage statisticWidgetPage; - private MainMenuPage mainMenuPage; - - @Override - @BeforeEach - public void setup() { - super.setup(); - createTestingTasks(); - createTestData(); - login(TestAccount.ADMIN_USER); - grantPermissionOfPortal(); - newDashboardPage = new NewDashboardPage(); - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - } - - private void grantPermissionOfPortal() { - redirectToRelativeLink(grantPortalPermission); - } - - @Test - public void testBackToStatisticPage() { - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - assertTrue(taskAnalysisWidgetPage.isDisplayed()); - statisticWidgetPage = taskAnalysisWidgetPage.navigateToStatisticPage(); - assertTrue(statisticWidgetPage.isDisplayed()); - } - - @Test - public void testAddAndRemoveColumns() { - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - - taskAnalysisWidgetPage.clickOnColumnToggler(); - - SelenideElement columnContainer = taskAnalysisWidgetPage.findColumnContainer(); - int numberOfCheckboxes = columnContainer.findElements(By.cssSelector(".ui-chkbox-box")).size(); - List unselectedColumnCheckboxes = - columnContainer.$$(By.cssSelector(".ui-chkbox-box:not(.ui-state-active)")); - - unselectedColumnCheckboxes.forEach(elem -> elem.click()); - taskAnalysisWidgetPage.waitPageLoaded(); - - int numberOfColumns = taskAnalysisWidgetPage.findElementById("task-widget:statistic-result-form:task-table_head") - .findElements(By.cssSelector("th[scope='col']:not(.ui-helper-hidden)")).size(); - assertEquals(numberOfColumns, numberOfCheckboxes); - - refreshPage(); - taskAnalysisWidgetPage.waitPageLoaded(); - taskAnalysisWidgetPage.clickOnColumnToggler(); - List selectedColumnCheckboxes = columnContainer - .$$(By.cssSelector(".ui-chkbox-box.ui-state-active")); - - selectedColumnCheckboxes.get(0) - .shouldBe(Condition.and("should be clickable", visible, exist), - DEFAULT_TIMEOUT) - .click(); - selectedColumnCheckboxes.get(1) - .shouldBe(Condition.and("should be clickable", visible, exist), - DEFAULT_TIMEOUT) - .click(); - - taskAnalysisWidgetPage.waitPageLoaded(); - - numberOfColumns = taskAnalysisWidgetPage - .findElementById("task-widget:statistic-result-form:task-table_head") - .$$(By.cssSelector("th[scope='col']:not(.ui-helper-hidden)")) - .shouldBe(CollectionCondition.sizeGreaterThanOrEqual(0)).size(); - - assertEquals(numberOfColumns, selectedColumnCheckboxes.size()); - } - - @Test - public void testApplyTaskFilters() { - String nameKeyword = "request"; - String prioritySeletion = "NORMAL"; - - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - taskAnalysisWidgetPage.openAdvancedTaskFilter("Name", "name"); - taskAnalysisWidgetPage.filterByTaskName(nameKeyword); - - taskAnalysisWidgetPage.openAdvancedTaskFilter("Priority", "priority"); - List selectedPriorities = new ArrayList<>(); - selectedPriorities.add(prioritySeletion); - taskAnalysisWidgetPage.filterByTaskPriority(selectedPriorities); - taskAnalysisWidgetPage.clickApplyFilter(); - - ElementsCollection results = taskAnalysisWidgetPage.getRowsInTaskTable(); - results.shouldHave(CollectionCondition.size(2), DEFAULT_TIMEOUT); - - for (WebElement resultRow : results) { - List resultCells = resultRow.findElements(By.cssSelector("td:not([class='ui-helper-hidden'])")); - assertTrue(resultCells.get(2).getText().toLowerCase().contains(nameKeyword)); - assertTrue(resultCells.get(3).getText().equals(prioritySeletion)); - } - } - - @Test - public void testApplyCaseFilters() { - String keyword = "request"; - String stateSeletion = "In progress"; - - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - taskAnalysisWidgetPage.openAdvancedCaseFilter("State", "state"); - taskAnalysisWidgetPage.openAdvancedCaseFilter("Name", "case-name"); - taskAnalysisWidgetPage.filterByCaseName(keyword); - - List selectedStates = new ArrayList<>(); - selectedStates.add(stateSeletion); - taskAnalysisWidgetPage.filterByCaseState(selectedStates); - taskAnalysisWidgetPage.clickApplyFilter(); - - ElementsCollection results = taskAnalysisWidgetPage.getRowsInTaskTable(); - results.shouldHave(CollectionCondition.size(4), DEFAULT_TIMEOUT); - - for (WebElement resultRow : results) { - List resultCells = resultRow.findElements(By.cssSelector("td:not([class='ui-helper-hidden'])")); - assertTrue(resultCells.get(0).getText().toLowerCase().contains(keyword)); - assertTrue("RUNNING".equals(resultCells.get(1).getText())); - } - } - - @Test - public void testApplyCategoryFilters() { - resizeBrowserTo2kResolution(); - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - - // Task category filter - taskAnalysisWidgetPage.openAdvancedTaskFilter("Category", "task-category"); - taskAnalysisWidgetPage.filterByTaskCategory("Other Leave"); - taskAnalysisWidgetPage.clickApplyFilter(); - ElementsCollection results = taskAnalysisWidgetPage.getRowsInTaskTable(); - results.shouldHave(CollectionCondition.size(2), DEFAULT_TIMEOUT); - - // Case category filter - taskAnalysisWidgetPage.resetFilter(); - taskAnalysisWidgetPage.openAdvancedCaseFilter("Case category", - "case-category"); - taskAnalysisWidgetPage.filterByCaseCategory("Leave Request"); - taskAnalysisWidgetPage.clickApplyFilter(); - - results = taskAnalysisWidgetPage.getRowsInTaskTable(); - results.shouldHave(CollectionCondition.size(4), DEFAULT_TIMEOUT); - } - - @Test - public void testApplyCaseOwnerFilter() { - updatePortalSetting(ENABLE_CASE_OWNER_SETTING, "true"); - redirectToRelativeLink(userIsOwnerUrl); - newDashboardPage = new NewDashboardPage(); - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - taskAnalysisWidgetPage.filterByOwner("Demo"); - taskAnalysisWidgetPage.clickApplyFilter(); - - ElementsCollection results = taskAnalysisWidgetPage.getRowsInTaskTable(); - results.shouldHave(CollectionCondition.size(2), DEFAULT_TIMEOUT); - updatePortalSetting(ENABLE_CASE_OWNER_SETTING, "false"); - } - - @Test - public void testAddCaseOwnerColumn() { - updatePortalSetting(ENABLE_CASE_OWNER_SETTING, "true"); - newDashboardPage = new NewDashboardPage(); - mainMenuPage = newDashboardPage.openMainMenu(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - - taskAnalysisWidgetPage.clickOnColumnToggler(); - - WebElement columnContainer = taskAnalysisWidgetPage.getDriver().findElement(By.tagName("body")) - .findElement(By.cssSelector(".ui-columntoggler")); - List checkboxes = columnContainer.findElements(By.cssSelector("li.ui-columntoggler-item")); - - checkboxes.forEach(elem -> { - if (StringUtils.equals(elem.getText(), "Case Owner")) { - elem.findElement(By.className("ui-chkbox")).click(); - } - }); - updatePortalSetting(ENABLE_CASE_OWNER_SETTING, "false"); - } - - @Test - public void testSavePublicFilterSet() { - String filterSetName = "Filters for annual"; - - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - resizeBrowserTo2kResolution(); - addFilters(taskAnalysisWidgetPage); - taskAnalysisWidgetPage.saveFilterSet(filterSetName, false); - taskAnalysisWidgetPage.countSavedFilter(2); - statisticWidgetPage = taskAnalysisWidgetPage.navigateToStatisticPage(); - TaskAnalysisWidgetPage secondTaskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - boolean isFilterSetloaded = secondTaskAnalysisWidgetPage.loadFilterSet(filterSetName, false); - - // Sometimes ES take longer time to save data... - if (!isFilterSetloaded) { - refreshPage(); - secondTaskAnalysisWidgetPage.loadFilterSet(filterSetName, false); - } - - secondTaskAnalysisWidgetPage.waitForTaskDataChangeToSpecificSize(1); - List resultCells = secondTaskAnalysisWidgetPage.getRowsInTaskTable().get(0) - .findElements(By.cssSelector("td:not([class='ui-helper-hidden'])")); - assertTrue(resultCells.get(0).getText().toLowerCase().contains("request")); - assertTrue("RUNNING".equals(resultCells.get(1).getText())); - assertTrue(resultCells.get(2).getText().toLowerCase().contains("annual")); - } - - @Test - public void testSavePrivateFilterSet() { - String filterSetName = "Filters for annual"; - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - resizeBrowserTo2kResolution(); - addFilters(taskAnalysisWidgetPage); - taskAnalysisWidgetPage.saveFilterSet(filterSetName, true); - taskAnalysisWidgetPage.countSavedFilter(2); - statisticWidgetPage = taskAnalysisWidgetPage.navigateToStatisticPage(); - TaskAnalysisWidgetPage secondTaskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - boolean isFilterSetloaded = secondTaskAnalysisWidgetPage.loadFilterSet(filterSetName, true); - - // Sometimes ES take longer time to save data... - if (!isFilterSetloaded) { - refreshPage(); - secondTaskAnalysisWidgetPage.loadFilterSet(filterSetName, true); - } - - secondTaskAnalysisWidgetPage.waitForTaskDataChangeToSpecificSize(1); - - List resultCells = secondTaskAnalysisWidgetPage.getRowsInTaskTable().get(0) - .findElements(By.cssSelector("td:not([class='ui-helper-hidden'])")); - assertTrue(resultCells.get(0).getText().toLowerCase().contains("request")); - assertTrue("RUNNING".equals(resultCells.get(1).getText())); - assertTrue(resultCells.get(2).getText().toLowerCase().contains("annual")); - } - - private void createTestData() { - redirectToRelativeLink(create12CasesWithCategoryUrl); - } - - private void addFilters(TaskAnalysisWidgetPage taskAnalysisWidgetPage) { - String taskNameKeyword = "annual"; - String taskCategory = "Annual Leave"; - String caseNameKeyword = "request"; - String caseCategory = "Leave Request"; - String caseState = "In progress"; - - taskAnalysisWidgetPage.openAdvancedCaseFilter("State", "state"); - taskAnalysisWidgetPage.openAdvancedTaskFilter("Name", "name"); - taskAnalysisWidgetPage.filterByTaskName(taskNameKeyword); - - taskAnalysisWidgetPage.openAdvancedTaskFilter("Category", "task-category"); - taskAnalysisWidgetPage.filterByTaskCategory(taskCategory); - - taskAnalysisWidgetPage.openAdvancedCaseFilter("Name", "case-name"); - taskAnalysisWidgetPage.filterByCaseName(caseNameKeyword); - - taskAnalysisWidgetPage.openAdvancedCaseFilter("Case category", "case-category"); - taskAnalysisWidgetPage.filterByCaseCategory(caseCategory); - - List selectedStates = new ArrayList<>(); - selectedStates.add(caseState); - taskAnalysisWidgetPage.filterByCaseState(selectedStates); - } - - @Test - public void testDefaultAndResetFilter() { - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - assertTrue(taskAnalysisWidgetPage.getFilterName().contains("Default filter")); - - taskAnalysisWidgetPage.openAdvancedTaskFilter("Name", "name"); - taskAnalysisWidgetPage.filterByTaskName("request"); - assertTrue(taskAnalysisWidgetPage.isResetButtonShown()); - - taskAnalysisWidgetPage.resetFilter(); - assertTrue(taskAnalysisWidgetPage.getFilterName().contains("Default filter")); - } - - @Test - public void testRemoveAndReloadFilter() { - // Task Responsible, Case Creator - String filterSetName = "saveUserFilter"; - - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - taskAnalysisWidgetPage.filterByResponsible("Demo", "Responsible", "responsible"); - taskAnalysisWidgetPage.filterUserInCase("Demo", "Creator", "creator"); - resizeBrowserTo2kResolution(); - taskAnalysisWidgetPage.saveFilterSet(filterSetName, false); - taskAnalysisWidgetPage.countSavedFilter(2); - - MainMenuPage mainMenuPage = new MainMenuPage(); - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - statisticWidgetPage.navigateToTaskAnalysisPage(); - taskAnalysisWidgetPage.loadFilterSet(filterSetName, false); - - taskAnalysisWidgetPage.removeResponsible(); - taskAnalysisWidgetPage.removeUserInFilter(); - - statisticWidgetPage = mainMenuPage.selectStatisticDashboard(); - statisticWidgetPage.navigateToTaskAnalysisPage(); - taskAnalysisWidgetPage.loadFilterSet(filterSetName, false); - - assertTrue(taskAnalysisWidgetPage.getUser("responsible").contains("Demo")); - assertTrue(taskAnalysisWidgetPage.getUser("creator").contains("Demo")); - } - - @Test - public void testTaskFilterForUnavailableActivator() { - TaskAnalysisWidgetPage taskAnalysisWidgetPage = statisticWidgetPage.navigateToTaskAnalysisPage(); - taskAnalysisWidgetPage.openNoActivatorFilter("Missing activator"); - taskAnalysisWidgetPage.filterByUnavailableActivator(); - taskAnalysisWidgetPage.clickApplyFilter(); - ElementsCollection results = taskAnalysisWidgetPage.getRowsInTaskTable(); - results.shouldHave(CollectionCondition.size(2), DEFAULT_TIMEOUT); - } -} diff --git a/AxonIvyPortal/portal/config/variables/Portal/StatisticCharts.json b/AxonIvyPortal/portal/config/variables/Portal/StatisticCharts.json deleted file mode 100644 index cdf9515e0ec..00000000000 --- a/AxonIvyPortal/portal/config/variables/Portal/StatisticCharts.json +++ /dev/null @@ -1,25 +0,0 @@ -[ - { - "id": "0", - "names": [ - { - "locale": "de", - "value": "Aufgaben nach Priorität" - }, - { - "locale": "en", - "value": "Tasks by Priority" - }, - { - "locale": "fr", - "value": "Tãches par priorité" - }, - { - "locale": "es", - "value": "Tareas por prioridad" - } - ], - "type": "TASK_BY_PRIORITY", - "filter": {} - } -] \ No newline at end of file