diff --git a/src/main/java/org/olat/course/nodes/members/MembersConfigForm.java b/src/main/java/org/olat/course/nodes/members/MembersConfigForm.java index a55b3d082eba6267bac9620b08f9874e926057db..763604b8be3ca468905db32799e1b2fd9d35c1fa 100755 --- a/src/main/java/org/olat/course/nodes/members/MembersConfigForm.java +++ b/src/main/java/org/olat/course/nodes/members/MembersConfigForm.java @@ -105,6 +105,7 @@ public class MembersConfigForm extends FormBasicController { setFormTitle("pane.tab.membersconfig"); setFormInfo("members.info"); setFormContextHelp("Communication and Collaboration#_teilnehmerliste"); + formLayout.setElementCssClass("o_sel_cmembers_settings"); // Read Configuration boolean showOwnerConfig = config.getBooleanSafe(MembersCourseNode.CONFIG_KEY_SHOWOWNER); diff --git a/src/test/java/org/olat/selenium/CourseTest.java b/src/test/java/org/olat/selenium/CourseTest.java index 756676b2c572cb5736611555cba2e80fb9aa1c87..4d82260b7392b7cfaf17d05de078bae1b61fd2dd 100644 --- a/src/test/java/org/olat/selenium/CourseTest.java +++ b/src/test/java/org/olat/selenium/CourseTest.java @@ -62,6 +62,8 @@ import org.olat.selenium.page.course.DialogConfigurationPage; 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.MemberListConfigurationPage; +import org.olat.selenium.page.course.MemberListPage; import org.olat.selenium.page.course.MembersPage; import org.olat.selenium.page.course.ParticipantFolderPage; import org.olat.selenium.page.course.PublisherPageFragment; @@ -1336,6 +1338,150 @@ public class CourseTest { .assertMessageBody("JPEG is smaller"); } + + /** + * An author create a course with a member list course element. + * It add two participants and a coach. It publish the course and + * check that it sees the authors, coaches and participants.<br> + * After that, it edits the course and change the settins to only + * show the participants. It checks that only the participants are + * visible.<br> + * At least, it changes the settings a second time to only show + * the course coaches. + * + * @param authorLoginPage + * @throws IOException + * @throws URISyntaxException + */ + @Test + @RunAsClient + public void createCourseWithMemberList(@InitialPage LoginPage authorLoginPage) + throws IOException, URISyntaxException { + UserVO author = new UserRestClient(deploymentUrl).createAuthor(); + UserVO coach = new UserRestClient(deploymentUrl).createRandomUser("Rei"); + UserVO participant1 = new UserRestClient(deploymentUrl).createRandomUser("Kanu"); + UserVO participant2 = 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(); + + //add 2 participants + CoursePageFragment course = new CoursePageFragment(browser); + MembersPage members = course + .members(); + members + .importMembers() + .setMembers(participant1, participant2) + .nextUsers() + .nextOverview() + .nextPermissions() + .finish(); + //add a coach + course + .members() + .addMember() + .searchMember(coach, true) + .nextUsers() + .nextOverview() + .selectRepositoryEntryRole(false, true, false) + .nextPermissions() + .finish(); + members + .clickToolbarBack(); + + String memberListTitle = "MemberList"; + //open course editor + CourseEditorPageFragment editor = course + .assertOnCoursePage() + .assertOnTitle(title) + .openToolsMenu() + .edit() + .createNode("cmembers") + .nodeTitle(memberListTitle); + //publish + editor + .publish() + .quickPublish(UserAccess.registred); + editor + .clickToolbarBack(); + + course + .clickTree() + .selectWithTitle(memberListTitle); + + //check the default configuration with authors, coaches and participants + MemberListPage memberList = new MemberListPage(browser); + memberList + .assertOnOwner(author.getFirstName()) + .assertOnCoach(coach.getFirstName()) + .assertOnParticipant(participant1.getFirstName()) + .assertOnParticipant(participant2.getFirstName()); + + //the author is not satisfied with the configuration + editor = course + .openToolsMenu() + .edit() + .selectNode(memberListTitle); + MemberListConfigurationPage memberListConfig = new MemberListConfigurationPage(browser); + memberListConfig + .selectSettings() + .setOwners(Boolean.FALSE) + .setCoaches(Boolean.FALSE) + .save(); + + //go check the results + course = editor + .autoPublish(); + course + .clickTree() + .selectWithTitle(memberListTitle); + + memberList + .assertOnMembers() + .assertOnNotOwner(author.getFirstName()) + .assertOnNotCoach(coach.getFirstName()) + .assertOnParticipant(participant1.getFirstName()) + .assertOnParticipant(participant2.getFirstName()); + + // perhaps only the coaches + editor = course + .openToolsMenu() + .edit() + .selectNode(memberListTitle); + memberListConfig = new MemberListConfigurationPage(browser); + memberListConfig + .selectSettings() + .setCoaches(Boolean.TRUE) + .setCourseCoachesOnly() + .setParticipants(Boolean.FALSE) + .save(); + + //go check that we see only the coaches results + course = editor + .autoPublish(); + course + .clickTree() + .selectWithTitle(memberListTitle); + + memberList + .assertOnMembers() + .assertOnNotOwner(author.getFirstName()) + .assertOnCoach(coach.getFirstName()) + .assertOnNotParticipant(participant1.getFirstName()) + .assertOnNotParticipant(participant2.getFirstName()); + } /** * An author create a course with a participant folder course diff --git a/src/test/java/org/olat/selenium/page/course/MemberListConfigurationPage.java b/src/test/java/org/olat/selenium/page/course/MemberListConfigurationPage.java new file mode 100644 index 0000000000000000000000000000000000000000..8ba503f455816dd6b66a898dea331cadba8e3137 --- /dev/null +++ b/src/test/java/org/olat/selenium/page/course/MemberListConfigurationPage.java @@ -0,0 +1,82 @@ +/** + * <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; +import org.openqa.selenium.WebElement; + +/** + * + * Initial date: 7 juil. 2017<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class MemberListConfigurationPage { + + private final WebDriver browser; + + public MemberListConfigurationPage(WebDriver browser) { + this.browser = browser; + } + + public MemberListConfigurationPage selectSettings() { + By configBy = By.cssSelector("fieldset.o_sel_cmembers_settings"); + OOGraphene.selectTab(CourseEditorPageFragment.navBarNodeConfiguration, configBy, browser); + return this; + } + + public MemberListConfigurationPage setOwners(Boolean visible) { + return setMembers(visible, "members.owners"); + } + + public MemberListConfigurationPage setCoaches(Boolean visible) { + return setMembers(visible, "coaches"); + } + + public MemberListConfigurationPage setParticipants(Boolean visible) { + return setMembers(visible, "participants"); + } + + private MemberListConfigurationPage setMembers(Boolean visible, String type) { + By checkboxBy = By.xpath("//fieldset[contains(@class,'o_sel_cmembers_settings')]//input[@type='checkbox'][@name='" + type + "']"); + By labelBy = By.xpath("//fieldset[contains(@class,'o_sel_cmembers_settings')]//label[input[@type='checkbox'][@name='" + type + "']]"); + WebElement checkboxEl = browser.findElement(checkboxBy); + WebElement labelEl = browser.findElement(labelBy); + OOGraphene.check(labelEl, checkboxEl, visible); + return this; + } + + public MemberListConfigurationPage setCourseCoachesOnly() { + By courseCoachBy = By.xpath("//fieldset[contains(@class,'o_sel_cmembers_settings')]//input[@type='radio'][@name='coachesChoice'][@value='course']"); + OOGraphene.waitElement(courseCoachBy, browser); + browser.findElement(courseCoachBy).click(); + OOGraphene.waitBusy(browser); + return this; + } + + public MemberListConfigurationPage save() { + By configBy = By.cssSelector("fieldset.o_sel_cmembers_settings button.btn-primary"); + OOGraphene.click(configBy, browser); + return this; + } + +} diff --git a/src/test/java/org/olat/selenium/page/course/MemberListPage.java b/src/test/java/org/olat/selenium/page/course/MemberListPage.java new file mode 100644 index 0000000000000000000000000000000000000000..250d2f6322f1ac6fd07b9321303b660f62d447dc --- /dev/null +++ b/src/test/java/org/olat/selenium/page/course/MemberListPage.java @@ -0,0 +1,89 @@ +/** + * <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.util.List; + +import org.junit.Assert; +import org.olat.selenium.page.graphene.OOGraphene; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + + +/** + * + * Initial date: 7 juil. 2017<br> + * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com + * + */ +public class MemberListPage { + + private final WebDriver browser; + + public MemberListPage(WebDriver browser) { + this.browser = browser; + } + + public MemberListPage assertOnMembers() { + By membersBy = By.cssSelector("div.o_cmembers"); + OOGraphene.waitElement(membersBy, browser); + return this; + } + + public MemberListPage assertOnOwner(String name) { + By ownerBy = By.xpath("//div[contains(@class,'o_sel_owners')]//div[@class='o_cmember_info_wrapper']/a/span[contains(text(),'" + name + "')]"); + OOGraphene.waitElement(ownerBy, browser); + return this; + } + + public MemberListPage assertOnNotOwner(String name) { + By ownerBy = By.xpath("//div[contains(@class,'o_sel_owners')]//div[@class='o_cmember_info_wrapper']/a/span[contains(text(),'" + name + "')]"); + List<WebElement> ownersEl = browser.findElements(ownerBy); + Assert.assertEquals(0, ownersEl.size()); + return this; + } + + public MemberListPage assertOnCoach(String name) { + By coachBy = By.xpath("//div[contains(@class,'o_sel_coaches')]//div[@class='o_cmember_info_wrapper']/a/span[contains(text(),'" + name + "')]"); + OOGraphene.waitElement(coachBy, browser); + return this; + } + + public MemberListPage assertOnNotCoach(String name) { + By coachBy = By.xpath("//div[contains(@class,'o_sel_coaches')]//div[@class='o_cmember_info_wrapper']/a/span[contains(text(),'" + name + "')]"); + List<WebElement> coachEls = browser.findElements(coachBy); + Assert.assertEquals(0, coachEls.size()); + return this; + } + + public MemberListPage assertOnParticipant(String name) { + By participantBy = By.xpath("//div[contains(@class,'o_sel_participants')]//div[@class='o_cmember_info_wrapper']/a/span[contains(text(),'" + name + "')]"); + OOGraphene.waitElement(participantBy, browser); + return this; + } + + public MemberListPage assertOnNotParticipant(String name) { + By participantBy = By.xpath("//div[contains(@class,'o_sel_participants')]//div[@class='o_cmember_info_wrapper']/a/span[contains(text(),'" + name + "')]"); + List<WebElement> participantEls = browser.findElements(participantBy); + Assert.assertEquals(0, participantEls.size()); + return this; + } +}