Skip to content
Snippets Groups Projects
Commit a08a8140 authored by srosse's avatar srosse
Browse files

OO-1068: 2 selenium test for the portfolio (file artefacts)

parent 9a8220bd
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
*/ */
package org.olat.selenium; package org.olat.selenium;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
...@@ -34,6 +35,7 @@ import org.jboss.arquillian.graphene.page.Page; ...@@ -34,6 +35,7 @@ import org.jboss.arquillian.graphene.page.Page;
import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assume;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.olat.selenium.page.LoginPage; import org.olat.selenium.page.LoginPage;
...@@ -50,11 +52,13 @@ import org.olat.selenium.page.repository.AuthoringEnvPage.ResourceType; ...@@ -50,11 +52,13 @@ import org.olat.selenium.page.repository.AuthoringEnvPage.ResourceType;
import org.olat.selenium.page.user.UserToolsPage; import org.olat.selenium.page.user.UserToolsPage;
import org.olat.selenium.page.wiki.WikiPage; import org.olat.selenium.page.wiki.WikiPage;
import org.olat.test.ArquillianDeployments; import org.olat.test.ArquillianDeployments;
import org.olat.test.JunitTestHelper;
import org.olat.test.rest.UserRestClient; import org.olat.test.rest.UserRestClient;
import org.olat.user.restapi.UserVO; import org.olat.user.restapi.UserVO;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
@RunWith(Arquillian.class) @RunWith(Arquillian.class)
...@@ -636,6 +640,156 @@ public class PortfolioTest { ...@@ -636,6 +640,156 @@ public class PortfolioTest {
Assert.assertTrue(postTitleEl.getText().contains(postTitle)); Assert.assertTrue(postTitleEl.getText().contains(postTitle));
} }
/**
* Create a map.
* Go the "My artefacts" and create an artefact of type file. Bind it
* to the map. Check the map.
*
* @param loginPage
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void addFileArtefact(@InitialPage LoginPage loginPage)
throws IOException, URISyntaxException {
//File upload only work with Firefox
Assume.assumeTrue(browser instanceof FirefoxDriver);
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
loginPage
.loginAs(author.getLogin(), author.getPassword())
.resume();
//open the portfolio
PortfolioPage portfolio = userTools
.openUserToolsMenu()
.openPortfolio();
//create a map
String mapTitle = "Map-File-1-" + UUID.randomUUID();
String pageTitle = "Page-File-1-" + UUID.randomUUID();
String structureElementTitle = "Struct-File-1-" + UUID.randomUUID();
portfolio
.openMyMaps()
.createMap(mapTitle, "Need to upload some file")
.openEditor()
.selectMapInEditor(mapTitle)
.selectFirstPageInEditor()
.setPage(pageTitle, "With a little description")
.createStructureElement(structureElementTitle, "Structure description");
//go to my artefacts
portfolio = userTools
.openUserToolsMenu()
.openPortfolio()
.openMyArtefacts();
String textTitle = "File-1-" + UUID.randomUUID();
URL courseUrl = JunitTestHelper.class.getResource("file_resources/handInTopic1.pdf");
File file = new File(courseUrl.toURI());
//create the artefact
portfolio
.createFileArtefact()
.uploadFile(file)
.next()
.fillArtefactMetadatas(textTitle, "Description")
.next()
.tags("File", "PDF", "Learning")
.next()
.selectMap(mapTitle, pageTitle, structureElementTitle)
.finish();
OOGraphene.closeBlueMessageWindow(browser);
//open the portfolio
portfolio = userTools
.openUserToolsMenu()
.openPortfolio()
.openMyMaps()
.openMap(mapTitle)
.selectStructureInTOC(structureElementTitle);
//check that we see the post
By artefactTitleBy = By.cssSelector("div.panel-heading>h3");
WebElement artefactTitle = browser.findElement(artefactTitleBy);
Assert.assertTrue(artefactTitle.getText().contains(textTitle));
}
/**
* Create a map, create a new file artefact.
* Check the map and the artefact.
*
* @param loginPage
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void addFileArtefact_withinMap(@InitialPage LoginPage loginPage)
throws IOException, URISyntaxException {
//File upload only work with Firefox
Assume.assumeTrue(browser instanceof FirefoxDriver);
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
loginPage
.loginAs(author.getLogin(), author.getPassword())
.resume();
//open the portfolio
PortfolioPage portfolio = userTools
.openUserToolsMenu()
.openPortfolio();
//create a map
String mapTitle = "Map-File-2-" + UUID.randomUUID();
String pageTitle = "Page-File-2-" + UUID.randomUUID();
String structureElementTitle = "Struct-File-2-" + UUID.randomUUID();
portfolio
.openMyMaps()
.createMap(mapTitle, "Need a map to upload some files quckly")
.openEditor()
.selectMapInEditor(mapTitle)
.selectFirstPageInEditor()
.setPage(pageTitle, "With a little description")
.createStructureElement(structureElementTitle, "Structure description");
//create the file artefact
ArtefactWizardPage artefactWizard = portfolio
.linkArtefact()
.addArtefact()
.createFileArtefact();
String textTitle = "File-2-" + UUID.randomUUID();
URL courseUrl = JunitTestHelper.class.getResource("file_resources/handInTopic1.pdf");
File file = new File(courseUrl.toURI());
//foolow the wizard
artefactWizard
.uploadFile(file)
.next()
.fillArtefactMetadatas(textTitle, "Description")
.next()
.tags("File", "Data", "Learning")
.next()
.selectMap(mapTitle, pageTitle, structureElementTitle)
.finish();
OOGraphene.closeBlueMessageWindow(browser);
//open the portfolio
portfolio = userTools
.openUserToolsMenu()
.openPortfolio()
.openMyMaps()
.openMap(mapTitle)
.selectStructureInTOC(structureElementTitle);
//check that we see the post
By artefactTitleBy = By.cssSelector("div.panel-heading>h3");
WebElement artefactTitle = browser.findElement(artefactTitleBy);
Assert.assertTrue(artefactTitle.getText().contains(textTitle));
}
/** /**
* Create a course with a portfolio course element. * Create a course with a portfolio course element.
* Create a template from within the portfolio course * Create a template from within the portfolio course
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
*/ */
package org.olat.selenium.page.graphene; package org.olat.selenium.page.graphene;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -57,6 +58,11 @@ public class OOGraphene { ...@@ -57,6 +58,11 @@ public class OOGraphene {
((JavascriptExecutor)browser).executeScript("top.tinymce.activeEditor.setContent('" + content + "')"); ((JavascriptExecutor)browser).executeScript("top.tinymce.activeEditor.setContent('" + content + "')");
} }
public static final void uploadFile(By inputBy, File file, WebDriver browser) {
WebElement input = browser.findElement(inputBy);
input.sendKeys(file.getAbsolutePath());
}
public static final void closeBlueMessageWindow(WebDriver browser) { public static final void closeBlueMessageWindow(WebDriver browser) {
By closeButtonBy = By.cssSelector("div.o_alert_info div.o_sel_info_message i.o_icon.o_icon_close"); By closeButtonBy = By.cssSelector("div.o_alert_info div.o_sel_info_message i.o_icon.o_icon_close");
List<WebElement> closeButtons = browser.findElements(closeButtonBy); List<WebElement> closeButtons = browser.findElements(closeButtonBy);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
*/ */
package org.olat.selenium.page.portfolio; package org.olat.selenium.page.portfolio;
import java.io.File;
import java.util.List; import java.util.List;
import org.jboss.arquillian.drone.api.annotation.Drone; import org.jboss.arquillian.drone.api.annotation.Drone;
...@@ -84,6 +85,12 @@ public class ArtefactWizardPage { ...@@ -84,6 +85,12 @@ public class ArtefactWizardPage {
return this; return this;
} }
public ArtefactWizardPage uploadFile(File file) {
By inputBy = By.cssSelector(".o_fileinput input[type='file']");
OOGraphene.uploadFile(inputBy, file, browser);
return this;
}
public ArtefactWizardPage fillArtefactMetadatas(String title, String description) { public ArtefactWizardPage fillArtefactMetadatas(String title, String description) {
By titleBy = By.cssSelector(".o_sel_ep_artefact_metadata_title input"); By titleBy = By.cssSelector(".o_sel_ep_artefact_metadata_title input");
WebElement titleEl = browser.findElement(titleBy); WebElement titleEl = browser.findElement(titleBy);
......
...@@ -74,10 +74,7 @@ public class PortfolioPage { ...@@ -74,10 +74,7 @@ public class PortfolioPage {
* @return * @return
*/ */
public ArtefactWizardPage createTextArtefact() { public ArtefactWizardPage createTextArtefact() {
By createButtonBy = By.className("o_sel_add_artfeact"); addArtefact();
WebElement createButton = browser.findElement(createButtonBy);
createButton.click();
OOGraphene.waitBusy();
By addTextArtefactBy = By.className("o_sel_add_text_artfeact"); By addTextArtefactBy = By.className("o_sel_add_text_artfeact");
OOGraphene.waitElement(addTextArtefactBy); OOGraphene.waitElement(addTextArtefactBy);
...@@ -93,10 +90,7 @@ public class PortfolioPage { ...@@ -93,10 +90,7 @@ public class PortfolioPage {
* @return * @return
*/ */
public ArtefactWizardPage createLearningJournal() { public ArtefactWizardPage createLearningJournal() {
By createButtonBy = By.className("o_sel_add_artfeact"); addArtefact();
WebElement createButton = browser.findElement(createButtonBy);
createButton.click();
OOGraphene.waitBusy();
By addJournalArtefactBy = By.className("o_sel_add_liveblog_artfeact"); By addJournalArtefactBy = By.className("o_sel_add_liveblog_artfeact");
OOGraphene.waitElement(addJournalArtefactBy); OOGraphene.waitElement(addJournalArtefactBy);
...@@ -107,6 +101,18 @@ public class PortfolioPage { ...@@ -107,6 +101,18 @@ public class PortfolioPage {
return ArtefactWizardPage.getWizard(browser); return ArtefactWizardPage.getWizard(browser);
} }
public ArtefactWizardPage createFileArtefact() {
addArtefact();
By addJournalArtefactBy = By.className("o_sel_add_upload_artfeact");
OOGraphene.waitElement(addJournalArtefactBy);
WebElement addJournalArtefactLink = browser.findElement(addJournalArtefactBy);
addJournalArtefactLink.click();
OOGraphene.waitBusy();
return ArtefactWizardPage.getWizard(browser);
}
/** /**
* Click the link to add an artefact to the map * Click the link to add an artefact to the map
* *
......
...@@ -16,17 +16,7 @@ ...@@ -16,17 +16,7 @@
<!-- debugging arguments for javaVm: -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y --> <!-- debugging arguments for javaVm: -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y -->
</configuration> </configuration>
</container> </container>
<extension qualifier="selenium">
<property name="browserCapabilities">firefox</property>
<!-- Path for Firefox if needed
<property name="capabilityWebdriverFirefoxBin">/Applications/Firefox.app/Contents/MacOS/firefox-bin</property>
-->
<!-- Not all tests pass with Chrome (issue with file upload)
<property name="browser">*googlechrome</property>
-->
</extension>
<extension qualifier="webdriver"> <extension qualifier="webdriver">
<property name="browser">safari</property> <property name="browser">safari</property>
</extension> </extension>
...@@ -35,13 +25,14 @@ ...@@ -35,13 +25,14 @@
<property name="browser">safari</property> <property name="browser">safari</property>
</extension> </extension>
<extension qualifier="graphene-firefox">
<property name="browser">firefox</property>
<property name="remoteReusable">true</property>
</extension>
<extension qualifier="phantomjs"> <extension qualifier="phantomjs">
<property name="browser">phantomjs</property> <property name="browser">phantomjs</property>
<property name="dimensions">1000x700</property> <property name="dimensions">1000x700</property>
</extension> </extension>
<extension qualifier="student">
<property name="browserCapabilities">firefox</property>
<property name="count">100</property>
</extension>
</arquillian> </arquillian>
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