Search in sources :

Example 66 with UserRestClient

use of org.olat.test.rest.UserRestClient in project openolat by klemens.

the class PortfolioV2Test method editPage.

/**
 * A user create a page / entry, it edit it
 * and add a title, an image, a document
 * and a citation. It toggles between the editor
 * mode and the view mode to check if the parts it
 * add in the page are really there.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void editPage(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser("rei");
    loginPage.loginAs(user.getLogin(), user.getPassword()).resume();
    UserToolsPage userTools = new UserToolsPage(browser);
    PortfolioV2HomePage portfolio = userTools.openUserToolsMenu().openPortfolioV2();
    String pageTitle = "My page " + UUID.randomUUID();
    EntryPage entry = portfolio.openMyEntries().newPage(pageTitle).assertOnPage(pageTitle);
    // add a title
    String title = "My long title " + UUID.randomUUID();
    entry.addTitle(title).setTitleSize(4).closeEditFragment().assertOnTitle(title, 4);
    // add an image
    URL imageUrl = JunitTestHelper.class.getResource("file_resources/IMG_1484.jpg");
    File imageFile = new File(imageUrl.toURI());
    entry.addImage("Blue is the new black", imageFile).assertOnImage(imageFile);
    // close the editor and check
    entry.toggleEditor().assertOnTitle(title, 4).assertOnImage(imageFile);
    // reopen the editor and add a document
    URL pdfUrl = JunitTestHelper.class.getResource("file_resources/handInTopic1.pdf");
    File pdfFile = new File(pdfUrl.toURI());
    entry.toggleEditor().addDocument("Anything about", pdfFile).assertOnDocument(pdfFile);
    // and a citation
    String citation = "Close the world, open the next.";
    entry.addCitation("Serial experiment", citation).assertOnCitation(citation);
    // close the editor and check all parts
    entry.toggleEditor().assertOnTitle(title, 4).assertOnImage(imageFile).assertOnDocument(pdfFile).assertOnCitation(citation);
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) PortfolioV2HomePage(org.olat.selenium.page.portfolio.PortfolioV2HomePage) EntryPage(org.olat.selenium.page.portfolio.EntryPage) File(java.io.File) URL(java.net.URL) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 67 with UserRestClient

use of org.olat.test.rest.UserRestClient in project openolat by klemens.

the class PortfolioV2Test method collectWikiMediaInWikiResource.

/**
 * Create a wiki as resource, add and fill a page. The author
 * picks the page as media and go in its media center to see it.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void collectWikiMediaInWikiResource(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    UserVO author = new UserRestClient(deploymentUrl).createAuthor();
    loginPage.loginAs(author.getLogin(), author.getPassword()).resume();
    // go to authoring
    AuthoringEnvPage authoringEnv = navBar.assertOnNavigationPage().openAuthoringEnvironment();
    String title = "PF-Wiki-" + UUID.randomUUID();
    // create a wiki and launch it
    authoringEnv.openCreateDropDown().clickCreate(ResourceType.wiki).fillCreateForm(title).assertOnGeneralTab().clickToolbarBack();
    // create a page in the wiki
    String page = "LMS-" + UUID.randomUUID();
    String content = "Learning Management System";
    WikiPage wiki = WikiPage.getWiki(browser);
    // create page and add it as artefact to portfolio
    String mediaTitle = "My own wiki page";
    wiki.createPage(page, content).addAsMedia().fillForumMedia(mediaTitle, "A post I write");
    UserToolsPage userTools = new UserToolsPage(browser);
    MediaCenterPage mediaCenter = userTools.openUserToolsMenu().openPortfolioV2().openMediaCenter();
    mediaCenter.assertOnMedia(mediaTitle).selectMedia(mediaTitle).assertOnMediaDetails(mediaTitle);
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) AuthoringEnvPage(org.olat.selenium.page.repository.AuthoringEnvPage) WikiPage(org.olat.selenium.page.wiki.WikiPage) MediaCenterPage(org.olat.selenium.page.portfolio.MediaCenterPage) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 68 with UserRestClient

use of org.olat.test.rest.UserRestClient in project openolat by klemens.

the class UserTest method restUrlAfterLogin.

/**
 * Check if a user can use the rest url in OpenOLAT.
 * It jump from the static sites to its home, user tools,
 * to the visiting card of an other user.
 *
 * @param loginPage
 * @param authorBrowser
 * @param participantBrowser
 * @param reiBrowser
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void restUrlAfterLogin(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserRestClient userClient = new UserRestClient(deploymentUrl);
    UserVO user = userClient.createRandomUser("Kanu");
    UserVO ryomou = userClient.createRandomUser("Ryomou");
    // load dmz
    loginPage.assertOnLoginPage().loginAs(user.getLogin(), user.getPassword());
    // go to courses
    navBar.openMyCourses();
    // use url to go to the other users business card
    String ryomouBusinessCardUrl = deploymentUrl.toString() + "auth/Identity/" + ryomou.getKey();
    browser.get(ryomouBusinessCardUrl);
    new VisitingCardPage(browser).assertOnVisitingCard().assertOnLastName(ryomou.getLastName());
    // return to my courses
    navBar.openMyCourses().assertOnMyCourses();
    // go to profile by url
    String userUrl = deploymentUrl.toString() + "url/Identity/" + user.getKey();
    browser.get(userUrl);
    new UserProfilePage(browser).assertOnProfile().assertOnUsername(user.getLogin());
    // go to groups
    String groupsUrl = deploymentUrl.toString() + "url/GroupsSite/0/AllGroups/0";
    browser.get(groupsUrl);
    new GroupsPage(browser).assertOnMyGroupsSelected();
    // go to my calendar
    String calendarUrl = deploymentUrl.toString() + "auth/HomeSite/0/calendar/0";
    browser.get(calendarUrl);
    new UserToolsPage(browser).assertOnCalendar();
    // go to my folder
    String folderUrl = deploymentUrl.toString() + "auth/HomeSite/" + user.getKey() + "/userfolder/0";
    browser.get(folderUrl);
    new UserToolsPage(browser).assertOnFolder();
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) UserProfilePage(org.olat.selenium.page.user.UserProfilePage) VisitingCardPage(org.olat.selenium.page.user.VisitingCardPage) UserRestClient(org.olat.test.rest.UserRestClient) GroupsPage(org.olat.selenium.page.group.GroupsPage) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 69 with UserRestClient

use of org.olat.test.rest.UserRestClient in project openolat by klemens.

the class UserTest method loginInHomeWithRestUrl.

/**
 * Jump to notifications in home, go to the courses and return
 * to home's notification with a REST url.
 *
 * @see https://jira.openolat.org/browse/OO-1962
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
@RunAsClient
public void loginInHomeWithRestUrl(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserRestClient userClient = new UserRestClient(deploymentUrl);
    UserVO user = userClient.createRandomUser();
    // load dmz
    loginPage.assertOnLoginPage();
    String jumpToNotificationsUrl = deploymentUrl.toString() + "url/HomeSite/" + user.getKey() + "/notifications/0";
    browser.get(jumpToNotificationsUrl);
    loginPage.loginAs(user.getLogin(), user.getPassword());
    // must see the notification
    new UserToolsPage(browser).assertOnNotifications();
    // go to courses
    navBar.openMyCourses();
    // use url to go to notifications
    String goToNotificationsUrl = deploymentUrl.toString() + "auth/HomeSite/" + user.getKey() + "/notifications/0";
    browser.get(goToNotificationsUrl);
    // must see the notification
    new UserToolsPage(browser).assertOnNotifications();
}
Also used : UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) UserRestClient(org.olat.test.rest.UserRestClient) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test)

Example 70 with UserRestClient

use of org.olat.test.rest.UserRestClient in project openolat by klemens.

the class UserTest method resumeCourseOnDemand.

/**
 * Set the resume preferences to resume the session on request,
 * open a course, log out, log in, resume the session and check
 * if the course is resumed.
 *
 * @param loginPage
 * @throws IOException
 * @throws URISyntaxException
 */
@Test
public void resumeCourseOnDemand(@InitialPage LoginPage loginPage) throws IOException, URISyntaxException {
    // create a random user
    UserVO user = new UserRestClient(deploymentUrl).createRandomUser();
    // deploy a course
    CourseVO course = new RepositoryRestClient(deploymentUrl).deployDemoCourse();
    // login
    loginPage.loginAs(user.getLogin(), user.getPassword());
    // set the preferences to resume automatically
    UserToolsPage userTools = new UserToolsPage(browser);
    userTools.openUserToolsMenu().openMySettings().openPreferences().setResume(ResumeOption.ondemand);
    // open a course via REST url and click it
    CoursePageFragment.getCourse(browser, deploymentUrl, course).clickTree();
    // logout
    userTools.logout();
    // login again
    loginPage.assertOnLoginPage().loginAs(user.getLogin(), user.getPassword());
    // resume
    loginPage.resumeWithAssert();
    // check the title of the course if any
    WebElement courseTitle = browser.findElement(By.tagName("h2"));
    Assert.assertNotNull(courseTitle);
    Assert.assertTrue(courseTitle.isDisplayed());
    Assert.assertTrue(courseTitle.getText().contains(course.getTitle()));
}
Also used : RepositoryRestClient(org.olat.test.rest.RepositoryRestClient) CourseVO(org.olat.restapi.support.vo.CourseVO) UserToolsPage(org.olat.selenium.page.user.UserToolsPage) UserVO(org.olat.user.restapi.UserVO) WebElement(org.openqa.selenium.WebElement) UserRestClient(org.olat.test.rest.UserRestClient) 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