Skip to content

Commit

Permalink
IVYPORTAL-16400 Customize global growl message doesn't work (#945)
Browse files Browse the repository at this point in the history
* Deprecated API, removed doc

* Added GUI Tests
  • Loading branch information
lttung-axonivy authored Aug 21, 2024
1 parent 1908ac1 commit a60ef75
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 336 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

import ch.ivyteam.ivy.environment.Ivy;

/**
* @deprecated Customizing growl message feature is deprecated and will not be supported in the future
*/
@Deprecated(forRemoval = true, since = "10.0.24")
public class PortalGlobalGrowInIFrameAPI {

public PortalGlobalGrowInIFrameAPI() {}
Expand All @@ -14,7 +18,9 @@ public PortalGlobalGrowInIFrameAPI() {}
* Displays Portal Growl customized message.
*
* @param message
* @deprecated Customizing growl message feature is deprecated and will not be supported in the future
*/
@Deprecated(forRemoval = true, since = "10.0.24")
public void displayCustomizedMessage(String message) {
String statement = "parent.displayPortalGrowlMessageCommand([{name: 'taskId', value: " + Ivy.wfTask().getId()
+ "},{name: 'overridePortalGrowl', value: true},{name: 'portalGrowlMessage', value: '"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.axonivy.portal.selenium.page;

import static com.codeborne.selenide.Selenide.$;

import org.openqa.selenium.By;

public class GlobalGrowlIframeTemplatePage extends TemplatePage {

@Override
protected String getLoadedLocator() {
return "#content";
}

public TaskWidgetPage clickCancel() {
return clickButton("content-form:cancel");
}

public TaskWidgetPage clickProceed() {
return clickButton("content-form:proceed");
}

private TaskWidgetPage clickButton(String idSelector) {
waitForElementDisplayed(By.id(idSelector), true);
$("button[id='" + idSelector + "']").click();
switchToDefaultContent();
return new TaskWidgetPage();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.axonivy.portal.selenium.common.WaitHelper;
import com.axonivy.portal.selenium.page.ExpressFormDefinitionPage;
import com.axonivy.portal.selenium.page.ExpressProcessPage;
import com.axonivy.portal.selenium.page.GlobalGrowlIframeTemplatePage;
import com.axonivy.portal.selenium.page.MainMenuPage;
import com.axonivy.portal.selenium.page.NewDashboardPage;
import com.axonivy.portal.selenium.page.SearchResultPage;
Expand All @@ -40,13 +41,8 @@ public class GlobalGrowlTest extends BaseTest {
"You have cancelled and left the task successfully. You can find the task in the dashboard or your task list.";
private static final String CANCEL_MESSAGE_WITH_DETAILS =
"You have cancelled and left the task successfully. You can find the task in the dashboard or your task list.\nClick here for details.";
private static final String CUSTOM_FINISH_MESSAGE = "Task is done successfully\nClick here for details.";
private static final String CUSTOM_CANCEL_MESSAGE =
"You have cancelled and left the task successfully\nClick here for details.";
private static final String CUSTOM_GROWL_URL =
"portal-developer-examples/16A7BB2ADC9580A8/frame8CustomizedMessage.ivp";
private static final String SKIP_TASK_LIST_URL =
"portal-developer-examples/16A7BB2ADC9580A8/frame8StandardMessageAndSkipTasklist.ivp";
private static final String GROWL_STANDARD_MESSAGE_URL =
"portal-developer-examples/16A7BB2ADC9580A8/frameStandardMessage.ivp";

@Override
@BeforeEach
Expand All @@ -55,20 +51,8 @@ public void setup() {
login(TestAccount.ADMIN_USER);
}

// TODO Write test for Growl in IFrame, in version 10 it has the test public void
// This test is ignored cause by this bug: https://1ivy.atlassian.net/browse/IVYPORTAL-16400
// @Test
public void testDisplayCustomGrowlAfterFinishTask() {
redirectToRelativeLink(CUSTOM_GROWL_URL);
TaskWidgetPage taskWidgetPage = NavigationHelper.navigateToTaskList();
TaskIFrameTemplatePage taskTemplatePage = taskWidgetPage.startTaskIFrame(0);
taskTemplatePage.clickSubmitButtonProceed();
taskTemplatePage.switchBackToParent();
assertGrowlMessage(taskWidgetPage, CUSTOM_FINISH_MESSAGE);
}

@Test
public void testDisplayDefaultGrowlAfterFinishTask() {
public void testDisplayDefaultGrowlAfterFinishTaskWithoutIFrame() {
redirectToRelativeLink(createTestingTasksUrl);
TaskWidgetPage taskWidgetPage = NavigationHelper.navigateToTaskList();
TaskIFrameTemplatePage taskTemplatePage = taskWidgetPage.startTaskIFrame(0);
Expand All @@ -80,57 +64,43 @@ public void testDisplayDefaultGrowlAfterFinishTask() {
assertGrowlMessage(taskWidgetPage, FINISH_MESSAGE_WITH_DETAILS);
}

// TODO Write test for Growl in IFrame, in version 10 it has the test public void
// This test is ignored cause by this bug: https://1ivy.atlassian.net/browse/IVYPORTAL-16400
// @Test
public void testDisplayDefaultGrowlAfterFinishFirstTask() {
redirectToRelativeLink(SKIP_TASK_LIST_URL);
@Test
public void testDisplayDefaultGrowlAfterFinishTaskWithIFrame() {
redirectToRelativeLink(GROWL_STANDARD_MESSAGE_URL);
TaskWidgetPage taskWidgetPage = NavigationHelper.navigateToTaskList();
TaskIFrameTemplatePage taskTemplatePage = taskWidgetPage.startTaskIFrame(0);
taskTemplatePage.clickSubmitButtonProceed();
taskTemplatePage.switchBackToParent();
TaskWidgetPage homePage = new TaskWidgetPage();
assertGrowlMessage(homePage, FINISH_MESSAGE_WITH_DETAILS);
taskWidgetPage.filterTasksInExpandedModeBy("Growl Standard Message", 1);
taskWidgetPage.startTaskIFrame(0);
GlobalGrowlIframeTemplatePage taskPage = new GlobalGrowlIframeTemplatePage();
taskWidgetPage = taskPage.clickProceed();
assertGrowlMessage(taskWidgetPage, FINISH_MESSAGE_WITH_DETAILS);
}

@Test
public void testDisplayDefaultGrowlAfterCancelTask() {
public void testDisplayDefaultGrowlAfterCancelTaskWithoutIFrame() {
redirectToRelativeLink(createTestingTasksUrl);
NewDashboardPage newDashboardPage = new NewDashboardPage();
TaskWidgetPage taskWidgetPage = newDashboardPage.openTaskList();
taskWidgetPage.waitForPageLoad();
TaskIFrameTemplatePage taskTemplatePage = taskWidgetPage.startTaskIFrame(0);
taskTemplatePage.waitForIFrameContentVisible();

taskTemplatePage.clickOnCancelButton();
taskTemplatePage.switchBackToParent();

assertGrowlMessage(taskWidgetPage, CANCEL_MESSAGE_WITH_DETAILS);
}

// TODO Write test for Growl in IFrame, in version 10 it has the test public void
// This test is ignored cause by this bug: https://1ivy.atlassian.net/browse/IVYPORTAL-16400
// @Test
public void testDisplayCustomGrowlAfterCancelTask() {
redirectToRelativeLink(CUSTOM_GROWL_URL);
@Test
public void testDisplayDefaultGrowlAfterCancelTaskWithIFrame() {
redirectToRelativeLink(GROWL_STANDARD_MESSAGE_URL);
TaskWidgetPage taskWidgetPage = NavigationHelper.navigateToTaskList();
TaskIFrameTemplatePage taskTemplatePage = taskWidgetPage.startTaskIFrame(0);
taskTemplatePage.clickCancelAndLeftButton();//
taskTemplatePage.switchBackToParent();
taskWidgetPage = new TaskWidgetPage();
assertGrowlMessage(taskWidgetPage, CUSTOM_CANCEL_MESSAGE);
}

// TODO Write test for Growl in IFrame, in version 10 it has the test public void
// This test is ignored cause by this bug: https://1ivy.atlassian.net/browse/IVYPORTAL-16400
// @Test
public void testDisplayDefaultGrowlAfterCancelFirstTask() {
redirectToRelativeLink(SKIP_TASK_LIST_URL);
TaskIFrameTemplatePage taskTemplatePage = new TaskIFrameTemplatePage();
taskTemplatePage.switchToIFrameOfTask();
taskTemplatePage.clickCancelAndLeftButton();
taskTemplatePage = new TaskIFrameTemplatePage();
assertGrowlMessage(taskTemplatePage, CANCEL_MESSAGE_WITH_DETAILS);
taskWidgetPage.filterTasksInExpandedModeBy("Growl Standard Message", 1);
taskWidgetPage.startTaskIFrame(0);
GlobalGrowlIframeTemplatePage taskPage = new GlobalGrowlIframeTemplatePage();
taskWidgetPage = taskPage.clickCancel();
assertGrowlMessage(taskWidgetPage, CANCEL_MESSAGE_WITH_DETAILS);
}

public void waitForTemplateRender() {
WaitHelper.waitForPresenceOfElementLocatedInFrame("[class$='task-template-container']");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,6 @@ After the user cancels a task, a growl message is displayed if ``Portal.DisplayM

|example-global-growl-cancelled-task|

Customize the Global Growl Message for a Task using IFrames
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If ``Portal.DisplayMessageAfterFinishTask`` is true, before a task is finished
or cancelled, you can trigger the display of a customized message by calling the
API below:

::

import com.axonivy.portal.components.publicapi.PortalGlobalGrowInIFrameAPI;

PortalGlobalGrowInIFrameAPI api = new PortalGlobalGrowInIFrameAPI();
api.displayCustomizedMessage("Your customized message");

Please refer to GlobalGrowl Start Process in the portal-developer-examples project for details.

.. _components-additional-portal-dialog-with-icon:

Portal Dialog with Icon
Expand Down
Loading

0 comments on commit a60ef75

Please sign in to comment.