From eba0b3ecb27a3b7656d62e113d70a6ae946f70d9 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Wed, 5 Jul 2017 20:28:42 +0200 Subject: [PATCH] no-jira: selenium test for the participant folder course element --- .../course/nodes/pf/ui/PFCoachController.java | 2 +- .../course/nodes/pf/ui/_content/coach.html | 7 +- .../nodes/pf/ui/_content/participant.html | 11 +- .../java/org/olat/selenium/CourseTest.java | 123 ++++++++++++++++++ .../olat/selenium/page/core/FolderPage.java | 23 ++++ .../page/course/DialogConfigurationPage.java | 19 +++ .../olat/selenium/page/course/DialogPage.java | 19 +++ .../page/course/ParticipantFolderPage.java | 78 +++++++++++ 8 files changed, 269 insertions(+), 13 deletions(-) create mode 100644 src/test/java/org/olat/selenium/page/course/ParticipantFolderPage.java diff --git a/src/main/java/org/olat/course/nodes/pf/ui/PFCoachController.java b/src/main/java/org/olat/course/nodes/pf/ui/PFCoachController.java index 801bced3f9a..d9701e30875 100644 --- a/src/main/java/org/olat/course/nodes/pf/ui/PFCoachController.java +++ b/src/main/java/org/olat/course/nodes/pf/ui/PFCoachController.java @@ -191,7 +191,7 @@ public class PFCoachController extends FormBasicController implements Controller } else if(source == dropboxTable) { if(event instanceof SelectionEvent) { SelectionEvent se = (SelectionEvent)event; - DropBoxRow currentObject = (DropBoxRow) tableModel.getObject(se.getIndex()); + DropBoxRow currentObject = tableModel.getObject(se.getIndex()); if ("drop.box".equals(se.getCommand())){ doSelectParticipantFolder (ureq, currentObject.getIdentity(), PFView.displayDrop); } else if ("return.box".equals(se.getCommand())){ diff --git a/src/main/java/org/olat/course/nodes/pf/ui/_content/coach.html b/src/main/java/org/olat/course/nodes/pf/ui/_content/coach.html index cf33c550989..a4e9d0458da 100644 --- a/src/main/java/org/olat/course/nodes/pf/ui/_content/coach.html +++ b/src/main/java/org/olat/course/nodes/pf/ui/_content/coach.html @@ -1,8 +1,8 @@ -<div class="clearfix"> #if($r.available("single")) $r.render("backLink") - <div class="o_block_bottom">$r.render("single")</div> + <div class="o_sel_pf_participant_folder clearfix o_block_bottom">$r.render("single")</div> #else +<div class="o_sel_pf_participants_list"> #if ($r.available("contextualSubscription")) <div class="clearfix o_block_bottom"> $r.render("contextualSubscription") @@ -12,6 +12,7 @@ #if($hasParticipants) $r.render("buttons") #end -#end </div> +#end + diff --git a/src/main/java/org/olat/course/nodes/pf/ui/_content/participant.html b/src/main/java/org/olat/course/nodes/pf/ui/_content/participant.html index 7a8e73f89fd..0edb97588c2 100644 --- a/src/main/java/org/olat/course/nodes/pf/ui/_content/participant.html +++ b/src/main/java/org/olat/course/nodes/pf/ui/_content/participant.html @@ -1,12 +1,4 @@ -<!-- <div class="panel panel-default o_personal"> --> -<!-- <div class="panel-heading">$name $r.translate("drop.box")</div> --> -<!-- <div>$r.translate("drop.info")</div> --> -<!-- <div>$r.render("upload")</div> --> -<!-- </div> --> -<!-- <div class="panel panel-default o_personal"> --> -<!-- <div class="panel-heading">$r.translate("return.box")</div> --> -<!-- <div>$r.translate("return.info")</div> --> -<!-- </div> --> +<div class="o_sel_pf_participant_folder"> #if ($limit) <div class="o_note">$r.translate("limit.count.info", $limit)</div> #end @@ -15,5 +7,6 @@ $r.render("contextualSubscription") #end $r.render("folder") +</div> diff --git a/src/test/java/org/olat/selenium/CourseTest.java b/src/test/java/org/olat/selenium/CourseTest.java index ab7d40f7711..756676b2c57 100644 --- a/src/test/java/org/olat/selenium/CourseTest.java +++ b/src/test/java/org/olat/selenium/CourseTest.java @@ -51,6 +51,7 @@ import org.olat.selenium.page.User; import org.olat.selenium.page.core.AdministrationPage; import org.olat.selenium.page.core.BookingPage; import org.olat.selenium.page.core.CalendarPage; +import org.olat.selenium.page.core.FolderPage; import org.olat.selenium.page.core.MenuTreePageFragment; import org.olat.selenium.page.course.AssessmentCEConfigurationPage; import org.olat.selenium.page.course.AssessmentToolPage; @@ -62,6 +63,7 @@ import org.olat.selenium.page.course.DialogPage; import org.olat.selenium.page.course.ForumCEPage; import org.olat.selenium.page.course.InfoMessageCEPage; import org.olat.selenium.page.course.MembersPage; +import org.olat.selenium.page.course.ParticipantFolderPage; import org.olat.selenium.page.course.PublisherPageFragment; import org.olat.selenium.page.course.RemindersPage; import org.olat.selenium.page.forum.ForumPage; @@ -1334,6 +1336,127 @@ public class CourseTest { .assertMessageBody("JPEG is smaller"); } + + /** + * An author create a course with a participant folder course + * element. It add a participant to the course and upload file + * in the return box of this participant.<br> + * The participant come in and open the course, see the file + * uploaded by the author in its return box and it uploads an + * image in its drop box. The author go the see the image. + * + * @param authorLoginPage + * @param participantBrowser + * @throws IOException + * @throws URISyntaxException + */ + @Test + @RunAsClient + public void createCourseWithParticipantFolder(@InitialPage LoginPage authorLoginPage, + @Drone @Participant WebDriver participantBrowser) + throws IOException, URISyntaxException { + UserVO author = new UserRestClient(deploymentUrl).createAuthor(); + UserVO participant = new UserRestClient(deploymentUrl).createRandomUser("Ryomou"); + authorLoginPage.loginAs(author.getLogin(), author.getPassword()); + + //go to authoring + AuthoringEnvPage authoringEnv = navBar + .assertOnNavigationPage() + .openAuthoringEnvironment(); + + String title = "Course partilist " + UUID.randomUUID(); + //create course + authoringEnv + .openCreateDropDown() + .clickCreate(ResourceType.course) + .fillCreateForm(title) + .assertOnGeneralTab() + .clickToolbarBack(); + + String participantFolderTitle = "ParticipantList"; + //open course editor + CoursePageFragment course = CoursePageFragment.getCourse(browser); + CourseEditorPageFragment editor = course + .assertOnCoursePage() + .assertOnTitle(title) + .openToolsMenu() + .edit() + .createNode("pf") + .nodeTitle(participantFolderTitle); + //publish + editor + .publish() + .quickPublish(UserAccess.membersOnly); + editor + .clickToolbarBack(); + + //add a participant + MembersPage members = new CoursePageFragment(browser) + .members(); + members + .addMember() + .searchMember(participant, true) + .nextUsers() + .nextOverview() + .selectRepositoryEntryRole(false, false, true) + .nextPermissions() + .finish(); + members + .clickToolbarBack(); + + //go to the course element + course + .clickTree() + .selectWithTitle(participantFolderTitle); + // open the return box of the participant and upload a file + URL coachImageUrl = JunitTestHelper.class.getResource("file_resources/IMG_1482.JPG"); + File coachImageFile = new File(coachImageUrl.toURI()); + ParticipantFolderPage folder = new ParticipantFolderPage(browser); + folder + .assertOnParticipantsList() + .assertOnParticipant(participant.getFirstName()) + .openParticipantFolder(participant.getFirstName()); + FolderPage directory = folder + .openReturnBox() + .uploadFile(coachImageFile) + .assertOnFile(coachImageFile.getName()); + + // The participant come in + LoginPage participantLoginPage = LoginPage.getLoginPage(participantBrowser, deploymentUrl); + participantLoginPage + .loginAs(participant.getLogin(), participant.getPassword()) + .resume(); + + // The participant find the course + NavigationPage participantNavBar = new NavigationPage(participantBrowser); + participantNavBar + .assertOnNavigationPage() + .openMyCourses() + .select(title); + // And opens the participant folder + CoursePageFragment participantCourse = CoursePageFragment.getCourse(participantBrowser); + participantCourse + .clickTree() + .selectWithTitle(participantFolderTitle); + ParticipantFolderPage participantFolder = new ParticipantFolderPage(participantBrowser); + participantFolder + .openReturnBox() + .assertOnFile(coachImageFile.getName()) + .selectRootDirectory(); + // Participant upload a file in its drop box + URL participantImageUrl = JunitTestHelper.class.getResource("file_resources/IMG_1482.JPG"); + File participantImageFile = new File(participantImageUrl.toURI()); + participantFolder + .openDropBox() + .uploadFile(participantImageFile) + .assertOnFile(participantImageFile.getName()); + + //Author check the image in the participant drop box + directory + .selectRootDirectory(); + folder.openDropBox() + .assertOnFile(participantImageFile.getName()); + } /** * Create a course with a calendar element, add a recurring event diff --git a/src/test/java/org/olat/selenium/page/core/FolderPage.java b/src/test/java/org/olat/selenium/page/core/FolderPage.java index 3ffdfde9b75..783937b01eb 100644 --- a/src/test/java/org/olat/selenium/page/core/FolderPage.java +++ b/src/test/java/org/olat/selenium/page/core/FolderPage.java @@ -19,6 +19,7 @@ */ package org.olat.selenium.page.core; +import java.io.File; import java.util.List; import org.junit.Assert; @@ -100,6 +101,28 @@ public class FolderPage { return this; } + public FolderPage uploadFile(File file) { + By newFileBy = By.className("o_bc_upload"); + browser.findElement(newFileBy).click(); + OOGraphene.waitModalDialog(browser); + + By inputBy = By.cssSelector("div.modal-dialog div.o_fileinput input[type='file']"); + OOGraphene.uploadFile(inputBy, file, browser); + OOGraphene.waitBusy(browser); + + By saveButtonBy = By.cssSelector("div.o_sel_upload_buttons button.btn-primary"); + browser.findElement(saveButtonBy).click(); + OOGraphene.waitBusy(browser); + return this; + } + + public FolderPage selectRootDirectory() { + By rootBy = By.xpath("//div[@class='o_briefcase_folder']//ol[@class='breadcrumb']/li[1]/a"); + browser.findElement(rootBy).click(); + OOGraphene.waitBusy(browser); + return this; + } + public FolderPage assertOnFile(String filename) { By fileBy = By.xpath("//table[contains(@class,'o_bc_table')]//a[contains(text(),'" + filename + "')]"); List<WebElement> fileEls = browser.findElements(fileBy); diff --git a/src/test/java/org/olat/selenium/page/course/DialogConfigurationPage.java b/src/test/java/org/olat/selenium/page/course/DialogConfigurationPage.java index e16a8a66eb9..549a6ea5c87 100644 --- a/src/test/java/org/olat/selenium/page/course/DialogConfigurationPage.java +++ b/src/test/java/org/olat/selenium/page/course/DialogConfigurationPage.java @@ -1,3 +1,22 @@ +/** + * <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; diff --git a/src/test/java/org/olat/selenium/page/course/DialogPage.java b/src/test/java/org/olat/selenium/page/course/DialogPage.java index 3cd14fe30ba..9665b84710e 100644 --- a/src/test/java/org/olat/selenium/page/course/DialogPage.java +++ b/src/test/java/org/olat/selenium/page/course/DialogPage.java @@ -1,3 +1,22 @@ +/** + * <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; diff --git a/src/test/java/org/olat/selenium/page/course/ParticipantFolderPage.java b/src/test/java/org/olat/selenium/page/course/ParticipantFolderPage.java new file mode 100644 index 00000000000..0675681e280 --- /dev/null +++ b/src/test/java/org/olat/selenium/page/course/ParticipantFolderPage.java @@ -0,0 +1,78 @@ +/** + * <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.core.FolderPage; +import org.olat.selenium.page.graphene.OOGraphene; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; + +/** + * + * Initial date: 5 juil. 2017<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class ParticipantFolderPage { + + private final WebDriver browser; + + public ParticipantFolderPage(WebDriver browser) { + this.browser = browser; + } + + public ParticipantFolderPage assertOnParticipantsList() { + By listBy = By.cssSelector("div.o_sel_pf_participants_list table"); + OOGraphene.waitElement(listBy, browser); + return this; + } + + public ParticipantFolderPage assertOnParticipant(String firstName) { + By inListBy = By.xpath("//div[contains(@class,'o_sel_pf_participants_list')]//table//td/a[contains(text(),'" + firstName + "')]"); + OOGraphene.waitElement(inListBy, browser); + return this; + } + + public ParticipantFolderPage openParticipantFolder(String firstName) { + By inListBy = By.xpath("//div[contains(@class,'o_sel_pf_participants_list')]//table//tr[td/a[contains(text(),'" + firstName + "')]]/td/a[contains(@href,'open.box')][i]"); + OOGraphene.waitElement(inListBy, browser); + browser.findElement(inListBy).click(); + OOGraphene.waitBusy(browser); + return this; + } + + public FolderPage openReturnBox() { + By returnBoxBy = By.xpath("//div[@class='o_briefcase_folder']//table/tbody/tr[1]/td/a[i[contains(@class,'o_filetype_folder')]]"); + OOGraphene.waitElement(returnBoxBy, browser); + browser.findElement(returnBoxBy).click(); + OOGraphene.waitBusy(browser); + return new FolderPage(browser); + } + + public FolderPage openDropBox() { + By returnBoxBy = By.xpath("//div[@class='o_briefcase_folder']//table/tbody/tr[2]/td/a[i[contains(@class,'o_filetype_folder')]]"); + OOGraphene.waitElement(returnBoxBy, browser); + browser.findElement(returnBoxBy).click(); + OOGraphene.waitBusy(browser); + return new FolderPage(browser); + } + + +} -- GitLab