Skip to content
Snippets Groups Projects
Commit 1947e821 authored by Vincent Massol's avatar Vincent Massol
Browse files

[Misc] Added missing functional test for the share page feature

parent 62271b99
No related branches found
No related tags found
No related merge requests found
Showing
with 519 additions and 6 deletions
...@@ -34,4 +34,12 @@ ...@@ -34,4 +34,12 @@
<modules> <modules>
<module>xwiki-platform-sharepage-ui</module> <module>xwiki-platform-sharepage-ui</module>
</modules> </modules>
<profiles>
<profile>
<id>integration-tests</id>
<modules>
<module>xwiki-platform-sharepage-test</module>
</modules>
</profile>
</profiles>
</project> </project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-sharepage</artifactId>
<version>7.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-sharepage-test</artifactId>
<name>XWiki Platform - Share Page - Tests - Parent POM</name>
<packaging>pom</packaging>
<description>XWiki Platform - Share Page - Tests - Parent POM</description>
<properties>
<!-- Don't run CLIRR in test modules since we don't care about backward compatibility for tests -->
<xwiki.clirr.skip>true</xwiki.clirr.skip>
<!-- Don't run Checkstyle in test modules -->
<xwiki.checkstyle.skip>true</xwiki.checkstyle.skip>
</properties>
<modules>
<module>xwiki-platform-sharepage-test-pageobjects</module>
<module>xwiki-platform-sharepage-test-tests</module>
</modules>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-sharepage-test</artifactId>
<version>7.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-sharepage-test-pageobjects</artifactId>
<name>XWiki Platform - Share Page - Tests - Page Objects</name>
<packaging>jar</packaging>
<description>XWiki Platform - Share Page - Tests - Page Objects</description>
<dependencies>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-test</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
/*
* 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 org.xwiki.sharepage.test.po;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.xwiki.test.ui.po.BaseElement;
/**
* Represents actions that can be done on the Share Page by Email dialog box.
*
* @version $Id$
* @since 7.0RC1
*/
public class ShareDialog extends BaseElement
{
@FindBy(id = "shareTarget")
private WebElement emailField;
@FindBy(xpath = "//textarea[@name = 'message']")
private WebElement emailMessage;
@FindBy(xpath = "//input[@type = 'submit' and @class = 'button']")
private WebElement sendButton;
public void setEmailField(String email)
{
this.emailField.clear();
this.emailField.sendKeys(email);
}
public void setMessage(String message)
{
this.emailMessage.clear();
this.emailMessage.sendKeys(message);
}
public ShareResultDialog sendMail()
{
this.sendButton.click();
return new ShareResultDialog();
}
}
/*
* 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 org.xwiki.sharepage.test.po;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.xwiki.test.ui.po.BaseElement;
import org.xwiki.test.ui.po.ViewPage;
/**
* Represents actions that can be done on the Share Page by Email dialog box result.
*
* @version $Id$
* @since 7.0RC1
*/
public class ShareResultDialog extends BaseElement
{
@FindBy(xpath = "//div[contains(@class, 'infomessage')]")
private WebElement infoDiv;
@FindBy(xpath = "//a[contains(@class, 'share-backlink')]")
private WebElement backLink;
public String getResultMessage()
{
return this.infoDiv.getText();
}
public ViewPage clickBackLink()
{
this.backLink.click();
return new ViewPage();
}
}
/*
* 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 org.xwiki.sharepage.test.po;
import org.xwiki.test.ui.po.ViewPage;
/**
* Adds the API to click on Share Page by Mail to a ViewPage.
*
* @version $Id$
* @since 7.0RC1
*/
public class ShareableViewPage extends ViewPage
{
/**
* Click the Share by Email submenu in the More Actions menu.
*/
public ShareDialog clickShareByEmail()
{
clickMoreActionsSubMenuEntry("tmActionShare");
return new ShareDialog();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!--
* 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.
-->
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-sharepage-test</artifactId>
<version>7.0-SNAPSHOT</version>
</parent>
<artifactId>xwiki-platform-sharepage-test-tests</artifactId>
<name>XWiki Platform - Share Page - Tests - Functional Tests</name>
<!-- TODO: Move to use "functional-test" in the future when http://jira.codehaus.org/browse/MNG-1911 is fixed,
see http://jira.xwiki.org/jira/browse/XWIKI-7683 -->
<packaging>jar</packaging>
<description>XWiki Platform - Share Page - Functional Tests</description>
<properties>
<!-- TODO: Remove once http://jira.xwiki.org/jira/browse/XWIKI-7581 is fixed -->
<xwikiCfgSuperadminPassword>pass</xwikiCfgSuperadminPassword>
<xwikiCfgPlugins>\
com.xpn.xwiki.plugin.skinx.JsSkinExtensionPlugin,\
com.xpn.xwiki.plugin.skinx.JsSkinFileExtensionPlugin,\
com.xpn.xwiki.plugin.skinx.CssSkinExtensionPlugin,\
com.xpn.xwiki.plugin.skinx.CssSkinFileExtensionPlugin,\
com.xpn.xwiki.plugin.skinx.LinkExtensionPlugin,\
com.xpn.xwiki.plugin.mailsender.MailSenderPlugin
</xwikiCfgPlugins>
<!-- Functional tests are allowed to output content to the console -->
<xwiki.surefire.captureconsole.skip>true</xwiki.surefire.captureconsole.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-sharepage-ui</artifactId>
<version>${project.version}</version>
<type>xar</type>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-mail-ui</artifactId>
<version>${project.version}</version>
<type>xar</type>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-sharepage-test-pageobjects</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<!-- Make sure we have the Logback SLF4J binding for client side logging for our tests and make sure other logging
systems go through SLF4J -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/it</testSourceDirectory>
<plugins>
<!-- TODO: Remove when the http://jira.codehaus.org/browse/MNG-1911 is fixed, see also
http://jira.xwiki.org/jira/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>
<profiles>
<profile>
<id>clover</id>
<!-- Add the Clover JAR to the WAR so that it's available at runtime when XWiki executes.
It's needed because instrumented jars in the WAR will call Clover APIs at runtime when they execute. -->
<dependencies>
<dependency>
<groupId>com.cenqua.clover</groupId>
<artifactId>clover</artifactId>
</dependency>
</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>com.cenqua.clover</groupId>
<artifactId>clover</artifactId>
<version>${clover.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
/*
* 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 org.xwiki.sharepage.test.ui;
import javax.mail.internet.MimeMessage;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.xwiki.sharepage.test.po.ShareDialog;
import org.xwiki.sharepage.test.po.ShareResultDialog;
import org.xwiki.sharepage.test.po.ShareableViewPage;
import org.xwiki.test.ui.AbstractTest;
import org.xwiki.test.ui.SuperAdminAuthenticationRule;
import org.xwiki.test.ui.po.ViewPage;
import com.icegreen.greenmail.util.GreenMail;
import com.icegreen.greenmail.util.ServerSetupTest;
import static org.junit.Assert.assertEquals;
/**
* UI tests for the Share by Email application.
*
* @version $Id$
* @since 7.0RC1
*/
public class SharePageTest extends AbstractTest
{
@Rule
public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
private GreenMail mail;
@Before
public void startMail()
{
this.mail = new GreenMail(ServerSetupTest.SMTP);
this.mail.start();
getUtil().updateObject("Mail", "MailConfig", "Mail.SendMailConfigClass", 0, "host", "localhost", "port",
"3025", "sendWaitTime", "0");
}
@After
public void stopMail()
{
if (this.mail != null) {
this.mail.stop();
}
}
@Test
public void testShareByEmail() throws Exception
{
// Delete any existing test page
getUtil().deletePage(getTestClassName(), getTestMethodName());
ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), "something", "title");
ShareableViewPage svp = new ShareableViewPage();
svp.clickShareByEmail();
ShareDialog sd = new ShareDialog();
sd.setEmailField("john@doe.com");
sd.setMessage("test");
ShareResultDialog srd = sd.sendMail();
assertEquals("The message has been sent to john.", srd.getResultMessage());
srd.clickBackLink();
// Verify we received the email and that its content is valid
this.mail.waitForIncomingEmail(10000L, 1);
MimeMessage mimeMessage = this.mail.getReceivedMessages()[0];
assertEquals("superadmin wants to share a document with you", mimeMessage.getSubject());
}
}
...@@ -36,4 +36,11 @@ ...@@ -36,4 +36,11 @@
<!-- Name to display by the Extension Manager --> <!-- Name to display by the Extension Manager -->
<xwiki.extension.name>Share Page Application</xwiki.extension.name> <xwiki.extension.name>Share Page Application</xwiki.extension.name>
</properties> </properties>
<dependencies>
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-platform-mailsender</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project> </project>
...@@ -157,12 +157,7 @@ public boolean isNewDocument() ...@@ -157,12 +157,7 @@ public boolean isNewDocument()
*/ */
protected void clickEditSubMenuEntry(String id) protected void clickEditSubMenuEntry(String id)
{ {
// Open the edit menu clickSubMenuEntryFromMenu(By.xpath("//div[@id='tmEdit']//button"), id);
getDriver().findElement(By.xpath("//div[@id='tmEdit']//button")).click();
// Wait for the submenu entry to be visible
getDriver().waitUntilElementIsVisible(By.id(id));
// Click on the specified entry
getDriver().findElement(By.id(id)).click();
} }
/** /**
...@@ -325,6 +320,28 @@ public void toggleWikiMenu() ...@@ -325,6 +320,28 @@ public void toggleWikiMenu()
toggleTopMenu(wikiMenuId); toggleTopMenu(wikiMenuId);
} }
/**
* @since 7.0RC1
*/
public void clickMoreActionsSubMenuEntry(String id)
{
clickSubMenuEntryFromMenu(
By.xpath("//div[@id='tmMoreActions']/button[contains(@class, 'dropdown-toggle')]"), id);
}
/**
* @since 7.0RC1
*/
private void clickSubMenuEntryFromMenu(By menuBy, String id)
{
// Open the parent Menu
getDriver().findElement(menuBy).click();
// Wait for the submenu entry to be visible
getDriver().waitUntilElementIsVisible(By.id(id));
// Click on the specified entry
getDriver().findElement(By.id(id)).click();
}
/** /**
* @return {@code true} if the screen is extra small (as defined by Bootstrap), {@code false} otherwise * @return {@code true} if the screen is extra small (as defined by Bootstrap), {@code false} otherwise
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment