From 14d2bba29cc2eca65c8b01fcea533d4b10f51239 Mon Sep 17 00:00:00 2001 From: ChiuchiuSorin Date: Tue, 7 Nov 2023 18:45:19 +0200 Subject: [PATCH] Add functional tests #16 * Created the test modules and structures --- application-admintools-api/pom.xml | 2 +- application-admintools-default/pom.xml | 2 +- .../pom.xml | 103 +++++++++++ .../admintools/test/ui/AdminToolsIT.java | 42 +++++ .../com/xwiki/admintools/test/ui/AllITs.java | 40 +++++ .../pom.xml | 39 ++++ application-admintools-test/pom.xml | 52 ++++++ application-admintools-ui/pom.xml | 2 +- .../AdminTools/Code/AdminToolsJS.xml | 6 +- .../AdminTools/Code/Configuration.xml | 19 +- .../AdminTools/Code/ConfigurationClass.xml | 5 +- .../main/resources/AdminTools/Code/Macros.xml | 167 +++++++++--------- .../AdminTools/Code/Translations.xml | 7 +- .../src/main/resources/AdminTools/WebHome.xml | 10 +- pom.xml | 10 +- 15 files changed, 399 insertions(+), 107 deletions(-) create mode 100644 application-admintools-test/application-admintools-test-docker/pom.xml create mode 100644 application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsIT.java create mode 100644 application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AllITs.java create mode 100644 application-admintools-test/application-admintools-test-pageobjects/pom.xml create mode 100644 application-admintools-test/pom.xml diff --git a/application-admintools-api/pom.xml b/application-admintools-api/pom.xml index fba7f3f6..ed26ce87 100644 --- a/application-admintools-api/pom.xml +++ b/application-admintools-api/pom.xml @@ -23,7 +23,7 @@ com.xwiki.admintools application-admintools - 1.0-SNAPSHOT + 1.0.139-SNAPSHOT 4.0.0 application-admintools-api diff --git a/application-admintools-default/pom.xml b/application-admintools-default/pom.xml index c7138581..c9bc954a 100644 --- a/application-admintools-default/pom.xml +++ b/application-admintools-default/pom.xml @@ -23,7 +23,7 @@ com.xwiki.admintools application-admintools - 1.0-SNAPSHOT + 1.0.139-SNAPSHOT 4.0.0 application-admintools-default diff --git a/application-admintools-test/application-admintools-test-docker/pom.xml b/application-admintools-test/application-admintools-test-docker/pom.xml new file mode 100644 index 00000000..e029c866 --- /dev/null +++ b/application-admintools-test/application-admintools-test-docker/pom.xml @@ -0,0 +1,103 @@ + + + + + + 4.0.0 + + com.xwiki.admintools + application-admintools-test + 1.0.139-SNAPSHOT + + application-admintools-test-docker + Admin Tools Application - Tests - Functional Docker Tests + jar + + + true + + + + + ${project.groupId} + application-admintools-ui + ${project.version} + xar + + + org.xwiki.platform + xwiki-platform-localization-rest-default + ${platform.version} + runtime + + + + org.xwiki.platform + xwiki-platform-test-docker + ${platform.version} + test + + + ${project.groupId} + application-admintools-test-pageobjects + ${project.version} + test + + + + src/test/it + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + + + clover + + + + org.openclover + clover + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + clover + + + + + + + + \ No newline at end of file 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 new file mode 100644 index 00000000..6d405d13 --- /dev/null +++ b/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AdminToolsIT.java @@ -0,0 +1,42 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package com.xwiki.admintools.test.ui; + +import org.junit.jupiter.api.Test; +import org.xwiki.test.docker.junit5.TestConfiguration; +import org.xwiki.test.docker.junit5.TestReference; +import org.xwiki.test.docker.junit5.UITest; +import org.xwiki.test.docker.junit5.browser.Browser; +import org.xwiki.test.docker.junit5.database.Database; +import org.xwiki.test.docker.junit5.servletengine.ServletEngine; +import org.xwiki.test.ui.TestUtils; + +@UITest(database = Database.MYSQL, databaseTag = "8", servletEngine = ServletEngine.TOMCAT, servletEngineTag = "8", + browser = Browser.CHROME) +class AdminToolsIT +{ + @Test + void testTry(TestUtils testUtils, TestReference testReference, + TestConfiguration testConfiguration) + { + String test = testUtils.getDriver().getCurrentUrl(); + System.out.println(test); + } +} \ No newline at end of file diff --git a/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AllITs.java b/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AllITs.java new file mode 100644 index 00000000..75bf3344 --- /dev/null +++ b/application-admintools-test/application-admintools-test-docker/src/test/it/com/xwiki/admintools/test/ui/AllITs.java @@ -0,0 +1,40 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package com.xwiki.admintools.test.ui; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.xwiki.test.docker.junit5.UITest; + +/** + * All UI tests for the Poll application. + * + * @version $Id$ + * @since 2.2 + */ +@UITest +class AllITs +{ + @Nested + @DisplayName("Admin Tools UI") + class NestedAdminToolsIT extends AdminToolsIT + { + } +} diff --git a/application-admintools-test/application-admintools-test-pageobjects/pom.xml b/application-admintools-test/application-admintools-test-pageobjects/pom.xml new file mode 100644 index 00000000..cde01316 --- /dev/null +++ b/application-admintools-test/application-admintools-test-pageobjects/pom.xml @@ -0,0 +1,39 @@ + + + + + + 4.0.0 + + com.xwiki.admintools + application-admintools-test + 1.0.139-SNAPSHOT + + application-admintools-test-pageobjects + Admin Tools Application - Tests - Page Objects + + + org.xwiki.platform + xwiki-platform-test-ui + ${platform.version} + + + \ No newline at end of file diff --git a/application-admintools-test/pom.xml b/application-admintools-test/pom.xml new file mode 100644 index 00000000..23480820 --- /dev/null +++ b/application-admintools-test/pom.xml @@ -0,0 +1,52 @@ + + + + + + 4.0.0 + + com.xwiki.admintools + application-admintools + 1.0.139-SNAPSHOT + + application-admintools-test + Admin Tools Application - Tests - Parent POM + pom + Admin Tools Application - Tests - Parent POM + + + true + true + + true + + + application-admintools-test-pageobjects + + + + docker + + application-admintools-test-docker + + + + \ No newline at end of file diff --git a/application-admintools-ui/pom.xml b/application-admintools-ui/pom.xml index c395ceb4..936192a2 100644 --- a/application-admintools-ui/pom.xml +++ b/application-admintools-ui/pom.xml @@ -24,7 +24,7 @@ com.xwiki.admintools application-admintools - 1.0-SNAPSHOT + 1.0.139-SNAPSHOT 4.0.0 application-admintools-ui diff --git a/application-admintools-ui/src/main/resources/AdminTools/Code/AdminToolsJS.xml b/application-admintools-ui/src/main/resources/AdminTools/Code/AdminToolsJS.xml index 3db38979..4447a80f 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/Code/AdminToolsJS.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/Code/AdminToolsJS.xml @@ -1,4 +1,5 @@ - + + + AdminTools.Code AdminToolsJS @@ -172,4 +174,4 @@ onDemand - \ No newline at end of file + diff --git a/application-admintools-ui/src/main/resources/AdminTools/Code/Configuration.xml b/application-admintools-ui/src/main/resources/AdminTools/Code/Configuration.xml index 2991078d..f67ff896 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/Code/Configuration.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/Code/Configuration.xml @@ -1,4 +1,4 @@ - + + AdminTools.Code Configuration @@ -66,7 +67,7 @@ - + @@ -292,19 +293,19 @@ - + - + AdminTools.Code.ConfigurationClass - + - + Admin Tools @@ -313,10 +314,10 @@ $services.localization.render('admin.admintools.description') - + - + @@ -328,4 +329,4 @@ - \ No newline at end of file + diff --git a/application-admintools-ui/src/main/resources/AdminTools/Code/ConfigurationClass.xml b/application-admintools-ui/src/main/resources/AdminTools/Code/ConfigurationClass.xml index deb2ec4b..d2638bb6 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/Code/ConfigurationClass.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/Code/ConfigurationClass.xml @@ -1,4 +1,4 @@ - + + AdminTools.Code ConfigurationClass @@ -128,4 +129,4 @@ XWiki.ClassSheet - \ No newline at end of file + diff --git a/application-admintools-ui/src/main/resources/AdminTools/Code/Macros.xml b/application-admintools-ui/src/main/resources/AdminTools/Code/Macros.xml index 1d746496..f06a51af 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/Code/Macros.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/Code/Macros.xml @@ -1,4 +1,4 @@ - + + AdminTools.Code Macros @@ -38,84 +39,84 @@ {{velocity output='false'}} #macro (viewLastNLinesMoldal $id) #set ($modalId = $id + 'ViewLastNLinesModal') - <div class="modal fade" id="${modalId}" tabindex="-1" role="dialog" aria-labelledby="${modalId}Label"> - <div class="modal-dialog modal-sm" role="document"> - <div class="modal-content"> - <div class="logs-modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">&times;</span></button> - <h1 class="modal-title"> + <div class="modal fade" id="${modalId}" tabindex="-1" role="dialog" aria-labelledby="${modalId}Label"> + <div class="modal-dialog modal-sm" role="document"> + <div class="modal-content"> + <div class="logs-modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">&times;</span></button> + <h1 class="modal-title"> $escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.title')) - </h1> - </div> - <div class="modal-body"> - <form class="xform" action="$request.getContextPath()/rest/admintools/files/logs"> - <dl> - <dt> - <label for="noLines">$escapetool.xml($services.localization.render( - 'adminTools.dashboard.logs.modal.nLines.label')) </label> - <span class="xHint">$escapetool.xml($services.localization.render( - 'adminTools.dashboard.logs.modal.nLines.hint'))</span> - </dt> - <dd><input type="number" name="noLines" placeholder="1000"></dd> - </dl> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-primary"> - $escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.submit'))</button> - <button type="button" class="btn btn-default" data-dismiss="modal"> - $escapetool.xml($services.localization.render('cancel'))</button> - </div> - </div> - </div> - </div> - </div> + </h1> + </div> + <div class="modal-body"> + <form class="xform" action="$request.getContextPath()/rest/admintools/files/logs"> + <dl> + <dt> + <label for="noLines">$escapetool.xml($services.localization.render( + 'adminTools.dashboard.logs.modal.nLines.label')) </label> + <span class="xHint">$escapetool.xml($services.localization.render( + 'adminTools.dashboard.logs.modal.nLines.hint'))</span> + </dt> + <dd><input type="number" name="noLines" placeholder="1000"></dd> + </dl> + </form> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary"> + $escapetool.xml($services.localization.render('adminTools.dashboard.logs.modal.submit'))</button> + <button type="button" class="btn btn-default" data-dismiss="modal"> + $escapetool.xml($services.localization.render('cancel'))</button> + </div> + </div> + </div> + </div> + </div> #end #macro (downloadArchiveModal) <div class="modal fade" id="downloadFilesModal" tabindex="-1" role="dialog" aria-labelledby= - "downloadFilesModalLabel"> - <div class="modal-dialog" role="document"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">&times;</span></button> - <h1 class="modal-title"> + "downloadFilesModalLabel"> + <div class="modal-dialog" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">&times;</span></button> + <h1 class="modal-title"> $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.title')) - </h1> - </div> - <div class="modal-body"> - <form class="xform" action="$request.getContextPath()/rest/admintools/files"> - <div class="download-modal-content"> - <dl> - <dt><label><input type="checkbox" name="files" value="xwikiConfig" checked> + </h1> + </div> + <div class="modal-body"> + <form class="xform" action="$request.getContextPath()/rest/admintools/files"> + <div class="download-modal-content"> + <dl> + <dt><label><input type="checkbox" name="files" value="xwikiConfig" checked> $escapetool.xml($services.localization.render( 'adminTools.dashboard.download.modal.xwikiConfig.title')) - </label> - </dt> - <dt><label><input type="checkbox" name="files" value="xwikiProperties" checked> + </label> + </dt> + <dt><label><input type="checkbox" name="files" value="xwikiProperties" checked> $escapetool.xml($services.localization.render( 'adminTools.dashboard.download.modal.xwikiProperties.title')) - </label> - </dt> - <dt> - <label><input type="checkbox" name="files" value="dataProvider" checked> + </label> + </dt> + <dt> + <label><input type="checkbox" name="files" value="dataProvider" checked> $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.provided')) - </label> - </dt> - <dt> - <label><input type="checkbox" name="files" value="logs" checked> + </label> + </dt> + <dt> + <label><input type="checkbox" name="files" value="logs" checked> $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.logs.title')) - </label> - </dt> - <dt> - <div class="dateFields"> + </label> + </dt> + <dt> + <div class="dateFields"> #set ($defaultDateFormat = 'dd-MM-yyyy') #set ($dateFormat = $xwiki.getXWikiPreference('dateformat', $defaultDateFormat)) - <label for="downloadFilesModalFromDate">$escapetool.xml($services.localization.render( + <label for="downloadFilesModalFromDate">$escapetool.xml($services.localization.render( 'adminTools.dashboard.download.modal.date.from')) - </label> + </label> #set ($dateFromParams = { 'id': "downloadFilesModalFromDate", 'name': 'from', @@ -124,9 +125,9 @@ 'adminTools.dashboard.download.modal.logs.filter.placeholder.from')) }) #dateTimePicker($dateFromParams) - <label for="downloadFilesModalToDate">$escapetool.xml($services.localization.render( + <label for="downloadFilesModalToDate">$escapetool.xml($services.localization.render( 'adminTools.dashboard.download.modal.date.to')) - </label> + </label> #set ($dateToParams = { 'id': "downloadFilesModalToDate", 'name': 'to', @@ -135,21 +136,21 @@ 'adminTools.dashboard.download.modal.logs.filter.placeholder.to')) }) #dateTimePicker($dateToParams) - </div> - </dt> - </dl> - </div> - </form> - </div> - <div class="modal-footer"> - <button type="button" class="btn btn-primary"> - $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.button'))</button> - <button type="button" class="btn btn-default" data-dismiss="modal"> - $escapetool.xml($services.localization.render('cancel'))</button> - </div> - </div> - </div> - </div> + </div> + </dt> + </dl> + </div> + </form> + </div> + <div class="modal-footer"> + <button type="button" class="btn btn-primary"> + $escapetool.xml($services.localization.render('adminTools.dashboard.download.modal.button'))</button> + <button type="button" class="btn btn-default" data-dismiss="modal"> + $escapetool.xml($services.localization.render('cancel'))</button> + </div> + </div> + </div> + </div> #end {{/velocity}} - \ No newline at end of file + diff --git a/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml b/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml index 0f7e5c54..6794b2ee 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/Code/Translations.xml @@ -1,4 +1,4 @@ - + + AdminTools.Code Translations @@ -120,7 +121,7 @@ adminTools.dashboard.section.security.title=Security 1 Scope 0 - + |, 1 0 @@ -132,4 +133,4 @@ adminTools.dashboard.section.security.title=Security WIKI - \ No newline at end of file + diff --git a/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml b/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml index 535f86e6..a7e72e1e 100644 --- a/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml +++ b/application-admintools-ui/src/main/resources/AdminTools/WebHome.xml @@ -1,4 +1,5 @@ - + + + AdminTools WebHome @@ -99,7 +101,7 @@ 1, 1 - + </property> </object> <object> @@ -166,7 +168,7 @@ <position>2, 1</position> </property> <property> - <title> + </property> </object> <object> @@ -313,4 +315,4 @@ <use>currentPage</use> </property> </object> -</xwikidoc> \ No newline at end of file +</xwikidoc> diff --git a/pom.xml b/pom.xml index 4ddbf031..fab63513 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ <groupId>com.xwiki.admintools</groupId> <artifactId>application-admintools</artifactId> <packaging>pom</packaging> - <version>1.0-SNAPSHOT</version> + <version>1.0.139-SNAPSHOT</version> <name>Admin Tools Application (Pro) Parent POM</name> <description>The Admin Tools Pro application gives you full control and visibility over your XWiki instance. Use it to manage your XWiki installation. Easily generate configuration reports. Perform sanity checks and show @@ -51,4 +51,12 @@ <module>application-admintools-default</module> <module>application-admintools-ui</module> </modules> + <profiles> + <profile> + <id>integration-tests</id> + <modules> + <module>application-admintools-test</module> + </modules> + </profile> + </profiles> </project> \ No newline at end of file