Skip to content

Commit

Permalink
IVYPORTAL-18063-bring-back-default-sort-for-task-case-widget-LE (#1301)…
Browse files Browse the repository at this point in the history
… (#1319)

- implement default sort in edit widget
- update GUI tests
- handle multiple ajax call in resizing mode
  • Loading branch information
tphvu-axonivy authored Dec 18, 2024
1 parent eff94d4 commit ef524d1
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,16 @@ public void resizeColumn() {
.clickAndHold(element)
.perform();
}

public void clickOnCaseNameColumn() {
$("div[id$='case-widget-preview:dashboard-cases']").shouldBe(appear, DEFAULT_TIMEOUT)
.$("th[id$='dashboard-cases-columns:1']").shouldBe(getClickableCondition()).click();
}

public SelenideElement getFirstCaseOfCaseWidget() {
$("div[id$='case-widget-preview:dashboard-cases']").shouldBe(appear, DEFAULT_TIMEOUT).$$("table tbody tr").get(0).shouldBe(appear,
DEFAULT_TIMEOUT);
return $("div[id$='case-widget-preview:dashboard-cases']").$$("table tbody tr").get(0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,21 @@ public SelenideElement getExpandModeCheckbox() {
public void clickOnExpandModeCheckbox() {
getExpandModeCheckbox().shouldBe(getClickableCondition(), DEFAULT_TIMEOUT).click();
}

public void clickOnTaskNameColumn() {
$("div[id$='task-widget-preview:dashboard-tasks']").shouldBe(appear, DEFAULT_TIMEOUT)
.$("th[id$='dashboard-tasks-columns:3']").shouldBe(getClickableCondition()).click();
}

public void clickOnTaskPriorityColumn() {
$("div[id$='task-widget-preview:dashboard-tasks']").shouldBe(appear, DEFAULT_TIMEOUT)
.$("th[id$='dashboard-tasks-columns:1']").shouldBe(getClickableCondition()).click();
}

public SelenideElement getFirstTaskOfTaskWidget() {
$("div[id$='task-widget-preview:dashboard-tasks']").shouldBe(appear, DEFAULT_TIMEOUT).$$("table tbody tr").get(0).shouldBe(appear,
DEFAULT_TIMEOUT);
return $("div[id$='task-widget-preview:dashboard-tasks']").$$("table tbody tr").get(0);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.axonivy.portal.selenium.test.dashboard;

import static com.codeborne.selenide.Condition.text;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.Dimension;
Expand All @@ -12,13 +14,18 @@
import com.axonivy.portal.selenium.common.ScreenshotUtils;
import com.axonivy.portal.selenium.common.TestAccount;
import com.axonivy.portal.selenium.page.CaseEditWidgetNewDashBoardPage;
import com.axonivy.portal.selenium.page.CaseWidgetNewDashBoardPage;
import com.axonivy.portal.selenium.page.DashboardConfigurationPage;
import com.axonivy.portal.selenium.page.NewDashboardDetailsEditPage;
import com.codeborne.selenide.CollectionCondition;

@IvyWebTest
public class DashboardEditCaseWidgetTest extends BaseTest {
private static final String NAME_STR = "Name";
private static final String YOUR_CASES_WIDGET = "Your Cases";

private static final String ALPHA_COMPANY = "Alpha Company";
private static final String ORDER_PIZZA = " Order Pizza";

@Override
@BeforeEach
Expand Down Expand Up @@ -201,4 +208,24 @@ private NewDashboardDetailsEditPage gotoEditPublicDashboardPage() {
return modificationPage.navigateToEditDashboardDetailsByName("Dashboard");
}

@Test
public void testDefaultSortOnCaseWidget() {
redirectToRelativeLink(createCaseWithTechnicalCaseUrl);
redirectToRelativeLink(createAlphaCompanyUrl);

LinkNavigator.redirectToPortalDashboardConfiguration();
var configurationPage = new DashboardConfigurationPage();
var modificationPage = configurationPage.openEditPublicDashboardsPage();
modificationPage.navigateToEditDashboardDetailsByName("Dashboard");

CaseWidgetNewDashBoardPage caseWidget = new CaseWidgetNewDashBoardPage(YOUR_CASES_WIDGET);
CaseEditWidgetNewDashBoardPage caseEditWidgetPage = caseWidget.openEditWidget();

caseEditWidgetPage.clickOnCaseNameColumn();
caseEditWidgetPage.getFirstCaseOfCaseWidget().shouldHave(text(ALPHA_COMPANY), DEFAULT_TIMEOUT);;

caseEditWidgetPage.clickOnCaseNameColumn();
caseEditWidgetPage.getFirstCaseOfCaseWidget().shouldHave(text(ORDER_PIZZA), DEFAULT_TIMEOUT);;

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.axonivy.portal.selenium.test.dashboard;

import static com.codeborne.selenide.Condition.text;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -12,10 +14,15 @@
import com.axonivy.portal.selenium.page.DashboardConfigurationPage;
import com.axonivy.portal.selenium.page.NewDashboardDetailsEditPage;
import com.axonivy.portal.selenium.page.TaskEditWidgetNewDashBoardPage;
import com.axonivy.portal.selenium.page.TaskWidgetNewDashBoardPage;
import com.codeborne.selenide.CollectionCondition;

@IvyWebTest
public class DashboardEditTaskWidgetTest extends BaseTest {
private static final String YOUR_TASKS_WIDGET = "Your Tasks";
private static final String MATERNITY_LEAVE_REQUEST = "Maternity Leave Request";
private static final String SICK_LEAVE_REQUEST = "Sick Leave Request";

private NewDashboardDetailsEditPage newDashboardDetailsEditPage;

@Override
Expand Down Expand Up @@ -165,4 +172,26 @@ public void testFilterResponsible() {
taskWidget.applyFilter();
taskWidget.countAllTasks().shouldHave(CollectionCondition.size(0));
}

@Test
public void testDefaultSortOnTaskWidget() {
LinkNavigator.redirectToPortalDashboardConfiguration();
var configurationPage = new DashboardConfigurationPage();
var modificationPage = configurationPage.openEditPublicDashboardsPage();
modificationPage.navigateToEditDashboardDetailsByName("Dashboard");

TaskWidgetNewDashBoardPage taskWidget = new TaskWidgetNewDashBoardPage(YOUR_TASKS_WIDGET);
TaskEditWidgetNewDashBoardPage taskEditWidgetPage = taskWidget.openEditTaskWidget();

// sort by task priority
taskEditWidgetPage.clickOnTaskPriorityColumn();
taskEditWidgetPage.getFirstTaskOfTaskWidget();
taskEditWidgetPage.getFirstTaskOfTaskWidget().shouldHave(text(SICK_LEAVE_REQUEST), DEFAULT_TIMEOUT);

// sort by task name
taskEditWidgetPage.clickOnTaskNameColumn();
taskEditWidgetPage.getFirstTaskOfTaskWidget();
taskEditWidgetPage.getFirstTaskOfTaskWidget().shouldHave(text(MATERNITY_LEAVE_REQUEST), DEFAULT_TIMEOUT);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<p:dataTable id="dashboard-cases" widgetVar="#{cc.attrs.caseWidgetVar}-#{caseWidget.id}" value="#{caseWidget.dataModel}" var="caseItem"
lazy="true" scrollRows="25"
liveScroll="true" scrollable="true" sortBy="#{(isResizing or isPreviewMode) ? null : caseWidget.sortBy}"
liveScroll="true" scrollable="true" sortBy="#{isResizing ? null : caseWidget.sortBy}"
showGridlines="#{isResizing}" resizableColumns="#{isResizing}" resizeMode="expand"
rowIndexVar="rowIndex" rowHover="#{isReadOnlyMode}" selectionMode="single"
styleClass="dashboard-cases--table #{isReadOnlyMode ? '' : 'dashboard__table--edit'} #{isPreviewMode ? 'dashboard__table--preview' : ''} #{!isPreviewMode and caseWidget.caseCount lt 1 ? 'u-display-none' : ''} #{isResizing ? 'js-resizing' : ''}"
Expand All @@ -63,10 +63,10 @@
<p:ajax event="colResize" process="dashboard-cases" global="false" partialSubmit="true"
listener="#{dashboardDetailModificationBean.onResizeColumn}" disabled="#{!isResizing}" />
<f:attribute name="widgetId" value="#{caseWidget.id}" />
<p:ajax event="sort" update="dashboard-cases" onstart="liveScroll()" />
<p:ajax event="sort" update="dashboard-cases" onstart="liveScroll()" disabled="#{isResizing}" />

<p:columns id="dashboard-cases-columns" var="column" value="#{caseWidget.columns}" styleClass="#{column.styleClass} #{(column.field eq 'name' or column.field eq 'actions' ) ? 'dashboard-cases__column-small-screen' : 'u-hidden-sm-down'} widget-column-header"
visible="#{column.visible}" field="#{column.field}" filterable="false" sortBy="#{column.field}" sortable="#{!isResizing and !isPreviewMode and column.sortable}"
visible="#{column.visible}" field="#{column.field}" filterable="false" sortBy="#{column.field}" sortable="#{(isPreviewMode or isReadOnlyMode) and column.sortable}"
style="#{column.isCustomAction or column.format eq 'TIMESTAMP' or column.format eq 'NUMBER' ? 'text-align: center;' : ''} #{column.styleToDisplay}">

<f:facet name="header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<c:set var="isPreviewMode" value="#{cc.attrs.isPreviewMode}" />
<c:set var="isResizing" value="#{!cc.attrs.isReadOnlyMode and !cc.attrs.isPreviewMode}" />

<p:remoteCommand id="rcLoadTaskFirstTimeAIResult" rendered="#{cc.attrs.isAIResult}"
<p:remoteCommand id="rcLoadTaskFirstTimeAIResult" rendered="#{cc.attrs.isAIResult}"
autoRun="true" actionListener="#{taskWidget.dataModel.loadFirstTime()}"
update="dashboard-tasks-container" global="false" async="true" process="@this"
oncomplete="loadWidgetFirstTime('js-loading-#{taskWidget.id}', 'js-dashboard-tasks-container-#{taskWidget.id}'); #{cc.attrs.onCompleteLoadWidget};" />
Expand Down Expand Up @@ -52,7 +52,7 @@
<p:dataTable id="dashboard-tasks" widgetVar="#{cc.attrs.taskWidgetVar}-#{taskWidget.id}" value="#{taskWidget.dataModel}" var="task"
lazy="true" scrollRows="25"
disabledSelection="#{isPreviewMode}"
liveScroll="true" scrollable="true" sortBy="#{(isResizing or isPreviewMode) ? null : taskWidget.sortBy}"
liveScroll="true" scrollable="true" sortBy="#{isResizing ? null : taskWidget.sortBy}"
showGridlines="#{isResizing}" resizableColumns="#{isResizing}" resizeMode="expand"
rowIndexVar="rowIndex" rowHover="#{isReadOnlyMode}" selectionMode="single"
styleClass="dashboard-tasks--table #{isReadOnlyMode ? '' : 'dashboard__table--edit'} #{isPreviewMode ? 'dashboard__table--preview' : ''} #{!isPreviewMode and taskWidget.taskCount lt 1 ? 'u-display-none' : ''} #{isResizing ? 'js-resizing' : ''}"
Expand All @@ -62,10 +62,11 @@
<p:ajax event="colResize" process="dashboard-tasks" global="false" partialSubmit="true"
listener="#{dashboardDetailModificationBean.onResizeColumn}" disabled="#{!isResizing}" />
<f:attribute name="widgetId" value="#{taskWidget.id}" />
<p:ajax event="sort" update="dashboard-tasks" onstart="liveScroll()" disabled="#{!isPreviewMode and !isReadOnlyMode}" />

<p:columns id="dashboard-tasks-columns" var="column" value="#{taskWidget.columns}" styleClass="#{column.styleClass} #{(column.field eq 'start' or column.field eq 'name' or column.field eq 'actions') ? '' : 'u-hidden-sm-down'} widget-column-header"
visible="#{column.visible}" field="#{column.field}" filterable="false"
sortBy="#{column.field}" sortable="#{!isResizing and !isPreviewMode and column.sortable}"
sortBy="#{column.field}" sortable="#{(isPreviewMode or isReadOnlyMode) and column.sortable}"
style="#{column.format eq 'TIMESTAMP' or column.format eq 'NUMBER' ? 'text-align: center;' : ''} #{column.styleToDisplay}">

<f:facet name="header">
Expand Down
2 changes: 1 addition & 1 deletion build/document-screenshot-selenide/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '60', artifactNumToKeepStr: '60'))
}

triggers {
cron('0 15 * * *')
}
Expand Down

0 comments on commit ef524d1

Please sign in to comment.