Skip to content

Commit

Permalink
feature/IVYPORTAL-17461-Remove-Full-Task-List-and-Replace-it-with-the…
Browse files Browse the repository at this point in the history
…-Task-Widget-ver5

_ adapt GUI Test
  • Loading branch information
nhthinh-axonivy committed Nov 13, 2024
1 parent 351d199 commit f8eac5e
Show file tree
Hide file tree
Showing 18 changed files with 167 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.axonivy.portal.selenium.common.FileHelper;
import com.codeborne.selenide.Condition;
import com.codeborne.selenide.DragAndDropOptions;
import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.SelenideElement;

public class DashboardConfigurationPage extends TemplatePage {
Expand Down Expand Up @@ -104,7 +103,7 @@ public void createPrivateDashboardFromTemplate(String newName, String icon, Stri
int templateIndex) {
waitForCreateNewDashboardSectionAppear().$("a[id$=':" + templateIndex + ":template']")
.shouldBe(appear, DEFAULT_TIMEOUT).shouldBe(getClickableCondition()).click();
inputCreateDashboardDialog(newName, icon, newDescription, null, false);
inputCreateDashboardDialog(newName, icon, newDescription, null, false, false);
}

public void createPrivateDashboardFromScratch(String newName, String icon, String newDescription) {
Expand All @@ -113,7 +112,7 @@ public void createPrivateDashboardFromScratch(String newName, String icon, Strin
.shouldBe(getClickableCondition()).click();
waitForCreateNewDashboardSectionAppear();
$("a[id$=':create-from-scratch']").shouldBe(Condition.appear, DEFAULT_TIMEOUT).click();
inputCreateDashboardDialog(newName, icon, newDescription, null, false);
inputCreateDashboardDialog(newName, icon, newDescription, null, false, false);
}

private SelenideElement waitForCreateNewDashboardSectionAppear() {
Expand All @@ -122,16 +121,16 @@ private SelenideElement waitForCreateNewDashboardSectionAppear() {
}

public void createPublicDashboardFromScratch(String newName, String icon, String newDescription,
List<String> permissions) {
List<String> permissions, boolean isTopMenu) {
$("a[id$=':create-from-scratch']").shouldBe(getClickableCondition()).click();
inputCreateDashboardDialog(newName, icon, newDescription, permissions, true);
inputCreateDashboardDialog(newName, icon, newDescription, permissions, true, isTopMenu);
}

public void createPublicDashboardFromTemplate(String newName, String icon, String newDescription,
List<String> permissions, int templateIndex) {
waitForCreateNewDashboardSectionAppear().$("a[id$='" + templateIndex + ":template']")
.shouldBe(appear, DEFAULT_TIMEOUT).shouldBe(getClickableCondition()).click();
inputCreateDashboardDialog(newName, icon, newDescription, permissions, true);
inputCreateDashboardDialog(newName, icon, newDescription, permissions, true, false);
}

public SelenideElement openCreateDashboardDialog() {
Expand Down Expand Up @@ -205,7 +204,7 @@ public void reorderPrivateDashboard() {
}

private void inputCreateDashboardDialog(String newName, String icon, String newDescription, List<String> permissions,
boolean isPublicDashboard) {
boolean isPublicDashboard, boolean isTopMenu) {
String creationDetailsDialogSelector = isPublicDashboard ? "div.create-public-dashboard-dialog"
: "div.create-private-dashboard-dialog";
creationDetailsDialogSelector = creationDetailsDialogSelector.concat("[id$=':dashboard-creation-details-dialog']");
Expand Down Expand Up @@ -237,7 +236,9 @@ private void inputCreateDashboardDialog(String newName, String icon, String newD
}
});
}

if (isTopMenu) {
createDashboardDialog.$("div[id$=':main-dashboard-menu-item']").$("div.ui-chkbox-box").click();
}
createDashboardDialog.$("button[id$='dashboard-create-button']").click();
createDashboardDialog.shouldBe(Condition.disappear, DEFAULT_TIMEOUT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import org.openqa.selenium.By;

import com.codeborne.selenide.Condition;

public class GlobalGrowlIframeTemplatePage extends TemplatePage {

@Override
Expand All @@ -21,7 +23,8 @@ public NewDashboardPage clickProceed() {

private NewDashboardPage clickButton(String idSelector) {
waitForElementDisplayed(By.id(idSelector), true);
$("button[id='" + idSelector + "']").click();
$("button[id='" + idSelector + "']").shouldBe(Condition.appear, DEFAULT_TIMEOUT);
clickByJavaScript($("button[id='" + idSelector + "']"));
switchToDefaultContent();
return new NewDashboardPage();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,16 @@ public String getProcessMenuItemText() {
}

public void clickThirdPartyApp() {
waitForElementDisplayed(By.cssSelector("li[class*='thirdparty-menu-item'] > a"), true);
waitForElementDisplayed(By.cssSelector("li[class*='thirdparty-menu-item'] > a > span"), true);
waitForElementClickableThenClick("li[class*='thirdparty-menu-item'] > a");
}

public void clickMainMenuItem(String name) {
WebElement element = driver.findElement(By.xpath(
String.format("//li[contains(@class, 'external-menu-item-main_dashboard') and .//span[text()='%s']]", name)));
element.click();
}

public void assertThirdPartyApp(String url) {
WebDriver driver = getDriver();
WaitHelper.assertTrueWithWait(() -> driver.getWindowHandles().size() > 1);
Expand All @@ -119,6 +125,11 @@ public void assertThirdPartyApp(String url) {
assertEquals(url, driver.getCurrentUrl());
}

public void assertMainMenuItem(String name) {
WebDriver driver = getDriver();
String tilte = String.format("%s - Portal - Axon Ivy", name);
WaitHelper.assertTrueWithWait(() -> tilte.equals(driver.getTitle()));
}

public boolean isProcessesDisplayed() {
return isMenuItemDisplayed("Processes");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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.Condition.text;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.$$;
Expand All @@ -23,7 +24,6 @@ public class TopMenuTaskWidgetPage extends TaskWidgetNewDashBoardPage {

private static final String YOUR_TASKS_WIDGET = "Your Tasks";
private String taskWidgetId;
private String taskWidgetName;

public TopMenuTaskWidgetPage() {
this("div[id$='dashboard-tasks']", YOUR_TASKS_WIDGET);
Expand All @@ -35,7 +35,6 @@ public TopMenuTaskWidgetPage(String taskWidgetName) {

public TopMenuTaskWidgetPage(String taskWidgetId, String taskWidgetName) {
this.taskWidgetId = taskWidgetId;
this.taskWidgetName = taskWidgetName;
}

@Override
Expand All @@ -48,11 +47,12 @@ public TaskTemplatePage startTaskByIndex(int taskIndex) {
return new TaskTemplatePage();
}

public void startTaskByName(String taskName) {
public void startTaskByNameInIFrame(String taskName) {
int taskIndex =
getAllTasksOfTaskWidget().asFixedIterable().stream().map(WebElement::getText).collect(Collectors.toList())
.indexOf(taskName);
startTaskByIndex(taskIndex);
switchToIFrameOfTask();
}

public boolean checkNameOfTaskAt(int taskIndex, String taskName) {
Expand Down Expand Up @@ -115,28 +115,38 @@ public List<String> getActiveTaskActionNames(int index) {

public TaskDetailsPage openTaskDetailsPageByAction(int taskIndex) {
clickOnTaskActionLink(taskIndex);
$$(String.format("div.js-task-side-steps-panel-default_task_list_dashboard_task_1-%d", taskIndex)).filter(appear)
.first().shouldBe(appear, DEFAULT_TIMEOUT).$("div.ui-overlaypanel-content").$$("a[class*='option-item']")
.filter(Condition.not(Condition.cssClass("ui-state-disabled"))).filter(text("Details")).first()
.shouldBe(getClickableCondition()).click();
clickTaskAction(taskIndex, "Details");
return new TaskDetailsPage();
}

@Override
public void reserveTask(int taskIndex) {
clickOnTaskActionLink(taskIndex);
clickTaskAction(taskIndex, "Reserve");
}

private void clickTaskAction(int taskIndex, String actionName) {
$$(String.format("div.js-task-side-steps-panel-default_task_list_dashboard_task_1-%d", taskIndex)).filter(appear)
.first().shouldBe(appear, DEFAULT_TIMEOUT).$("div.ui-overlaypanel-content").$$("a[class*='option-item']")
.filter(Condition.not(Condition.cssClass("ui-state-disabled"))).filter(text("Reserve")).first()
.filter(Condition.not(Condition.cssClass("ui-state-disabled"))).filter(text(actionName)).first()
.shouldBe(getClickableCondition()).click();
}

public void destroyTask(int taskIndex) {
clickOnTaskActionLink(taskIndex);
clickTaskAction(taskIndex, "Destroy");
confirmDestroy();
}

private void confirmDestroy() {
$("div[id$='destroy-task-confirmation-dialog']").shouldBe(appear, DEFAULT_TIMEOUT)
.$("button[id$='confirm-destruction-dashboard-tasks']").shouldBe(getClickableCondition()).click();
$("button[id$='confirm-destruction-dashboard-tasks']").shouldBe(disappear, DEFAULT_TIMEOUT);
}

public void openTaskDelegateDialog(int taskIndex) {
clickOnTaskActionLink(taskIndex);
$$(String.format("div.js-task-side-steps-panel-default_task_list_dashboard_task_1-%d", taskIndex)).filter(appear)
.first().shouldBe(appear, DEFAULT_TIMEOUT).$("div.ui-overlaypanel-content").$$("a[class*='option-item']")
.filter(Condition.not(Condition.cssClass("ui-state-disabled"))).filter(text("Delegate")).first()
.shouldBe(getClickableCondition()).click();;
clickTaskAction(taskIndex, "Delegate");
}

@Override
Expand Down Expand Up @@ -286,4 +296,13 @@ public String getCannotDelegateText() {
public boolean isDelegateListSelectionAvailable() {
return $("div[id$='select-delegate-panel']").shouldBe(Condition.appear, DEFAULT_TIMEOUT).exists();
}

@Override
public void triggerEscalationTask(int taskIndex) {
getActiveTaskActions(taskIndex).filter(text("Trigger Escalation")).first().shouldBe(getClickableCondition())
.click();
$("div[id='escalation-task-confirmation-dialog']").shouldBe(Condition.appear, DEFAULT_TIMEOUT);
$("button[id='confirm-escalation-dashboard-tasks']").shouldBe(Condition.appear, DEFAULT_TIMEOUT)
.shouldBe(getClickableCondition()).click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
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.FilterOperator;
import com.axonivy.portal.selenium.common.FilterValueType;
import com.axonivy.portal.selenium.common.NavigationHelper;
import com.axonivy.portal.selenium.common.TestAccount;
import com.axonivy.portal.selenium.common.Variable;
import com.axonivy.portal.selenium.page.TopMenuTaskWidgetPage;
import com.codeborne.selenide.CollectionCondition;

@IvyWebTest
public class EnhanceVisibilityTasksForMemberOfRoleTest extends BaseTest {


Expand Down Expand Up @@ -96,8 +99,8 @@ public void testVisibilityTaskDone() {
taskWidget.addFilter("state", null);
taskWidget.inputValueOnLatestFilter(FilterValueType.STATE_TYPE, "Done");
taskWidget.applyFilter();
taskWidget.countAllTasks().shouldHave(CollectionCondition.size(0));

int countTasks = taskWidget.countAllTasks().size();
// User Guest
login(TestAccount.GUEST_USER);
NavigationHelper.navigateToTaskList();
Expand All @@ -109,7 +112,7 @@ public void testVisibilityTaskDone() {
taskWidget.addFilter("state", null);
taskWidget.inputValueOnLatestFilter(FilterValueType.STATE_TYPE, "Done");
taskWidget.applyFilter();
assertEquals(countTasks, taskWidget.countAllTasks().size());
taskWidget.countAllTasks().shouldHave(CollectionCondition.size(0));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
import com.axonivy.portal.selenium.common.Variable;
import com.axonivy.portal.selenium.page.CaseDetailsPage;
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.TaskDetailsPage;
import com.axonivy.portal.selenium.page.TaskWidgetNewDashBoardPage;
import com.axonivy.portal.selenium.page.TaskWidgetPage;
import com.axonivy.portal.selenium.page.TopMenuTaskWidgetPage;
import com.codeborne.selenide.Condition;

Expand Down Expand Up @@ -69,21 +67,23 @@ public void testTriggerEscalationTaskOnTaskDetails() {
public void testTriggerEscalationTaskOnTaskList() {
login(TestAccount.ADMIN_USER);
redirectToNewDashBoard();
MainMenuPage mainMenuPage = new MainMenuPage();
mainMenuPage.openTaskList();
TaskWidgetPage taskWidgetPage = new TaskWidgetPage();
taskWidgetPage.filterTasksBy(SICK_LEAVE_REQUEST);
assertTrue(SICK_LEAVE_REQUEST.equals(taskWidgetPage.getFilterTasksByKeyword().attr("value")));
taskWidgetPage.countTasks().shouldHave(size(1));
taskWidgetPage.clickOnTaskActionLink(0);
taskWidgetPage.triggerEscalation();
NavigationHelper.navigateToTaskList();
TopMenuTaskWidgetPage taskWidget = new TopMenuTaskWidgetPage();
taskWidget.openFilterWidget();
taskWidget.addFilter("Name", FilterOperator.IS);
taskWidget.inputValueOnLatestFilter(FilterValueType.TEXT, SICK_LEAVE_REQUEST);
taskWidget.applyFilter();
taskWidget.countAllTasks().shouldHave(size(1));
taskWidget.triggerEscalationTask(0);
// Try to refresh data
refreshPage();
taskWidgetPage = new TaskWidgetPage();
taskWidgetPage.filterTasksBy(SICK_LEAVE_REQUEST_ESCALATED);
assertTrue(SICK_LEAVE_REQUEST_ESCALATED.equalsIgnoreCase(taskWidgetPage.getFilterTasksByKeyword().attr("value")));
taskWidgetPage.countTasks().shouldHave(size(1));
assertTrue("high".equalsIgnoreCase(taskWidgetPage.getPriorityOfTask(0)));
taskWidget = new TopMenuTaskWidgetPage();
taskWidget.openFilterWidget();
taskWidget.addFilter("State", null);
taskWidget.inputValueOnLatestFilter(FilterValueType.STATE_TYPE, "Destroyed");
taskWidget.applyFilter();
taskWidget.countAllTasks().shouldHave(size(1));
assertTrue("Destroyed".equalsIgnoreCase(taskWidget.stateOfFirstTask().text()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.axonivy.portal.selenium.test;

import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -10,6 +13,7 @@
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.NewDashboardDetailsEditPage;
import com.axonivy.portal.selenium.page.NewDashboardPage;
import com.axonivy.portal.selenium.page.UserProfilePage;

Expand Down Expand Up @@ -45,10 +49,42 @@ public void testLoadCustomMenuItems() {

MainMenuPage mainMenuPage = new MainMenuPage();
String expected =
"Dashboard,Processes,Tasks,Cases,User Example Guide,Google,Testing link google,Testing example,A link,B link";
"Dashboard,Processes,Cases,Tasks,User Example Guide,Google,Testing link google,Testing example,A link,B link";
assertEquals(expected, mainMenuPage.getMenuItemsAsString());
}

@Test
public void testAddingDashboardAsTopMenuItem() {
redirectToRelativeLink(NewDashboardPage.PORTAL_HOME_PAGE_URL);
login(TestAccount.ADMIN_USER);
NewDashboardPage newDashboardPage = new NewDashboardPage();
newDashboardPage.waitPageLoaded();
createJSonFile("default-dashboard.json", PortalVariable.DASHBOARD.key);
newDashboardPage.waitForAbsencesGrowlMessageDisplay();
String name = "Dashboard Menu Item";
String icon = "fa-coffee";
String description = "Dashboard Menu Item";
List<String> permissions = new ArrayList<>();
permissions.add("Everybody");
boolean isTopMenu = true;
var configurationPage = newDashboardPage.openDashboardConfigurationPage();
configurationPage.openCreatePublicDashboardMenu();
configurationPage.createPublicDashboardFromScratch(name, icon, description, permissions, isTopMenu);
NewDashboardDetailsEditPage newDashboardDetailsEditPage = new NewDashboardDetailsEditPage();
configurationPage = newDashboardDetailsEditPage.backToConfigurationPage();
newDashboardPage = configurationPage.backToHomePage();
MainMenuPage mainMenuPage = newDashboardPage.openMainMenu();
mainMenuPage.clickMainMenuItem(name);
mainMenuPage.assertMainMenuItem(name);
redirectToNewDashBoard();
mainMenuPage = new MainMenuPage();
String expected =
"Dashboard,Processes,Cases,Tasks," + name
+ ",User Example Guide,Google";
String menuItemAsString = mainMenuPage.getMenuItemsAsString();
assertEquals(expected, menuItemAsString);
}

@Test
public void testKeepOpenStateWhenNavigateToAnotherPage() {
redirectToRelativeLink(NewDashboardPage.PORTAL_HOME_PAGE_URL);
Expand Down
Loading

0 comments on commit f8eac5e

Please sign in to comment.