Search in sources :

Example 11 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class BusinessGroupTest method enrollmentWithUnlimitedBusinessGroups.

/**
 * Variant from the above test where the business group is not
 * limited in size. This was a bug while development of the 10.3
 * release.
 *
 * @param authorLoginPage
 * @param ryomouBrowser
 * @param reiBrowser
 * @param kanuBrowser
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void enrollmentWithUnlimitedBusinessGroups(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver ryomouBrowser, @Drone @Participant WebDriver reiBrowser, @Drone @Student WebDriver kanuBrowser) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("Rei");
    UserVO kanu = new UserRestClient(deploymentUrl).createRandomUser("kanu");
    UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou");
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    // create a course
    String courseTitle = "Enrollment-3-" + UUID.randomUUID();
    navBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
    // create a group in members management
    String groupName = "Enroll - " + UUID.randomUUID();
    CoursePageFragment authorCourse = CoursePageFragment.getCourse(browser);
    MembersPage membersPage = authorCourse.members().selectBusinessGroups().createBusinessGroup(groupName, "-", -1, false, false);
    // back to the members page
    navBar.openCourse(courseTitle);
    authorCourse = membersPage.clickToolbarBack();
    // create an enrollment course element
    String enNodeTitle = "Enroll - 3";
    CourseEditorPageFragment courseEditor = authorCourse.edit().createNode("en").nodeTitle(enNodeTitle);
    // select the group created above
    EnrollmentConfigurationPage enrolmentConfig = new EnrollmentConfigurationPage(browser);
    enrolmentConfig.selectConfiguration().selectBusinessGroups();
    // publish the course
    courseEditor.publish().quickPublish(UserAccess.registred);
    GroupPage authorGroup = navBar.openGroups(browser).selectGroup(groupName).openAdministration().openAdminMembers().setVisibility(false, true, false).openMembers().assertParticipantList();
    Enrollment[] participantDrivers = new Enrollment[] { new Enrollment(ryomou, ryomouBrowser), new Enrollment(rei, reiBrowser), new Enrollment(kanu, kanuBrowser) };
    for (Enrollment enrollment : participantDrivers) {
        WebDriver driver = enrollment.getDriver();
        LoginPage.getLoginPage(driver, deploymentUrl).loginAs(enrollment.getUser()).resume();
        NavigationPage participantNavBar = new NavigationPage(driver);
        participantNavBar.openMyCourses().openSearch().extendedSearch(courseTitle).select(courseTitle).start();
        // go to the enrollment
        CoursePageFragment participantCourse = new CoursePageFragment(driver);
        participantCourse.clickTree().selectWithTitle(enNodeTitle);
        EnrollmentPage enrollmentPage = new EnrollmentPage(driver);
        enrollmentPage.assertOnEnrolmentPage();
        enrollment.setEnrollmentPage(enrollmentPage);
    }
    // enroll
    for (Enrollment enrollment : participantDrivers) {
        enrollment.getEnrollmentPage().enrollNoWait();
    }
    // wait
    int errors = 0;
    for (Enrollment enrollment : participantDrivers) {
        if (enrollment.getEnrollmentPage().hasError()) {
            errors++;
        }
    }
    // author check the lists
    authorGroup.openMembers();
    // must a participant and 2 in waiting list
    int participants = 0;
    for (Enrollment enrollment : participantDrivers) {
        if (authorGroup.isInMembersParticipantList(enrollment.getUser())) {
            participants++;
        }
    }
    Assert.assertEquals(3, participants);
    Assert.assertEquals(0, errors);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) GroupPage(org.olat.selenium.page.group.GroupPage) CoursePageFragment(org.olat.selenium.page.course.CoursePageFragment) UserRestClient(org.olat.test.rest.UserRestClient) CourseEditorPageFragment(org.olat.selenium.page.course.CourseEditorPageFragment) UserVO(org.olat.user.restapi.UserVO) NavigationPage(org.olat.selenium.page.NavigationPage) EnrollmentPage(org.olat.selenium.page.course.EnrollmentPage) MembersPage(org.olat.selenium.page.course.MembersPage) EnrollmentConfigurationPage(org.olat.selenium.page.course.EnrollmentConfigurationPage) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 12 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class BusinessGroupTest method groupMembersVisibility.

/**
 * An author create a group, set the visibility to
 * show owners and participants. Add a member to the
 * group.
 *
 * The participant log in, search the group and open it.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void groupMembersVisibility(@InitialPage LoginPage loginPage, @Drone @Participant WebDriver participantBrowser) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createRandomUser("Selena");
    UserVO participant = new UserRestClient(deploymentUrl).createRandomUser("Aoi");
    loginPage.loginAs(author.getLogin(), author.getPassword()).resume();
    // go to groups
    String groupName = "Group-1-" + UUID.randomUUID();
    GroupPage group = navBar.openGroups(browser).createGroup(groupName, "A very little group");
    MembersWizardPage members = group.openAdministration().openAdminMembers().setVisibility(true, true, false).addMember();
    members.searchMember(participant, false).nextUsers().nextOverview().nextPermissions().finish();
    LoginPage participantLoginPage = LoginPage.getLoginPage(participantBrowser, deploymentUrl);
    // tools
    participantLoginPage.loginAs(participant.getLogin(), participant.getPassword()).resume();
    NavigationPage participantNavBar = new NavigationPage(participantBrowser);
    participantNavBar.openGroups(participantBrowser).selectGroup(groupName);
    WebElement contentEl = participantBrowser.findElement(By.id("o_main_center_content_inner"));
    String content = contentEl.getText();
    Assert.assertTrue(content.contains(groupName));
}
Also used : MembersWizardPage(org.olat.selenium.page.group.MembersWizardPage) UserVO(org.olat.user.restapi.UserVO) NavigationPage(org.olat.selenium.page.NavigationPage) GroupPage(org.olat.selenium.page.group.GroupPage) WebElement(org.openqa.selenium.WebElement) LoginPage(org.olat.selenium.page.LoginPage) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 13 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class BusinessGroupTest method enrollmentWithMultiEnrollment.

/**
 * An author create a course, with an enrollment course element. It
 * configure it and create 3 groups and set the maximum enrollment counter to 2<br>
 *
 * One user goes to the course and enrolls in 2 of the groups. It shouldent be possible
 * enroll in the third<br>
 *
 * @param authorLoginPage
 * @param ryomouBrowser
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void enrollmentWithMultiEnrollment(@InitialPage LoginPage authorLoginPage, @Drone @User WebDriver ryomouBrowser) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    authorLoginPage.loginAs(author.getLogin(), author.getPassword());
    UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou");
    // create a course
    String courseTitle = "Enrolment-3-" + UUID.randomUUID();
    navBar.openAuthoringEnvironment().createCourse(courseTitle).clickToolbarBack();
    // create a course element of type Enrolment
    String enNodeTitle = "Enrolment-3";
    CourseEditorPageFragment courseEditor = CoursePageFragment.getCourse(browser).edit();
    courseEditor.createNode("en").nodeTitle(enNodeTitle);
    // configure enrolment with a group that we create
    List<String> groups = new ArrayList<String>();
    groups.add("Enrolment group - 3 " + UUID.randomUUID());
    groups.add("Enrolment group - 3 " + UUID.randomUUID());
    groups.add("Enrolment group - 3 " + UUID.randomUUID());
    EnrollmentConfigurationPage enrolmentConfig = new EnrollmentConfigurationPage(browser);
    enrolmentConfig.selectConfiguration().createBusinessGroup(groups.get(0), "-", 4, false, false).createBusinessGroup(groups.get(1), "-", 4, false, false).createBusinessGroup(groups.get(2), "-", 4, false, false).selectMultipleEnrollments(2);
    // publish the course
    courseEditor.publish().quickPublish(UserAccess.registred);
    courseEditor.clickToolbarBack();
    for (String groupName : groups) {
        navBar.openGroups(browser).selectGroup(groupName).openAdministration().openAdminMembers().setVisibility(true, true, false).openMembers();
    }
    // Ryomou open the course
    LoginPage.getLoginPage(ryomouBrowser, deploymentUrl).loginAs(ryomou).resume();
    NavigationPage participantNavBar = new NavigationPage(ryomouBrowser);
    participantNavBar.openMyCourses().openSearch().extendedSearch(courseTitle).select(courseTitle).start();
    OOGraphene.waitBusy(ryomouBrowser);
    // go to the enrollment
    CoursePageFragment participantCourse = new CoursePageFragment(ryomouBrowser);
    participantCourse.clickTree().selectWithTitle(enNodeTitle);
    EnrollmentPage enrollmentPage = new EnrollmentPage(ryomouBrowser);
    enrollmentPage.assertOnEnrolmentPage().multiEnroll(2);
    // assert that that no more enrollment is allowed
    enrollmentPage.assertNoEnrollmentAllowed();
}
Also used : CourseEditorPageFragment(org.olat.selenium.page.course.CourseEditorPageFragment) UserVO(org.olat.user.restapi.UserVO) NavigationPage(org.olat.selenium.page.NavigationPage) EnrollmentPage(org.olat.selenium.page.course.EnrollmentPage) CoursePageFragment(org.olat.selenium.page.course.CoursePageFragment) ArrayList(java.util.ArrayList) EnrollmentConfigurationPage(org.olat.selenium.page.course.EnrollmentConfigurationPage) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 14 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class BusinessGroupTest method confirmMembershipByGroup.

/**
 * First, an administrator make in administration part
 * the confirmation of group's membership mandatory if
 * the group is created by a standard user.<br>
 *
 * A standard user create a group and add a participant.
 * The participant log-in and confirm its membership and
 * visit the group.<br>
 *
 * A first user log in, confirm the membership and search
 * the group.<br>
 *
 * A second user log in but with a rest url to the group
 * and jump to the group after confirming the membership.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void confirmMembershipByGroup(@InitialPage LoginPage loginPage, @Drone @User WebDriver ryomouBrowser, @Drone @Participant WebDriver participantBrowser, @Drone @Student WebDriver reiBrowser) throws IOException, URISyntaxException {
    UserVO ryomou = new UserRestClient(deploymentUrl).createRandomUser("Ryomou");
    UserVO rei = new UserRestClient(deploymentUrl).createRandomUser("Rei");
    UserVO participant = new UserRestClient(deploymentUrl).createRandomUser();
    // admin make the confirmation of membership mandatory
    // for groups created by standard users.
    loginPage.loginAs("administrator", "openolat").resume();
    AdministrationPage administration = new NavigationPage(browser).openAdministration().openGroupSettings().setGroupConfirmationForUser(true);
    // a standard user create a group
    LoginPage ryomouLoginPage = LoginPage.getLoginPage(ryomouBrowser, deploymentUrl);
    ryomouLoginPage.loginAs(ryomou.getLogin(), ryomou.getPassword()).resume();
    // go to groups
    String groupName = "Group-1-" + UUID.randomUUID();
    NavigationPage rymouNavBar = new NavigationPage(ryomouBrowser);
    GroupPage group = rymouNavBar.openGroups(ryomouBrowser).createGroup(groupName, "Confirmation group");
    String groupUrl = group.openAdministration().getGroupURL();
    group.openAdminMembers().addMember().searchMember(participant, false).nextUsers().nextOverview().nextPermissions().finish();
    group.addMember().searchMember(rei, false).nextUsers().nextOverview().nextPermissions().finish();
    // participant login
    LoginPage participantLoginPage = LoginPage.getLoginPage(participantBrowser, deploymentUrl);
    participantLoginPage.loginAs(participant.getLogin(), participant.getPassword()).assertOnMembershipConfirmation().confirmMembership();
    NavigationPage participantNavBar = new NavigationPage(participantBrowser);
    participantNavBar.openGroups(participantBrowser).selectGroup(groupName).assertOnInfosPage(groupName);
    // second participant log in with rest url
    reiBrowser.get(groupUrl);
    new LoginPage(reiBrowser).loginAs(rei.getLogin(), rei.getPassword()).assertOnMembershipConfirmation().confirmMembership();
    NavigationPage reiNavBar = new NavigationPage(reiBrowser);
    reiNavBar.openGroups(reiBrowser).selectGroup(groupName).assertOnInfosPage(groupName);
    // reset the settings
    administration.setGroupConfirmationForUser(false);
}
Also used : AdministrationPage(org.olat.selenium.page.core.AdministrationPage) UserVO(org.olat.user.restapi.UserVO) NavigationPage(org.olat.selenium.page.NavigationPage) GroupPage(org.olat.selenium.page.group.GroupPage) LoginPage(org.olat.selenium.page.LoginPage) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 15 with UserRestClient

use of org.olat.test.rest.UserRestClient in project OpenOLAT by OpenOLAT.

the class CourseTest method createCourse_withWizard.

/**
 * Create a course, use the course wizard, select all course
 * elements and go further with the standard settings.
 *
 * Go from the description editor to the course, check
 * that the course is automatically published and that
 * the five course elements are there.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void createCourse_withWizard(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    loginPage.loginAs(author.getLogin(), author.getPassword());
    // go to authoring
    AuthoringEnvPage authoringEnv = navBar.assertOnNavigationPage().openAuthoringEnvironment();
    String title = "Create-Course-Wizard-" + UUID.randomUUID().toString();
    // create course
    CourseWizardPage courseWizard = authoringEnv.openCreateDropDown().clickCreate(ResourceType.course).fillCreateFormAndStartWizard(title);
    courseWizard.selectAllCourseElements().nextNodes().nextCatalog().finish();
    // OOGraphene.closeErrorBox(browser);//STMP error
    RepositoryEditDescriptionPage editDescription = new RepositoryEditDescriptionPage(browser);
    // from description editor, back to details and launch the course
    editDescription.assertOnGeneralTab();
    // close mail error
    OOGraphene.closeErrorBox(browser);
    editDescription.clickToolbarBack();
    // open course editor
    CoursePageFragment course = CoursePageFragment.getCourse(browser);
    course.assertOnCoursePage().assertOnTitle(title);
    // assert the 5 nodes are there and click them
    By nodeBy = By.cssSelector("span.o_tree_link.o_tree_l1.o_tree_level_label_leaf>a");
    List<WebElement> nodes = browser.findElements(nodeBy);
    Assert.assertEquals(5, nodes.size());
    for (WebElement node : nodes) {
        node.click();
        OOGraphene.waitBusy(browser);
    }
}
Also used : UserVO(org.olat.user.restapi.UserVO) AuthoringEnvPage(org.olat.selenium.page.repository.AuthoringEnvPage) CourseWizardPage(org.olat.selenium.page.course.CourseWizardPage) CoursePageFragment(org.olat.selenium.page.course.CoursePageFragment) By(org.openqa.selenium.By) WebElement(org.openqa.selenium.WebElement) RepositoryEditDescriptionPage(org.olat.selenium.page.repository.RepositoryEditDescriptionPage) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)258 UserRestClient (org.olat.test.rest.UserRestClient)258 UserVO (org.olat.user.restapi.UserVO)258 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)254 NavigationPage (org.olat.selenium.page.NavigationPage)110 LoginPage (org.olat.selenium.page.LoginPage)108 CoursePageFragment (org.olat.selenium.page.course.CoursePageFragment)102 QTI21Page (org.olat.selenium.page.qti.QTI21Page)96 URL (java.net.URL)88 File (java.io.File)86 CourseEditorPageFragment (org.olat.selenium.page.course.CourseEditorPageFragment)84 UserToolsPage (org.olat.selenium.page.user.UserToolsPage)62 QTI21EditorPage (org.olat.selenium.page.qti.QTI21EditorPage)46 WebElement (org.openqa.selenium.WebElement)46 MembersPage (org.olat.selenium.page.course.MembersPage)36 AuthoringEnvPage (org.olat.selenium.page.repository.AuthoringEnvPage)34 GroupPage (org.olat.selenium.page.group.GroupPage)22 BinderPage (org.olat.selenium.page.portfolio.BinderPage)12 PortfolioV2HomePage (org.olat.selenium.page.portfolio.PortfolioV2HomePage)12 By (org.openqa.selenium.By)12