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

no-jira: selenium test for document element with doc. from repository

parent c4d37c65
No related branches found
No related tags found
No related merge requests found
...@@ -82,6 +82,7 @@ public class DocumentSelectionController extends FormBasicController { ...@@ -82,6 +82,7 @@ public class DocumentSelectionController extends FormBasicController {
formLayout.add(selectCont); formLayout.add(selectCont);
selectCourseFolderLink = uifactory.addFormLink("config.select.course.folder", selectCont, "btn btn-default"); selectCourseFolderLink = uifactory.addFormLink("config.select.course.folder", selectCont, "btn btn-default");
selectRepositoryEntryLink = uifactory.addFormLink("config.select.repo.entry", selectCont, "btn btn-default"); selectRepositoryEntryLink = uifactory.addFormLink("config.select.repo.entry", selectCont, "btn btn-default");
selectRepositoryEntryLink.setElementCssClass("o_sel_doc_select_repository_entry");
// Create // Create
List<DocTemplate> templates = docTemplates.getTemplates(); List<DocTemplate> templates = docTemplates.getTemplates();
......
...@@ -1333,6 +1333,63 @@ public class CourseElementTest extends Deployments { ...@@ -1333,6 +1333,63 @@ public class CourseElementTest extends Deployments {
DocumentPage doc = new DocumentPage(browser); DocumentPage doc = new DocumentPage(browser);
doc.assertDocumentLink(pdfDocumentFile.getName()); doc.assertDocumentLink(pdfDocumentFile.getName());
} }
/**
* An author upload a PDF document as learn resource, after that she creates
* a course with a document course element, selects the PDF in the editor,
* publish the course and go to the course element see if the document is
* there.
*
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void courseWithDocumentFromRepository()
throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
LoginPage loginPage = LoginPage.load(browser, deploymentUrl);
loginPage.loginAs(author.getLogin(), author.getPassword());
URL pdfDocumentUrl = JunitTestHelper.class.getResource("file_resources/handInTopic1.pdf");
File pdfDocumentFile = new File(pdfDocumentUrl.toURI());
//create a course
String docTitle = "PDF-" + UUID.randomUUID();
NavigationPage navBar = NavigationPage.load(browser);
navBar
.openAuthoringEnvironment()
.uploadResource(docTitle, pdfDocumentFile);
//create a course
String courseTitle = "PDFDoc-" + UUID.randomUUID();
navBar
.openAuthoringEnvironment()
.createCourse(courseTitle)
.clickToolbarBack();
//create a course element of type Test with the test that we create above
String nodeTitle = "PDF";
CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser)
.edit();
courseEditor
.createNode("document")
.nodeTitle(nodeTitle);
DocumentConfigurationPage docConfig = new DocumentConfigurationPage(browser);
docConfig
.selectConfiguration()
.selectDocument(docTitle);
courseEditor
.autoPublish();
DocumentPage doc = new DocumentPage(browser);
doc.assertDocumentLink(pdfDocumentFile.getName());
}
/** /**
......
...@@ -48,10 +48,38 @@ public class DocumentConfigurationPage { ...@@ -48,10 +48,38 @@ public class DocumentConfigurationPage {
public DocumentConfigurationPage uploadDocument(File file) { public DocumentConfigurationPage uploadDocument(File file) {
By inputBy = By.xpath("//fieldset[contains(@class,'o_sel_document_settings_upload')]//div[contains(@class,'o_fileinput')]/input[@type='file']"); By inputBy = By.xpath("//fieldset[contains(@class,'o_sel_document_settings_upload')]//div[contains(@class,'o_fileinput')]/input[@type='file']");
OOGraphene.uploadFile(inputBy, file, browser); OOGraphene.uploadFile(inputBy, file, browser);
return assertOnPreview(file.getName());
}
public DocumentConfigurationPage selectDocument(String name) {
By inputBy = By.cssSelector("fieldset.o_sel_document_settings_upload a.o_sel_doc_select_repository_entry");
OOGraphene.waitElement(inputBy, browser);
browser.findElement(inputBy).click();
OOGraphene.waitBusy(browser);
OOGraphene.waitModalDialog(browser);
//find the row
By rowBy = By.xpath("//div[contains(@class,'')]//div[contains(@class,'o_segments_content')]//table[contains(@class,'o_table')]//tr/td/a[text()[contains(.,'" + name + "')]]");
OOGraphene.waitElement(rowBy, browser);
browser.findElement(rowBy).click();
OOGraphene.waitBusy(browser);
//confirm
By confirmBy = By.xpath("//div[contains(@class,'modal-dialog')]//a[contains(@onclick,'link_0')]");
OOGraphene.waitElement(confirmBy, browser);
browser.findElement(confirmBy).click();
OOGraphene.waitBusy(browser);
By previewBy = By.xpath("//div[contains(@class,'o_cnd_document')]/div[contains(@class,'o_cnd_header')]/h4[text()[contains(.,'" + file.getName() + "')]]"); return assertOnPreview(name);
}
public DocumentConfigurationPage assertOnPreview(String name) {
By previewBy = By.xpath("//div[contains(@class,'o_cnd_document')]/div[contains(@class,'o_cnd_header')]/h4[text()[contains(.,'" + name + "')]]");
OOGraphene.waitElement(previewBy, browser); OOGraphene.waitElement(previewBy, browser);
return this; return this;
} }
} }
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