From cbc69619c0830b75aaed78277b55c0c9957a16c0 Mon Sep 17 00:00:00 2001 From: Tung Le <76459536+lttung-axonivy@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:39:34 +0700 Subject: [PATCH] Feature/ivyportal 18039 write tests for highlighting menu with navigation (#1292) * IVYPORTAL-18039 Write tests for highlighting menu with navigation - Added tests * IVYPORTAL-18039 Write tests for highlighting menu with navigation - Added tests * IVYPORTAL-18039 Write tests for highlighting menu with navigation - Updated tests --- .../resources/testFile/complex-dashboard.json | 927 ++++++++++++++++++ .../portal/selenium/page/MainMenuPage.java | 17 +- .../portal/selenium/page/TaskDetailsPage.java | 6 + .../selenium/test/MenuHighlightTest.java | 171 ++++ 4 files changed, 1117 insertions(+), 4 deletions(-) create mode 100644 AxonIvyPortal/portal-selenium-test/resources/testFile/complex-dashboard.json create mode 100644 AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/MenuHighlightTest.java diff --git a/AxonIvyPortal/portal-selenium-test/resources/testFile/complex-dashboard.json b/AxonIvyPortal/portal-selenium-test/resources/testFile/complex-dashboard.json new file mode 100644 index 00000000000..04cc1133470 --- /dev/null +++ b/AxonIvyPortal/portal-selenium-test/resources/testFile/complex-dashboard.json @@ -0,0 +1,927 @@ +[ + { + "id": "1", + "version": "12.0.0", + "templateId": "default-portal-dashboard-template", + "titles": [ + { + "locale": "en", + "value": "Dashboard" + }, + { + "locale": "fr", + "value": "Tableau de bord" + }, + { + "locale": "de", + "value": "Dashboard" + }, + { + "locale": "es", + "value": "Tablero de mandos" + } + ], + "icon": "si-pie-line-graph", + "widgets": [ + { + "type": "task", + "id": "task_1", + "names": [ + { + "locale": "en", + "value": "Your Tasks" + }, + { + "locale": "de", + "value": "Ihre Aufgaben" + }, + { + "locale": "fr", + "value": "Vos tâches" + }, + { + "locale": "es", + "value": "Sus tareas" + } + ], + "layout": { + "w": 8, + "h": 6, + "x": 0, + "y": 2 + }, + "enableQuickSearch": true, + "columns": [ + { + "field": "start", + "width": "65" + }, + { + "field": "priority", + "width": "65" + }, + { + "field": "id", + "visible": false + }, + { + "field": "name", + "width": "315" + }, + { + "field": "description", + "visible": false + }, + { + "field": "activator", + "width": "120" + }, + { + "field": "state", + "visible": false + }, + { + "field": "startTimestamp", + "visible": false + }, + { + "field": "expiryTimestamp" + }, + { + "field": "category", + "visible": false + }, + { + "field": "actions", + "width": "78" + } + ], + "sortDescending": true, + "sortField": "startTimestamp", + "canWorkOn": true, + "filters": [ + { + "field": "state", + "values": [ + "DONE", + "IN_PROGRESS", + "OPEN" + ], + "operator": "in", + "type": "standard" + } + ] + }, + { + "type": "case", + "id": "case_1", + "names": [ + { + "locale": "en", + "value": "Your Cases" + }, + { + "locale": "de", + "value": "Ihre Vorgänge" + }, + { + "locale": "fr", + "value": "Vos affaires" + }, + { + "locale": "es", + "value": "Sus casos" + } + ], + "layout": { + "w": 9, + "h": 6, + "x": 3, + "y": 8 + }, + "enableQuickSearch": true, + "columns": [ + { + "field": "id", + "width": "60" + }, + { + "field": "name", + "width": "320" + }, + { + "field": "description", + "visible": false + }, + { + "field": "state", + "width": "60" + }, + { + "field": "creator", + "width": "100" + }, + { + "field": "startTimestamp", + "width": "100" + }, + { + "field": "endTimestamp", + "visible": false + }, + { + "field": "category", + "visible": false + }, + { + "field": "actions", + "width": "60" + } + ], + "sortDescending": true, + "sortField": "startTimestamp", + "filters": [ + { + "field": "state", + "values": [ + "OPEN" + ], + "operator": "in", + "type": "standard" + } + ] + }, + { + "type": "compact-process", + "id": "process_1", + "names": [ + { + "locale": "en", + "value": "Your Processes" + }, + { + "locale": "de", + "value": "Ihre Prozesse" + }, + { + "locale": "fr", + "value": "Vos processus" + }, + { + "locale": "es", + "value": "Sus procesos" + } + ], + "layout": { + "w": 4, + "h": 4, + "x": 8, + "y": 4 + } + }, + { + "type": "welcome", + "id": "welcome_1", + "names": [ + { + "locale": "en", + "value": "Your Welcome Widget" + } + ], + "layout": { + "w": 12, + "h": 2, + "x": 0, + "y": 0 + }, + "welcomeTextPosition": "TOP_LEFT", + "welcomeTextSize": "HEADING_3", + "welcomeTextColor": "ffffff", + "welcomeTexts": [ + { + "locale": "en", + "value": ", welcome to the Axon Ivy Portal!" + }, + { + "locale": "fr", + "value": ", bienvenue sur le portail Axon Ivy!" + }, + { + "locale": "de", + "value": ", willkommen im Axon Ivy Portal!" + }, + { + "locale": "es", + "value": ", bienvenido al portal Axon Ivy!" + } + ], + "welcomeImageFit": "COVER", + "greeting": true + }, + { + "type": "client-statistic", + "id": "client_statistic_1", + "layout": { + "w": 2, + "h": 2, + "x": 8, + "y": 2 + }, + "chartId": "10" + }, + { + "type": "client-statistic", + "id": "client_statistic_2", + "layout": { + "w": 2, + "h": 2, + "x": 10, + "y": 2 + }, + "chartId": "11" + }, + { + "type": "client-statistic", + "id": "client_statistic_3", + "layout": { + "w": 3, + "h": 3, + "x": 0, + "y": 11 + }, + "chartId": "7" + }, + { + "type": "client-statistic", + "id": "client_statistic_4", + "layout": { + "w": 3, + "h": 3, + "x": 0, + "y": 8 + }, + "chartId": "3" + }, + { + "type": "client-statistic", + "id": "client_statistic_5", + "layout": { + "w": 3, + "h": 3, + "x": 0, + "y": 14 + }, + "chartId": "5" + }, + { + "type": "client-statistic", + "id": "client_statistic_6", + "layout": { + "w": 9, + "h": 3, + "x": 3, + "y": 14 + }, + "chartId": "4" + } + ], + "permissions": [ + "Everybody" + ] + }, + { + "id": "default-task-list-dashboard", + "version": "12.0.0", + "templateId": "create-from-scratch", + "titles": [ + { + "locale": "en", + "value": "Tasks" + }, + { + "locale": "fr", + "value": "Tâches" + }, + { + "locale": "de", + "value": "Aufgaben" + }, + { + "locale": "es", + "value": "Tareas" + } + ], + "icon": "si-task-list-edit", + "description": "Default Task List Dashboard", + "widgets": [ + { + "type": "task", + "id": "default_task_list_dashboard_task_1", + "names": [ + { + "locale": "en", + "value": "Your Tasks" + }, + { + "locale": "de", + "value": "Ihre Aufgaben" + }, + { + "locale": "fr", + "value": "Vos tâches" + }, + { + "locale": "es", + "value": "Sus tareas" + } + ], + "layout": { + "w": 12, + "h": 8, + "x": 0, + "y": 0 + }, + "enableQuickSearch": true, + "columns": [ + { + "field": "start", + "width": "75" + }, + { + "field": "priority", + "width": "70" + }, + { + "field": "id", + "quickSearch": true, + "width": "90" + }, + { + "field": "name", + "quickSearch": true, + "width": "280" + }, + { + "field": "description", + "quickSearch": true, + "width": "280" + }, + { + "field": "activator", + "width": "120" + }, + { + "field": "state", + "width": "80" + }, + { + "field": "startTimestamp", + "width": "95" + }, + { + "field": "expiryTimestamp", + "width": "95" + }, + { + "field": "category", + "width": "105" + }, + { + "field": "actions", + "width": "95" + } + ], + "canWorkOn": false, + "sortField": "id", + "sortDescending": true + } + ], + "permissions": [ + "Everybody" + ], + "isTopMenu": true + }, + { + "id": "default-case-list-dashboard", + "version": "12.0.0", + "templateId": "create-from-scratch", + "titles": [ + { + "locale": "en", + "value": "Cases" + }, + { + "locale": "fr", + "value": "Dossiers" + }, + { + "locale": "de", + "value": "Vorgänge" + }, + { + "locale": "es", + "value": "Casos" + } + ], + "icon": "si-layout-bullets", + "description": "Default Case List Dashboard", + "widgets": [ + { + "type": "case", + "id": "default_case_list_dashboard_case_1", + "names": [ + { + "locale": "en", + "value": "Your Cases" + }, + { + "locale": "de", + "value": "Ihre Vorgänge" + }, + { + "locale": "fr", + "value": "Vos affaires" + }, + { + "locale": "es", + "value": "Sus casos" + } + ], + "layout": { + "w": 12, + "h": 8, + "x": 0, + "y": 0 + }, + "sortDescending": true, + "sortField": "id", + "enableQuickSearch": true, + "columns": [ + { + "field": "id", + "quickSearch": true, + "width": "80" + }, + { + "field": "name", + "quickSearch": true, + "width": "300" + }, + { + "field": "description", + "quickSearch": true, + "width": "300" + }, + { + "field": "creator", + "width": "120" + }, + { + "field": "startTimestamp", + "width": "95" + }, + { + "field": "endTimestamp", + "width": "95" + }, + { + "field": "state", + "width": "80" + }, + { + "field": "category", + "width": "105" + }, + { + "field": "actions", + "width": "95" + } + ] + } + ], + "permissions": [ + "Everybody" + ], + "isTopMenu": true + }, + { + "id": "main-dashboard-1", + "version": "12.0.0", + "templateId": "create-from-scratch", + "titles": [ + { + "locale": "en", + "value": "Main Dashboard 1" + } + ], + "icon": "si-task-list-edit", + "description": "Main Dashboard 1", + "widgets": [ + { + "type": "task", + "id": "main_dashboard_1_task_1", + "names": [ + { + "locale": "en", + "value": "Your Tasks" + }, + { + "locale": "de", + "value": "Ihre Aufgaben" + }, + { + "locale": "fr", + "value": "Vos tâches" + }, + { + "locale": "es", + "value": "Sus tareas" + } + ], + "layout": { + "w": 12, + "h": 8, + "x": 0, + "y": 0 + }, + "enableQuickSearch": true, + "columns": [ + { + "field": "start", + "width": "75" + }, + { + "field": "priority", + "width": "70" + }, + { + "field": "id", + "quickSearch": true, + "width": "90" + }, + { + "field": "name", + "quickSearch": true, + "width": "280" + }, + { + "field": "description", + "quickSearch": true, + "width": "280" + }, + { + "field": "activator", + "width": "120" + }, + { + "field": "state", + "width": "80" + }, + { + "field": "startTimestamp", + "width": "95" + }, + { + "field": "expiryTimestamp", + "width": "95" + }, + { + "field": "category", + "width": "105" + }, + { + "field": "actions", + "width": "95" + } + ], + "canWorkOn": false, + "sortField": "id", + "sortDescending": true + } + ], + "permissions": [ + "Everybody" + ], + "isTopMenu": true + }, + { + "id": "main-dashboard-2", + "version": "12.0.0", + "templateId": "create-from-scratch", + "titles": [ + { + "locale": "en", + "value": "Main Dashboard 2" + } + ], + "icon": "si-layout-bullets", + "description": "Main Dashboard 2", + "widgets": [ + { + "type": "case", + "id": "main_dashboard_2_case_1", + "names": [ + { + "locale": "en", + "value": "Your Cases" + }, + { + "locale": "de", + "value": "Ihre Vorgänge" + }, + { + "locale": "fr", + "value": "Vos affaires" + }, + { + "locale": "es", + "value": "Sus casos" + } + ], + "layout": { + "w": 12, + "h": 8, + "x": 0, + "y": 0 + }, + "sortDescending": true, + "sortField": "id", + "enableQuickSearch": true, + "columns": [ + { + "field": "id", + "quickSearch": true, + "width": "80" + }, + { + "field": "name", + "quickSearch": true, + "width": "300" + }, + { + "field": "description", + "quickSearch": true, + "width": "300" + }, + { + "field": "creator", + "width": "120" + }, + { + "field": "startTimestamp", + "width": "95" + }, + { + "field": "endTimestamp", + "width": "95" + }, + { + "field": "state", + "width": "80" + }, + { + "field": "category", + "width": "105" + }, + { + "field": "actions", + "width": "95" + } + ] + } + ], + "permissions": [ + "Everybody" + ], + "isTopMenu": true + }, + { + "id": "sub-dashboard-1", + "version": "12.0.0", + "templateId": "create-from-scratch", + "titles": [ + { + "locale": "en", + "value": "Sub Dashboard 1" + } + ], + "icon": "si-task-list-edit", + "description": "Sub Dashboard 1", + "widgets": [ + { + "type": "task", + "id": "sub_dashboard_1_task_1", + "names": [ + { + "locale": "en", + "value": "Your Tasks" + }, + { + "locale": "de", + "value": "Ihre Aufgaben" + }, + { + "locale": "fr", + "value": "Vos tâches" + }, + { + "locale": "es", + "value": "Sus tareas" + } + ], + "layout": { + "w": 12, + "h": 8, + "x": 0, + "y": 0 + }, + "enableQuickSearch": true, + "columns": [ + { + "field": "start", + "width": "75" + }, + { + "field": "priority", + "width": "70" + }, + { + "field": "id", + "quickSearch": true, + "width": "90" + }, + { + "field": "name", + "quickSearch": true, + "width": "280" + }, + { + "field": "description", + "quickSearch": true, + "width": "280" + }, + { + "field": "activator", + "width": "120" + }, + { + "field": "state", + "width": "80" + }, + { + "field": "startTimestamp", + "width": "95" + }, + { + "field": "expiryTimestamp", + "width": "95" + }, + { + "field": "category", + "width": "105" + }, + { + "field": "actions", + "width": "95" + } + ], + "canWorkOn": false, + "sortField": "id", + "sortDescending": true + } + ], + "permissions": [ + "Everybody" + ] + }, + { + "id": "sub-dashboard_2", + "version": "12.0.0", + "templateId": "create-from-scratch", + "titles": [ + { + "locale": "en", + "value": "Sub Dashboard 2" + } + ], + "icon": "si-layout-bullets", + "description": "Sub Dashboard 2", + "widgets": [ + { + "type": "case", + "id": "sub_dashboard_2_case_1", + "names": [ + { + "locale": "en", + "value": "Your Cases" + }, + { + "locale": "de", + "value": "Ihre Vorgänge" + }, + { + "locale": "fr", + "value": "Vos affaires" + }, + { + "locale": "es", + "value": "Sus casos" + } + ], + "layout": { + "w": 12, + "h": 8, + "x": 0, + "y": 0 + }, + "sortDescending": true, + "sortField": "id", + "enableQuickSearch": true, + "columns": [ + { + "field": "id", + "quickSearch": true, + "width": "80" + }, + { + "field": "name", + "quickSearch": true, + "width": "300" + }, + { + "field": "description", + "quickSearch": true, + "width": "300" + }, + { + "field": "creator", + "width": "120" + }, + { + "field": "startTimestamp", + "width": "95" + }, + { + "field": "endTimestamp", + "width": "95" + }, + { + "field": "state", + "width": "80" + }, + { + "field": "category", + "width": "105" + }, + { + "field": "actions", + "width": "95" + } + ] + } + ], + "permissions": [ + "Everybody" + ] + } +] 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 a54d8b4abbd..2873270d8af 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 @@ -145,11 +145,20 @@ public boolean isCasesDisplayed() { return isMenuItemDisplayed("Cases"); } - public WorkingTaskDialogPageOfApplicationMenu selectDashboardMenu() { - waitForElementClickableThenClick(".layout-menu li[role='menuitem'] a.DASHBOARD"); - return new WorkingTaskDialogPageOfApplicationMenu(); + public NewDashboardPage selectDashboardMenu() { + $(By.id("left-menu")).shouldBe(appear, DEFAULT_TIMEOUT).hover().scrollTo(); + WaitHelper.waitForNavigation(() -> $(By.cssSelector("li[id$='dashboard_0-parent-dashboard']")) + .shouldBe(appear, DEFAULT_TIMEOUT).shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click()); + return new NewDashboardPage(); } - + + public TaskWidgetNewDashBoardPage selectTaskMenuItem() { + $(By.id("left-menu")).shouldBe(appear, DEFAULT_TIMEOUT).hover().scrollTo(); + WaitHelper.waitForNavigation(() -> $(By.cssSelector("li[id$='default-task-list-dashboard-main-dashboard']")) + .shouldBe(appear, DEFAULT_TIMEOUT).shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click()); + return new TaskWidgetNewDashBoardPage(); + } + public String getIconClassMainMenuEntryAsString() { return $("div[id='user-menu-required-login']").shouldBe(appear, DEFAULT_TIMEOUT) .$("li[id*='main-menu__js__DASHBOARD-parent-dashboard']").shouldBe(appear, DEFAULT_TIMEOUT) diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskDetailsPage.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskDetailsPage.java index 30860893e9d..c3b9a9e8b1d 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskDetailsPage.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/page/TaskDetailsPage.java @@ -311,6 +311,7 @@ public List getTaskNoteAuthors() { } public void clickBackButton() { + $("[id$=':task-detail-title-form:back-to-previous-page']").scrollIntoView(false); waitForElementClickableThenClick($("[id$=':task-detail-title-form:back-to-previous-page']")); } @@ -331,6 +332,11 @@ public TaskIFrameTemplatePage clickStartTask() { return new TaskIFrameTemplatePage(); } + public CaseDetailsPage clickStartTaskWithoutDialog() { + $("[id$=':task-detail-start-command']").shouldBe(appear).click(); + return new CaseDetailsPage(); + } + public void changePriorityOfTask(int priorityValue) { findElementByCssSelector("[id$=':general-information:priority-form:edit-priority-inplace_display']").click(); waitForElementDisplayed(By.cssSelector("[id$=':general-information:priority-form:priority-select-menu_label']"), diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/MenuHighlightTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/MenuHighlightTest.java new file mode 100644 index 00000000000..54492323090 --- /dev/null +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/MenuHighlightTest.java @@ -0,0 +1,171 @@ +package com.axonivy.portal.selenium.test; + +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 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.NavigationHelper; +import com.axonivy.portal.selenium.common.Variable; +import com.axonivy.portal.selenium.page.CaseDetailsPage; +import com.axonivy.portal.selenium.page.CaseWidgetNewDashBoardPage; +import com.axonivy.portal.selenium.page.MainMenuPage; +import com.axonivy.portal.selenium.page.NewDashboardPage; +import com.axonivy.portal.selenium.page.TaskDetailsPage; +import com.axonivy.portal.selenium.page.TaskIFrameTemplatePage; +import com.axonivy.portal.selenium.page.TopMenuTaskWidgetPage; +import com.axonivy.portal.selenium.page.UserProfilePage; +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; + +import ch.ivy.addon.portalkit.enums.PortalVariable; + +@IvyWebTest +public class MenuHighlightTest extends BaseTest { + + private static final String MAIN_MENU_PROCESS = ".*main-menu_process_1"; + private static final String DASHBOARD_PARENT_DASHBOARD_PATTERN = ".*DASHBOARD-parent-dashboard"; + private static final String DEFAULT_CASE_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN = + ".*default-case-list-dashboard-main-dashboard"; + private static final String DASHBOARD_0_PARENT_DASHBOARD_PATTERN = ".*dashboard_0-parent-dashboard"; + private static final String DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN = + ".*default-task-list-dashboard-main-dashboard"; + + @Override + @BeforeEach + public void setup() { + super.setup(); + updateGlobalVariable(Variable.TASK_BEHAVIOUR_WHEN_CLICKING_ON_LINE_IN_TASK_LIST.getKey(), "ACCESS_TASK_DETAILS"); + createTestingTasks(); + } + + @Test + public void testHighlightDefaultMenus() { + assertMenuHighlighted(DASHBOARD_0_PARENT_DASHBOARD_PATTERN); + MainMenuPage menuPage = new MainMenuPage(); + menuPage.selectProcessesMenu(); + assertMenuHighlighted(MAIN_MENU_PROCESS); + menuPage.selectTaskMenuItem(); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + menuPage.selectCaseMenu(); + assertMenuHighlighted(DEFAULT_CASE_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + menuPage.selectDashboardMenu(); + assertMenuHighlighted(DASHBOARD_0_PARENT_DASHBOARD_PATTERN); + NavigationHelper.navigateToProcessList(); + assertMenuHighlighted(MAIN_MENU_PROCESS); + NavigationHelper.navigateToTaskList(); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + NavigationHelper.navigateToCaseList(); + assertMenuHighlighted(DEFAULT_CASE_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + createJSonFile("complex-dashboard.json", PortalVariable.DASHBOARD.key); + clickLogo(); + assertMenuHighlighted(DASHBOARD_PARENT_DASHBOARD_PATTERN); + $("li[id$='1-sub-dashboard'].active-menuitem").shouldBe(Condition.appear); + } + + @Test + public void testHighlightTaskListWithoutSubDashboards() { + executeHighlightMenuScenario(); + assertMenuHighlighted(DASHBOARD_0_PARENT_DASHBOARD_PATTERN); + } + + @Test + public void testHighlightTaskListWithSubDashboards() { + createJSonFile("complex-dashboard.json", PortalVariable.DASHBOARD.key); + executeHighlightMenuScenario(); + assertMenuHighlighted(DASHBOARD_PARENT_DASHBOARD_PATTERN); + } + + @Test + public void testHighlightCaseList() { + new NewDashboardPage(); + MainMenuPage menuPage = new MainMenuPage(); + CaseWidgetNewDashBoardPage caseListPage = menuPage.selectCaseMenu(); + assertMenuHighlighted(DEFAULT_CASE_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + CaseDetailsPage caseDetailsPage = caseListPage.openDetailsFirstCase(); + assertMenuHighlighted(DEFAULT_CASE_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + caseDetailsPage.clickBackButton(); + caseListPage = new CaseWidgetNewDashBoardPage(); + assertMenuHighlighted(DEFAULT_CASE_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + } + + @Test + public void tesChangingtHomepageInUserProfile() { + NewDashboardPage newDashboardPage = new NewDashboardPage(); + newDashboardPage.waitForCaseWidgetLoaded(); + newDashboardPage.waitForGrowlMessageDisappear(); + + UserProfilePage profilePage = newDashboardPage.openMyProfilePage(); + profilePage.changeNewDashboardPageToCase(); + profilePage.saveWithoutWaitingNavigation(); + new CaseWidgetNewDashBoardPage(); + MainMenuPage menuPage = new MainMenuPage(); + menuPage.selectTaskMenuItem(); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + TopMenuTaskWidgetPage taskWidgetPage = new TopMenuTaskWidgetPage(); + TaskIFrameTemplatePage taskTemplatePage = taskWidgetPage.startTaskIFrameByIndex(0); + getActiveMenuItems().shouldBe(size(0)); + taskTemplatePage.clickOnCancelButton(); + ElementsCollection menuItems = getActiveMenuItems(); + menuItems.shouldBe(size(1)); + redirectToRelativeLink(createAlphaCompanyUrl); + new CaseWidgetNewDashBoardPage(); + assertMenuHighlighted(DEFAULT_CASE_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + menuPage.selectTaskMenuItem(); + $("td.dashboard-tasks__state").shouldBe(Condition.text("Open")); + taskWidgetPage.startTask(0); + $("td.dashboard-tasks__state").shouldBe(Condition.text("Done")); + taskWidgetPage.getTheFirstTaskWidgetByColumn("State").shouldHave(Condition.text("Done")); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + clickLogo(); + assertMenuHighlighted(DEFAULT_CASE_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + } + + private void executeHighlightMenuScenario() { + NavigationHelper.navigateToTaskList(); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + TopMenuTaskWidgetPage taskWidgetPage = new TopMenuTaskWidgetPage(); + TaskIFrameTemplatePage taskTemplatePage = taskWidgetPage.startTaskIFrameByIndex(0); + getActiveMenuItems().shouldBe(size(0)); + taskTemplatePage.clickOnCancelButton(); + ElementsCollection menuItems = getActiveMenuItems(); + menuItems.shouldBe(size(1)); + taskWidgetPage = new TopMenuTaskWidgetPage(); + TaskDetailsPage taskDetailsPage = taskWidgetPage.openDashboardTaskDetails("Categoried Leave Request"); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + taskDetailsPage.gotoBusinessCase(); + CaseDetailsPage caseDetailsPage = new CaseDetailsPage(); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + caseDetailsPage.clickBackButton(); + taskDetailsPage = new TaskDetailsPage(); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + taskDetailsPage.clickBackButton(); + taskWidgetPage = new TopMenuTaskWidgetPage(); + assertMenuHighlighted(DEFAULT_TASK_LIST_DASHBOARD_MAIN_DASHBOARD_PATTERN); + redirectToRelativeLink(createAlphaCompanyUrl); + NavigationHelper.navigateToTaskList(); + taskDetailsPage = taskWidgetPage.openDashboardTaskDetails("Alpha Company"); + taskDetailsPage.clickStartTaskWithoutDialog(); + getActiveMenuItems().shouldBe(size(0)); + clickLogo(); + } + + private void assertMenuHighlighted(String highlightedMenuItemPattern) { + ElementsCollection menuItems = getActiveMenuItems(); + menuItems.shouldBe(size(1)); + menuItems.first().shouldHave(Condition.attributeMatching("id", highlightedMenuItemPattern)); + } + + private ElementsCollection getActiveMenuItems() { + return $$("ul[id$=':main-menu'] > li.active-menuitem").filter(appear); + } + + private void clickLogo() { + $(".sidebar-logo").shouldBe(appear).click(); + } +}