From 38d87f82b5726afe199bd930f9ce018576528f03 Mon Sep 17 00:00:00 2001 From: ChiuchiuSorin Date: Thu, 14 Dec 2023 10:21:36 +0200 Subject: [PATCH] Add functional tests #16 * Modified comments * Modified execution condition * Removed test for application panel as it is currently not working (will create a separate issue to address this) * Code refactoring --- .../pom.xml | 6 ----- .../test/ui/AdminToolsExecutionCondition.java | 15 ++++--------- .../admintools/test/ui/AdminToolsIT.java | 22 +------------------ .../test/po/AdminToolsHomePage.java | 17 -------------- .../po/DashboardConfigurationSectionView.java | 5 +---- .../test/po/DashboardFilesSectionView.java | 10 ++++++--- 6 files changed, 13 insertions(+), 62 deletions(-) diff --git a/application-admintools-test/application-admintools-test-docker/pom.xml b/application-admintools-test/application-admintools-test-docker/pom.xml index 224af0ec..3c4ece91 100644 --- a/application-admintools-test/application-admintools-test-docker/pom.xml +++ b/application-admintools-test/application-admintools-test-docker/pom.xml @@ -105,12 +105,6 @@ ${project.version} test - - org.xwiki.platform - xwiki-platform-panels-test-pageobjects - ${platform.version} - test - src/test/it diff --git a/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsExecutionCondition.java b/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsExecutionCondition.java index d986fbd0..7802498d 100644 --- a/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsExecutionCondition.java +++ b/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsExecutionCondition.java @@ -20,8 +20,6 @@ package com.xwiki.admintools.test.ui; import java.util.List; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.junit.jupiter.api.extension.ConditionEvaluationResult; import org.junit.jupiter.api.extension.ExecutionCondition; @@ -45,16 +43,11 @@ public class AdminToolsExecutionCondition implements ExecutionCondition public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) { if (DockerTestUtils.isInAContainer()) { - List filteredServletEngines = - Stream.of(ServletEngine.values()).filter(engine -> !supportedServers.contains(engine)) - .collect(Collectors.toList()); TestConfiguration configuration = DockerTestUtils.getTestConfiguration(context); - for (ServletEngine servletEngine : filteredServletEngines) { - if (servletEngine.equals(configuration.getServletEngine())) { - return ConditionEvaluationResult.disabled(String.format("Servlet engine [%s] is forbidden " - + "when the PDF export tests are executed inside a Docker container, skipping.", - configuration.getServletEngine())); - } + if (!supportedServers.contains(configuration.getServletEngine())) { + return ConditionEvaluationResult.disabled(String.format("Servlet engine [%s] is forbidden " + + "when the PDF export tests are executed inside a Docker container, skipping.", + configuration.getServletEngine())); } } diff --git a/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsIT.java b/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsIT.java index 36684534..d80a6a10 100644 --- a/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsIT.java +++ b/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsIT.java @@ -22,7 +22,6 @@ import java.util.Arrays; import java.util.List; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Order; @@ -30,11 +29,9 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.xwiki.model.reference.DocumentReference; -import org.xwiki.panels.test.po.ApplicationsPanel; import org.xwiki.test.docker.junit5.TestConfiguration; import org.xwiki.test.docker.junit5.UITest; import org.xwiki.test.ui.TestUtils; -import org.xwiki.test.ui.po.ViewPage; import com.xwiki.admintools.test.po.AdminToolsHomePage; import com.xwiki.admintools.test.po.DashboardConfigurationSectionView; @@ -61,8 +58,6 @@ class AdminToolsIT private static final String PASSWORD = "pass"; - private static boolean isSupportedServer = true; - private final List supportedDatabases = List.of("mysql", "hsql", "hsqldb", "mariadb", "postgresql", "oracle"); @@ -70,16 +65,10 @@ class AdminToolsIT List.of("environment.permanentDirectory", "rendering.linkLabelFormat", "core.defaultDocumentSyntax", "MISC"); @BeforeAll - static void setUp(TestUtils setup, TestConfiguration testConfiguration) + static void setUp(TestUtils setup) { setup.createUser(USER_NAME, PASSWORD, setup.getURLToNonExistentPage(), "first_name", "Jon", "last_name", "Snow"); - String serverType = testConfiguration.getServletEngine().name(); - if (!supportedServers.contains(serverType)) { - isSupportedServer = false; - AdminToolsHomePage adminToolsHomePage = AdminToolsHomePage.gotoPage(); - assertEquals(2, adminToolsHomePage.countWarningMessages()); - } // By default the minimal distribution used for the tests doesn't have any rights setup. Let's create an Admin // user part of the Admin Group and make sure that this Admin Group has admin rights in the wiki. We could also @@ -97,15 +86,6 @@ void goToPage() AdminToolsHomePage.gotoPage(); } - @Test - void appEntryRedirectsToHomePage() - { - ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage(); - ViewPage vp = applicationPanel.clickApplication("Admin Tools"); - Assertions.assertTrue( - AdminToolsHomePage.isCurrentPage(vp)); - } - @Test @Order(1) void adminToolsHomePageBackend(TestConfiguration testConfiguration) diff --git a/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/AdminToolsHomePage.java b/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/AdminToolsHomePage.java index 96726b85..c3752ddb 100644 --- a/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/AdminToolsHomePage.java +++ b/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/AdminToolsHomePage.java @@ -42,15 +42,6 @@ public static AdminToolsHomePage gotoPage() return new AdminToolsHomePage(); } - /** - * Check if the page is the same as Admin Tools WebHome. - */ - public static boolean isCurrentPage(ViewPage vp) - { - return vp.getMetaDataValue("page").equals(ADMIN_TOOLS_PAGE) && vp.getMetaDataValue("space") - .equals(ADMIN_TOOLS_SPACE); - } - /** * Open the dashboard configuration section. */ @@ -68,13 +59,5 @@ public static DashboardFilesSectionView getFilesSection() gotoPage(); return new DashboardFilesSectionView(); } - - /** - * Count the warning messages on the homepage. - */ - public int countWarningMessages() - { - return getDriver().findElements(By.className("warningmessage")).size(); - } } diff --git a/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/DashboardConfigurationSectionView.java b/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/DashboardConfigurationSectionView.java index a2dfb518..8d5b71c1 100644 --- a/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/DashboardConfigurationSectionView.java +++ b/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/DashboardConfigurationSectionView.java @@ -35,15 +35,12 @@ public class DashboardConfigurationSectionView extends ViewPage { private static final String BACKEND_SECTION_VIEW_LAST_LOGS_MODAL_ID = "#configurationViewLastNLinesModal"; - @FindBy(xpath = "//a[@data-target = '#configurationViewLastNLinesModal']") + @FindBy(css = "a[data-target='#configurationViewLastNLinesModal']") public WebElement backendLogsHyperlink; @FindBy(css = ".backend-section") public WebElement backendContent; - @FindBy(css = ".warningmessage") - public List warningElements; - public String getText() { return backendContent.findElement(By.tagName("ul")).getText(); diff --git a/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/DashboardFilesSectionView.java b/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/DashboardFilesSectionView.java index 559fa33b..86aa944f 100644 --- a/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/DashboardFilesSectionView.java +++ b/application-admintools-test/application-admintools-test-pageobjects/src/main/java/com/xwiki/admintools/test/po/DashboardFilesSectionView.java @@ -19,8 +19,6 @@ */ package com.xwiki.admintools.test.po; -import java.util.List; - import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; @@ -40,7 +38,7 @@ public class DashboardFilesSectionView extends ViewPage private WebElement downloadFilesModalHyperlink; /** - * Open the download modal. + * Open the download files archive modal. */ public DownloadArchiveModalView clickDownloadModalHyperlink() { @@ -48,11 +46,17 @@ public DownloadArchiveModalView clickDownloadModalHyperlink() return new DownloadArchiveModalView(By.id("downloadFilesModal")); } + /** + * Navigate and click the link for viewing XWiki properties file. + */ public void clickPropertiesHyperlink() { filesContent.findElement(By.id("filesProperties")).click(); } + /** + * Navigate and click the link for viewing XWiki configuration file. + */ public void clickConfigurationHyperlink() { filesContent.findElement(By.id("filesConfig")).click();