diff --git a/src/main/java/org/olat/course/nodes/document/ui/_content/config.html b/src/main/java/org/olat/course/nodes/document/ui/_content/config.html index 230492c2514af3e92d9b8d18e002166111371f8c..7aabf5508aebf4458ca9e1e65ae0747831810de7 100644 --- a/src/main/java/org/olat/course/nodes/document/ui/_content/config.html +++ b/src/main/java/org/olat/course/nodes/document/ui/_content/config.html @@ -1,4 +1,4 @@ -<fieldset class="clearfix"> +<fieldset class="o_sel_document_settings_upload clearfix"> <legend>$r.contextHelpWithWrapper("Content#_document") $r.translate("config.title")</legend> $r.render("display") diff --git a/src/test/java/org/olat/selenium/CourseElementTest.java b/src/test/java/org/olat/selenium/CourseElementTest.java index 87739740c0fae528ef001675471af489c4149528..72bd8041dc1ae87896d3c309eeffccb1ab496280 100644 --- a/src/test/java/org/olat/selenium/CourseElementTest.java +++ b/src/test/java/org/olat/selenium/CourseElementTest.java @@ -52,6 +52,8 @@ import org.olat.selenium.page.course.CourseEditorPageFragment; import org.olat.selenium.page.course.CoursePageFragment; import org.olat.selenium.page.course.DialogConfigurationPage; import org.olat.selenium.page.course.DialogPage; +import org.olat.selenium.page.course.DocumentConfigurationPage; +import org.olat.selenium.page.course.DocumentPage; import org.olat.selenium.page.course.ForumCEPage; import org.olat.selenium.page.course.InfoMessageCEPage; import org.olat.selenium.page.course.LTIConfigurationPage; @@ -1281,6 +1283,56 @@ public class CourseElementTest extends Deployments { folder.openDropBox() .assertOnFile(participantImageFile.getName()); } + + + /** + * An author creates a course with a document course element, + * upload a PDF in the editor, publish the course and go to + * the course element check if the document is there. + * + * @throws IOException + * @throws URISyntaxException + */ + @Test + @RunAsClient + public void courseWithDocument() + throws IOException, URISyntaxException { + + UserVO author = new UserRestClient(deploymentUrl).createAuthor(); + + LoginPage loginPage = LoginPage.load(browser, deploymentUrl); + loginPage.loginAs(author.getLogin(), author.getPassword()); + + //create a course + String courseTitle = "DocCourse" + UUID.randomUUID(); + NavigationPage navBar = NavigationPage.load(browser); + navBar + .openAuthoringEnvironment() + .createCourse(courseTitle) + .clickToolbarBack(); + + //create a course element of type Test with the test that we create above + String nodeTitle = "Document"; + CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser) + .edit(); + courseEditor + .createNode("document") + .nodeTitle(nodeTitle); + + URL pdfDocumentUrl = JunitTestHelper.class.getResource("file_resources/handInTopic1.pdf"); + File pdfDocumentFile = new File(pdfDocumentUrl.toURI()); + + DocumentConfigurationPage docConfig = new DocumentConfigurationPage(browser); + docConfig + .selectConfiguration() + .uploadDocument(pdfDocumentFile); + + courseEditor + .autoPublish(); + + DocumentPage doc = new DocumentPage(browser); + doc.assertDocumentLink(pdfDocumentFile.getName()); + } /** diff --git a/src/test/java/org/olat/selenium/page/course/DocumentConfigurationPage.java b/src/test/java/org/olat/selenium/page/course/DocumentConfigurationPage.java new file mode 100644 index 0000000000000000000000000000000000000000..800bd519a66aa04005400fc20e6c5620a50044ad --- /dev/null +++ b/src/test/java/org/olat/selenium/page/course/DocumentConfigurationPage.java @@ -0,0 +1,57 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.selenium.page.course; + +import java.io.File; + +import org.olat.selenium.page.graphene.OOGraphene; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; + +/** + * + * Initial date: 2 nov. 2020<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class DocumentConfigurationPage { + + private final WebDriver browser; + + public DocumentConfigurationPage(WebDriver browser) { + this.browser = browser; + } + + public DocumentConfigurationPage selectConfiguration() { + By dialogConfigBy = By.cssSelector("fieldset.o_sel_document_settings_upload"); + OOGraphene.selectTab("o_node_config", dialogConfigBy, browser); + return this; + } + + 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']"); + OOGraphene.uploadFile(inputBy, file, browser); + + By previewBy = By.xpath("//div[contains(@class,'o_cnd_document')]/div[contains(@class,'o_cnd_header')]/h4[text()[contains(.,'" + file.getName() + "')]]"); + OOGraphene.waitElement(previewBy, browser); + return this; + } + +} diff --git a/src/test/java/org/olat/selenium/page/course/DocumentPage.java b/src/test/java/org/olat/selenium/page/course/DocumentPage.java new file mode 100644 index 0000000000000000000000000000000000000000..cb8d123c5966182b65c34b43bd8a28a8e0c80788 --- /dev/null +++ b/src/test/java/org/olat/selenium/page/course/DocumentPage.java @@ -0,0 +1,46 @@ +/** + * <a href="http://www.openolat.org"> + * OpenOLAT - Online Learning and Training</a><br> + * <p> + * Licensed under the Apache License, Version 2.0 (the "License"); <br> + * you may not use this file except in compliance with the License.<br> + * You may obtain a copy of the License at the + * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> + * <p> + * Unless required by applicable law or agreed to in writing,<br> + * software distributed under the License is distributed on an "AS IS" BASIS, <br> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br> + * See the License for the specific language governing permissions and <br> + * limitations under the License. + * <p> + * Initial code contributed and copyrighted by<br> + * frentix GmbH, http://www.frentix.com + * <p> + */ +package org.olat.selenium.page.course; + +import org.olat.selenium.page.graphene.OOGraphene; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; + +/** + * + * Initial date: 2 nov. 2020<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class DocumentPage { + + private final WebDriver browser; + + public DocumentPage(WebDriver browser) { + this.browser = browser; + } + + public DocumentPage assertDocumentLink(String name) { + By docLinkBy = By.xpath("//div[@class='o_cnd_run']/a/span[text()[contains(.,'" + name + "')]]"); + OOGraphene.waitElement(docLinkBy, browser); + return this; + } + +}