From c67465658bd002418fb66c9469345ab22183c137 Mon Sep 17 00:00:00 2001 From: Luong Minh Luat <157108501+lmluat-axonivy@users.noreply.github.com> Date: Tue, 27 Aug 2024 17:56:58 +0700 Subject: [PATCH] Bug/ivyportal 17514 fix g UI tests le (#988) * bug/IVYPORTAL-17514-Fix-GUI-tests-LE - Update LanguageSettingTest * bug/IVYPORTAL-17514-Fix-GUI-tests-LE - Update GUI tests * bug/IVYPORTAL-17514-Fix-GUI-tests-LE - add headless false * bug/IVYPORTAL-17514-Fix-GUI-tests-LE - Update label * bug/IVYPORTAL-17514-Fix-GUI-tests-LE - Remove unused code * bug/IVYPORTAL-17514-Fix-GUI-tests-LE - Update GUI tests * Revert "bug/IVYPORTAL-17514-Fix-GUI-tests-LE" This reverts commit 6ae376c8e77845fedb523b9a70189cc087b7d854. * Revert "bug/IVYPORTAL-17514-Fix-GUI-tests-LE" This reverts commit db7e4588f83ec255de094af0f5aac98a4497c8b8. * bug/IVYPORTAL-17514-Fix-GUI-tests-LE - Grant permission for admin user * bug/IVYPORTAL-17514-Fix-GUI-tests-LE - Format code --- .../com/axonivy/portal/selenium/common/BaseTest.java | 9 +++++++++ .../axonivy/portal/selenium/test/AnnouncementTest.java | 7 +++++++ .../portal/selenium/test/LanguageSettingTest.java | 8 ++++++-- .../axonivy/portal/selenium/test/LeaveRequestTest.java | 1 + .../portal/selenium/test/PortalPermissionTest.java | 3 ++- .../axonivy/portal/selenium/test/QuickSearchTest.java | 3 +-- .../portal/selenium/test/task/TaskActionTest.java | 5 +++++ .../portal/selenium/test/task/TaskDetailsTest.java | 1 + .../portal/selenium/test/task/TaskWidgetTest.java | 3 +++ 9 files changed, 35 insertions(+), 5 deletions(-) diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/BaseTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/BaseTest.java index dbc447954a1..12cf9c1bb98 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/BaseTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/common/BaseTest.java @@ -17,6 +17,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import com.axonivy.ivy.webtest.engine.EngineUrl; +import com.axonivy.portal.selenium.page.NewDashboardPage; +import com.axonivy.portal.selenium.page.UserProfilePage; import com.codeborne.selenide.Condition; import com.codeborne.selenide.WebDriverRunner; @@ -344,6 +346,13 @@ public void createJSonFile(String jsonFile, String key) { } redirectToRelativeLink(String.format(createJSonFileUrl, filepath, key)); } + + public void resetFormattingLanguage() { + NewDashboardPage newDashboardPage = new NewDashboardPage(); + UserProfilePage userProfilePage = newDashboardPage.openMyProfilePage(); + userProfilePage.inputFormattingLanguage("English (United Kingdom)"); + newDashboardPage = userProfilePage.save(); + } protected void showNewDashboard() { redirectToRelativeLink(PORTAL_HOME_PAGE_URL); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/AnnouncementTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/AnnouncementTest.java index e6d401a2db3..c61402c87d4 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/AnnouncementTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/AnnouncementTest.java @@ -1,5 +1,7 @@ package com.axonivy.portal.selenium.test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -81,4 +83,9 @@ public void testDepulishNotification() { announcementPage.dePublish(); assertTrue(newDashboardPage.isAnnouncementMessageNotDisplayed()); } + + @AfterEach + public void resetDefaultFormattingLanguage() { + resetFormattingLanguage(); + } } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/LanguageSettingTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/LanguageSettingTest.java index 47fa32fa963..ffe74d1303f 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/LanguageSettingTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/LanguageSettingTest.java @@ -1,5 +1,6 @@ package com.axonivy.portal.selenium.test; +import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -45,7 +46,6 @@ public void testChangeLanguage() { assertEquals("Prozesse", mainMenuPage.getProcessMenuItemText()); userProfilePage = newDashboardPage.openMyProfilePage(); userProfilePage.selectLanguage(1); - userProfilePage.inputFormattingLanguage("English"); userProfilePage.save(); mainMenuPage = userProfilePage.openMainMenu(); mainMenuPage.waitPageLoaded(); @@ -55,5 +55,9 @@ public void testChangeLanguage() { private void createTestData() { redirectToRelativeLink(createTestingTasksUrl); } - + + @AfterEach + public void resetDefaultFormattingLanguage() { + resetFormattingLanguage(); + } } diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/LeaveRequestTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/LeaveRequestTest.java index f372f14e17a..7025963016a 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/LeaveRequestTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/LeaveRequestTest.java @@ -2,6 +2,7 @@ import java.time.LocalDateTime; + import java.time.format.DateTimeFormatter; import java.util.Locale; diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/PortalPermissionTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/PortalPermissionTest.java index 8054c3d8b6f..5643b03f749 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/PortalPermissionTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/PortalPermissionTest.java @@ -36,7 +36,8 @@ public void setup() { grantAccessFullListPermissions(); newDashboardPage = new NewDashboardPage(); } - + + @Override @AfterEach public void tearDown() { grantTaskActionsPermissions(); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/QuickSearchTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/QuickSearchTest.java index c538c60147b..6a109b185b3 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/QuickSearchTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/QuickSearchTest.java @@ -389,9 +389,8 @@ public void testQuickSearchInProcessWidget() { @Test public void testSessionCacheInProcessWidget() { login(TestAccount.ADMIN_USER); - ProcessWidgetNewDashBoardPage processWidget = newDashboardPage.selectProcessWidget("Your Processes"); - assertTrue(processWidget.isQuickSearchInputShow()); ScreenshotUtils.maximizeBrowser(); + ProcessWidgetNewDashBoardPage processWidget = newDashboardPage.selectProcessWidget("Your Processes"); processWidget.setQuickSearchKeyword("login"); var configurationPage = newDashboardPage.openDashboardConfigurationPage(); DashboardModificationPage modificationPage = configurationPage.openEditPublicDashboardsPage(); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskActionTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskActionTest.java index 6f39d5bc5ae..eda5b354a50 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskActionTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskActionTest.java @@ -18,6 +18,8 @@ import com.axonivy.portal.selenium.page.TaskIFrameTemplatePage; import com.axonivy.portal.selenium.page.TaskWidgetPage; +import ch.ivy.addon.portalkit.enums.PortalPermission; + @IvyWebTest public class TaskActionTest extends BaseTest { @@ -90,6 +92,7 @@ public void testVisibilityTaskActionForNormalUser() { @Test public void testVisibilityTaskActionForAdminUser() { login(TestAccount.ADMIN_USER); + grantSpecificPortalPermission(PortalPermission.SYSTEM_TASK_READ_ALL); redirectToRelativeLink(createTaskWithSystemState); taskWidgetPage = NavigationHelper.navigateToTaskList(); // Ready for Join @@ -134,6 +137,7 @@ public void testVisibilityTaskActionForAdminUser() { @Test public void testVisibleTaskActionsWhenTaskStatusIsDoneAndDestroyed() { login(TestAccount.ADMIN_USER); + grantSpecificPortalPermission(PortalPermission.SYSTEM_TASK_READ_ALL); redirectToRelativeLink(createTaskWithSystemState); taskWidgetPage = NavigationHelper.navigateToTaskList(); @@ -162,6 +166,7 @@ public void testVisibleTaskActionsWhenTaskStatusIsDoneAndDestroyed() { @Test public void testVisibilityTaskActionForTechnicalStates() { login(TestAccount.ADMIN_USER); + grantSpecificPortalPermission(PortalPermission.SYSTEM_TASK_READ_ALL); redirectToRelativeLink(createTechnicalStateUrl); taskWidgetPage = NavigationHelper.navigateToTaskList(); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskDetailsTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskDetailsTest.java index 34d01f6d0b7..951810d7893 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskDetailsTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskDetailsTest.java @@ -105,6 +105,7 @@ public void testShareTaskDetails() { public void testShowTaskStatusBannerOnTaskDetails() { redirectToRelativeLink(createTestingTasksUrl); login(TestAccount.ADMIN_USER); + grantSpecificPortalPermission(PortalPermission.SYSTEM_TASK_READ_ALL); redirectToNewDashBoard(); MainMenuPage mainMenuPage = new MainMenuPage(); mainMenuPage.openTaskList(); diff --git a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskWidgetTest.java b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskWidgetTest.java index 74a9b76ce2e..5a7c267e133 100644 --- a/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskWidgetTest.java +++ b/AxonIvyPortal/portal-selenium-test/src_test/com/axonivy/portal/selenium/test/task/TaskWidgetTest.java @@ -21,6 +21,8 @@ import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; +import ch.ivy.addon.portalkit.enums.PortalPermission; + @IvyWebTest public class TaskWidgetTest extends BaseTest { @@ -113,6 +115,7 @@ public void testDisplayDelegateButton() { @Test public void testDestroyTask() { login(TestAccount.ADMIN_USER); + grantSpecificPortalPermission(PortalPermission.SYSTEM_TASK_READ_ALL); redirectToRelativeLink(GRANT_DESTROY_TASK_URL); TaskWidgetPage taskWidgetPage = NavigationHelper.navigateToTaskList();