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

no-jira: selenium test for the member list course element

parent 983402a1
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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
......
/**
* <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;
}
}
/**
* <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;
}
}
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