Skip to content
Snippets Groups Projects
Commit 32b8c4f8 authored by srosse's avatar srosse
Browse files

no-jira: selenium test for free booking without user interaction

parent 56820a49
No related branches found
No related tags found
No related merge requests found
......@@ -61,14 +61,18 @@ public class FreeAccessConfigurationController extends AbstractConfigurationMeth
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_accesscontrol_free_form");
String desc = null;
if(link.getOffer() != null) {
desc = link.getOffer().getDescription();
}
descEl = uifactory.addTextAreaElement("offer-desc", "offer.description", 2000, 6, 80, false, desc, formLayout);
descEl.setElementCssClass("o_sel_accesscontrol_description");
String[] autoValues = new String[]{ translate("auto.booking.value") };
autoEl = uifactory.addCheckboxesHorizontal("auto.booking", "auto.booking", formLayout, autoKeys, autoValues);
autoEl.setElementCssClass("o_sel_accesscontrol_auto_booking");
if(link.getOffer() != null && link.getOffer().getKey() != null) {
autoEl.select(autoKeys[0], link.getOffer().isAutoBooking());
} else {
......
......@@ -871,6 +871,91 @@ public class CourseTest extends Deployments {
.assertFirstNameInList(ryomou);
}
/**
* An author creates a course, make it visible for
* members and add an access control by free booking
* with the auto booking enabled.<br/>
* The user search for the course and enters it.<br/>
* The author checks in the list of orders if the booking
* of the user is there and after it checks if the user is
* in the member list too.
*
* @param loginPage
* @param userBrowser
* @throws IOException
* @throws URISyntaxException
*/
@Test
@RunAsClient
public void courseFreeBooking(@InitialPage LoginPage loginPage,
@Drone @User WebDriver userBrowser)
throws IOException, URISyntaxException {
UserVO author = new UserRestClient(deploymentUrl).createAuthor();
loginPage.loginAs(author.getLogin(), author.getPassword());
UserVO user = new UserRestClient(deploymentUrl).createRandomUser("Kanu");
//go to authoring
AuthoringEnvPage authoringEnv = navBar
.assertOnNavigationPage()
.openAuthoringEnvironment();
String title = "AutoBooking-" + UUID.randomUUID();
//create course
authoringEnv
.openCreateDropDown()
.clickCreate(ResourceType.course)
.fillCreateForm(title)
.assertOnGeneralTab();
//open course editor
CoursePageFragment course = new CoursePageFragment(browser);
RepositoryAccessPage courseAccess = course
.openToolsMenu()
.edit()
.createNode("info")
.autoPublish()
.accessConfiguration()
.setUserAccess(UserAccess.registred);
//add booking by secret token
courseAccess
.boooking()
.openAddDropMenu()
.addFreeBooking()
.configureFreeBooking("It's free");
courseAccess
.clickToolbarBack();
//a user search the course
LoginPage userLoginPage = LoginPage.getLoginPage(userBrowser, deploymentUrl);
userLoginPage
.loginAs(user.getLogin(), user.getPassword())
.resume();
NavigationPage userNavBar = new NavigationPage(userBrowser);
userNavBar
.openMyCourses()
.openSearch()
.extendedSearch(title)
.book(title);//book the course
//check the course
CoursePageFragment bookedCourse = CoursePageFragment.getCourse(userBrowser);
bookedCourse
.assertOnTitle(title);
//Author go in the list of bookings of the course
BookingPage bookingList = course
.openToolsMenu()
.bookingTool();
bookingList
.assertFirstNameInListIsOk(user);
//Author go to members list
course
.members()
.assertFirstNameInList(user);
}
/**
* An author create a course, set a start and end date for life-cycle.
* It add a participant to the course. It creates a reminder
......
......@@ -71,10 +71,9 @@ public class BookingPage {
private BookingPage addMethod(String iconClassname) {
//wait menu
By addMenuBy = By.cssSelector("fieldset.o_ac_configuration ul.dropdown-menu");
OOGraphene.waitElement(addMenuBy, 5, browser);
By addMethodBy = By.xpath("//fieldset[contains(@class,'o_ac_configuration')]//ul[contains(@class,'dropdown-menu')]//a[//i[contains(@class,'" + iconClassname + "')]]");
WebElement methodLink = browser.findElement(addMethodBy);
methodLink.click();
OOGraphene.waitElement(addMenuBy, browser);
By addMethodBy = By.xpath("//fieldset[contains(@class,'o_ac_configuration')]//ul[contains(@class,'dropdown-menu')]//a[i[contains(@class,'" + iconClassname + "')]]");
browser.findElement(addMethodBy).click();
OOGraphene.waitBusy(browser);
return this;
}
......@@ -113,6 +112,33 @@ public class BookingPage {
OOGraphene.waitBusy(browser);
}
/**
* Select the free booking option
*
* @return Itself
*/
public BookingPage addFreeBooking() {
addMethod("o_ac_free_icon");
OOGraphene.waitModalDialog(browser);
return this;
}
/**
* Save the free booking.
*
* @param description The description of the booking.
* @return Itself
*/
public BookingPage configureFreeBooking(String description) {
By descriptionBy = By.cssSelector(".o_sel_accesscontrol_free_form .o_sel_accesscontrol_description textarea");
browser.findElement(descriptionBy).sendKeys(description);
By submitBy = By.cssSelector(".o_sel_accesscontrol_free_form button.btn-primary");
browser.findElement(submitBy).click();
OOGraphene.waitBusy(browser);
return this;
}
public void save() {
By saveButtonBy = By.cssSelector("form button.btn-primary");
browser.findElement(saveButtonBy).click();
......
......@@ -435,6 +435,15 @@ public class OOGraphene {
waitModalDialogDisappears(browser);
}
public static final void closeWarningBox(WebDriver browser) {
By errorBoxBy = By.cssSelector(".modal-body.alert.alert-warning");
waitElement(errorBoxBy, 5, browser);
By closeButtonBy = By.xpath("//div[not(@id='o_form_dirty_message')]/div[contains(@class,'modal-dialog')]//button[@class='close']");
waitElement(closeButtonBy, 5, browser);
browser.findElement(closeButtonBy).click();
waitModalDialogDisappears(browser);
}
public static final void waitAndCloseBlueMessageWindow(WebDriver browser) {
try {
Graphene.waitModel(browser).withTimeout(5, TimeUnit.SECONDS)
......
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