Skip to content

Commit

Permalink
XWIKI-21831: Migrate tour functional tests to docker
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelleduc committed Jan 25, 2024
1 parent 0498711 commit 6c99041
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
</properties>
<modules>
<module>xwiki-platform-tour-test-pageobjects</module>
<module>xwiki-platform-tour-test-tests</module>
</modules>
<profiles>
<profile>
<id>docker</id>
<modules>
<module>xwiki-platform-tour-test-docker</module>
</modules>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,87 +20,62 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-tour-test</artifactId>
<version>16.1.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-tour-test-tests</artifactId>
<artifactId>xwiki-platform-tour-test-docker</artifactId>
<name>XWiki Platform - Tour - Tests - Functional Tests</name>
<!-- TODO: Move to use "functional-test" in the future when http://jira.codehaus.org/browse/MNG-1911 is fixed,
see https://jira.xwiki.org/browse/XWIKI-7683 -->
<packaging>jar</packaging>
<description>XWiki Platform - Tour - Tests - Functional Tests in Docker</description>
<properties>
<xwikiCfgSuperadminPassword>pass</xwikiCfgSuperadminPassword>
<!-- Functional tests are allowed to output content to the console -->
<!-- Functional tests are allowed to output content to the console. -->
<xwiki.surefire.captureconsole.skip>true</xwiki.surefire.captureconsole.skip>
</properties>
<dependencies>
<!-- The UI we are testing-->
<!-- The UI we are testing. -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-tour-ui</artifactId>
<version>${project.version}</version>
<type>xar</type>
</dependency>
<!-- This macro is used during tests -->
<!-- This macro is used during tests. -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-localization-macro</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Test dependencies -->
<!-- Test dependencies. -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-tour-test-pageobjects</artifactId>
<artifactId>xwiki-platform-test-docker</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-tour-test-pageobjects</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/it</testSourceDirectory>
<plugins>
<!-- We need to explicitly include the failsafe plugin since it's not part of the default maven lifecycle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>package</id>
<activation>
<property>
<name>!skipITs</name>
</property>
</activation>
<build>
<plugins>
<!-- TODO: Remove when the http://jira.codehaus.org/browse/MNG-1911 is fixed, see also
https://jira.xwiki.org/browse/XWIKI-7683 -->
<plugin>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-tool-packager-plugin</artifactId>
<version>${project.version}</version>
<executions>
<execution>
<phase>generate-test-resources</phase>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>clover</id>
<!-- Add the Clover JAR to the WAR so that it's available at runtime when XWiki executes.
Expand All @@ -113,19 +88,16 @@
</dependencies>
<build>
<plugins>
<!-- Add the Clover JAR to the Packager plugin runtime classpath since the Packager plugin uses java classes
that have been instrumented with Clover (XWiki oldcore for example) -->
<plugin>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-tool-packager-plugin</artifactId>
<version>${project.version}</version>
<dependencies>
<dependency>
<groupId>org.openclover</groupId>
<artifactId>clover</artifactId>
<version>${clover.version}</version>
</dependency>
</dependencies>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<!-- Tell the Docker-based test to activate the Clover profile so that the Clover JAR is added to
WEB-INF/lib -->
<xwiki.test.ui.profiles>clover</xwiki.test.ui.profiles>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@
*/
package org.xwiki.tour.test.ui;

import org.junit.runner.RunWith;
import org.xwiki.test.ui.PageObjectSuite;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.xwiki.test.docker.junit5.UITest;

/**
* Runs all functional tests found in the classpath.
* All UI tests for the Tour feature.
*
* @version $Id$
*/
@RunWith(PageObjectSuite.class)
public class AllIT
@UITest
class AllIT
{

@Nested
@DisplayName("Tour UI")
class NestedTourApplicationIT extends TourApplicationIT
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,97 +22,96 @@
import java.util.Arrays;
import java.util.List;

import org.junit.Rule;
import org.junit.Test;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.xwiki.model.reference.LocalDocumentReference;
import org.xwiki.test.ui.AbstractTest;
import org.xwiki.test.ui.SuperAdminAuthenticationRule;
import org.xwiki.test.docker.junit5.UITest;
import org.xwiki.test.ui.TestUtils;
import org.xwiki.test.ui.po.ViewPage;
import org.xwiki.tour.test.po.PageWithTour;
import org.xwiki.tour.test.po.StepEditModal;
import org.xwiki.tour.test.po.TourEditPage;
import org.xwiki.tour.test.po.TourFromLivetable;
import org.xwiki.tour.test.po.TourHomePage;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Functional tests for the Tour Application.
*
* @version $Id$
*/
public class TourApplicationIT extends AbstractTest
@UITest
class TourApplicationIT
{
private static final LocalDocumentReference TOUR_REFERENCE_1 =
new LocalDocumentReference(List.of("Tour", "Test"), "WebHome");

private static final LocalDocumentReference TOUR_REFERENCE_2 =
new LocalDocumentReference(List.of("Tour", "NewTest"), "WebHome");

@Rule
public SuperAdminAuthenticationRule superAdminAuthenticationRule = new SuperAdminAuthenticationRule(getUtil());
@Test
@Order(1)
void verifyTourFeatures(TestUtils setup) throws Exception
{
setup.loginAsSuperAdmin();
// Use a scenario since it's a best practice but also because each tour test has consequences on the other one.
// For example, the second test binds to a TourClass and thus when displaying the first tour page (which also
// contains a TourClass) it would display the second tour...

private void setUpTour(TourEditPage tourEditPage, String description, boolean isActive, String targetPage,
String targetClass) throws Exception
setup.rest().delete(TOUR_REFERENCE_1);
setup.rest().delete(TOUR_REFERENCE_2);

tourBoundToPage();
tourBoundToClass();
}

private void setUpTour(TourEditPage tourEditPage, String description, String targetPage, String targetClass)
{
tourEditPage.setDescription(description);
tourEditPage.setIsActive(isActive);
tourEditPage.setIsActive(true);
tourEditPage.setTargetPage(targetPage);
tourEditPage.setTargetClass(targetClass);
}

private void setUpStep(TourEditPage tourEditPage, String element, String title, String content, boolean backdrop,
private void setUpStep(TourEditPage tourEditPage, String title, String content, boolean backdrop,
String targetPage)
{
StepEditModal stepEditModal = tourEditPage.newStep();
stepEditModal.setElement(element);
stepEditModal.setElement("body");
stepEditModal.setTitle(title);
stepEditModal.setContent(content);
stepEditModal.setBackdrop(backdrop);
stepEditModal.setTargetPage(targetPage);
stepEditModal.save();
}

private void deleteTour(String page) throws Exception
private void deleteTour()
{
TourHomePage tourHomePage = TourHomePage.gotoPage();
ViewPage tourPage = tourHomePage.getTourPage(page);
ViewPage tourPage = tourHomePage.getTourPage("Test");
tourPage.delete().clickYes();
}

@Test
public void verifyTourFeatures() throws Exception
{
// Use a scenario since it's a best practice but also because each tour test has consequences on the other one.
// For example, the second test binds to a TourClass and thus when displaying the first tour page (which
// also contains a TourClass) it would display the second tour...

getUtil().rest().delete(TOUR_REFERENCE_1);
getUtil().rest().delete(TOUR_REFERENCE_2);

tourBoundToPage();
tourBoundToClass();
}

private void tourBoundToPage() throws Exception
private void tourBoundToPage()
{
// First, we need to create a tour
TourHomePage tourHomePage = TourHomePage.gotoPage();
TourEditPage tourEditPage = tourHomePage.addNewEntry("Test");
setUpTour(tourEditPage, "My nice description", true, "Tour.StartTour.WebHome", "");
setUpTour(tourEditPage, "My nice description", "Tour.StartTour.WebHome", "");

// Test to put a translation key, use the translation macro
setUpStep(tourEditPage, "body", "tour.app.name", "{{translation key=\"TourCode.TourClass_description\" /}}",
setUpStep(tourEditPage, "tour.app.name", "{{translation key=\"TourCode.TourClass_description\" /}}",
true, "");
// I voluntary create the object 3 before the 2 to test the 'order' field
setUpStep(tourEditPage, "body", "Title 3", "Step 3", true, "");
setUpStep(tourEditPage, "body", "Title 2", "Step 2", true, "");
setUpStep(tourEditPage, "Title 3", "Step 3", true, "");
setUpStep(tourEditPage, "Title 2", "Step 2", true, "");
// Add a step that will be removed
setUpStep(tourEditPage, "body", "to remove", "to remove", false, "");
setUpStep(tourEditPage, "to remove", "to remove", false, "");
// Object 4 used to test the Multipage feature ('targetPage' field)
setUpStep(tourEditPage, "body", "Title 4", "Step 4", true, "TourCode.TourClass");
setUpStep(tourEditPage, "Title 4", "Step 4", true, "TourCode.TourClass");

// Test that we can change the order of a step
StepEditModal stepEditModal = tourEditPage.editStep(2);
Expand Down Expand Up @@ -283,16 +282,16 @@ private void tourBoundToPage() throws Exception
homePage.close();

// Verify that we can delete a tour in the LT UI
deleteTour("Test");
deleteTour();
}

private void tourBoundToClass() throws Exception
private void tourBoundToClass()
{
// First, we need to create a tour
TourHomePage tourHomePage = TourHomePage.gotoPage();
TourEditPage tourEditPage = tourHomePage.addNewEntry("NewTest");
setUpTour(tourEditPage, "Description", true, "", "TourCode.TourClass");
setUpStep(tourEditPage, "body", "Tour Title", "Tour Content", true, "");
setUpTour(tourEditPage, "Description", "", "TourCode.TourClass");
setUpStep(tourEditPage, "Tour Title", "Tour Content", true, "");
tourEditPage.clickSaveAndView();

tourHomePage = TourHomePage.gotoPage();
Expand Down

0 comments on commit 6c99041

Please sign in to comment.