Search in sources :

Example 76 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class EditObjectsTest method testChangeListTypeRelationalStorage.

/**
 * Prove that a list can be changed from relational storage to plain storage and back without database corruption.
 * XWIKI-1621: Changing parameters of list properties fails
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeListTypeRelationalStorage() {
    // Create class page
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestClass");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add class
    ClassEditPage cep = vp.editClass();
    cep.addProperty("prop", "StaticList");
    StaticListClassEditElement slcee = cep.getStaticListClassEditElement("prop");
    slcee.setMultiSelect(true);
    slcee.setDisplayType(StaticListClassEditElement.DisplayType.INPUT);
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Create object page
    wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
    wep.setContent("this is the content: {{velocity}}$doc.display('prop'){{/velocity}}");
    vp = wep.clickSaveAndView();
    // Add object
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
    objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "this|that|other");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: this that other", vp.getContent());
    // Change list to relational storage.
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getStaticListClassEditElement("prop").setRelationalStorage(true);
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Make sure we can still edit the object.
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "this|other");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: this other", vp.getContent());
    // Change list to non-relational storage.
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getStaticListClassEditElement("prop").setRelationalStorage(false);
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Make sure we can still edit the object.
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "that|other");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: that other", vp.getContent());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) StaticListClassEditElement(org.xwiki.test.ui.po.editor.StaticListClassEditElement) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) FormElement(org.xwiki.test.ui.po.FormElement) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 77 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class KeyboardShortcutsTest method testKeyboardShortcuts.

@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testKeyboardShortcuts() {
    ViewPage vp = getUtil().gotoPage("Sandbox", "WebHome");
    // Test default edit mode (WYSIWYG for Sandbox.WebHome) key
    vp.sendKeys("e");
    // Test Cancel key
    vp.sendKeys(Keys.chord(Keys.ALT, "c"));
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInViewMode());
    // Test Wiki edit key
    vp.sendKeys("k");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInWikiEditMode());
    // Test WYSIWYG edit mode key
    vp = getUtil().gotoPage("Sandbox", "WebHome");
    vp.sendKeys("g");
    // Test Inline Form edit mode key
    vp = getUtil().gotoPage("Sandbox", "WebHome");
    vp.sendKeys("f");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInInlineEditMode());
    // Test Rights edit mode key on a terminal document
    vp = getUtil().gotoPage("Sandbox", "TestPage1");
    vp.sendKeys("r");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInRightsEditMode());
    // Test Rights edit mode key on a non terminal document
    vp = getUtil().gotoPage("Sandbox", "WebHome");
    vp.sendKeys("r");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInAdminMode());
    AdministrationPage administrationPage = new AdministrationPage();
    Assert.assertTrue(administrationPage.hasSection("PageRights"));
    // Test Object edit mode key
    vp = getUtil().gotoPage("Sandbox", "WebHome");
    vp.sendKeys("o");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInObjectEditMode());
    // Test Class edit mode key
    vp = getUtil().gotoPage("Sandbox", "WebHome");
    vp.sendKeys("s");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInClassEditMode());
    // Test Delete key
    vp = getUtil().gotoPage("Sandbox", "WebHome");
    vp.sendKeys(Keys.DELETE);
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInDeleteMode());
    // Test Rename key
    vp = getUtil().gotoPage("Sandbox", "WebHome");
    vp.sendKeys(Keys.F2);
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInRenameMode());
    // Test View Source key
    vp = getUtil().gotoPage("Sandbox", "WebHome");
    vp.sendKeys("d");
    vp.waitUntilPageIsLoaded();
    Assert.assertTrue(getUtil().isInSourceViewMode());
}
Also used : AdministrationPage(org.xwiki.administration.test.po.AdministrationPage) ViewPage(org.xwiki.test.ui.po.ViewPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 78 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class LanguageTest method testChangeLanguageInMonolingualModeUsingTheAdministrationPreference.

@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeLanguageInMonolingualModeUsingTheAdministrationPreference() {
    WikiEditPage edit = WikiEditPage.gotoPage("Test", "LanguageTest");
    edit.setContent("{{velocity}}context = ($xcontext.language), doc = ($doc.language), " + "default = ($doc.defaultLanguage), tdoc = ($tdoc.language), " + "tdocdefault = ($tdoc.defaultLanguage){{/velocity}}");
    ViewPage vp = edit.clickSaveAndView();
    // Current language must be "en"
    Assert.assertEquals("Invalid content", vp.getContent(), "context = (en), doc = (), default = (en), tdoc = (), tdocdefault = (en)");
    // Change default language to "fr"
    AdministrationPage adminPage = AdministrationPage.gotoPage();
    LocalizationAdministrationSectionPage sectionPage = adminPage.clickLocalizationSection();
    sectionPage.setDefaultLanguage("fr");
    sectionPage.clickSave();
    // Now language must be "fr"
    vp = getUtil().gotoPage("Test", "LanguageTest");
    Assert.assertTrue("Page not in French!", isPageInFrench());
    Assert.assertEquals("Invalid content", vp.getContent(), "context = (fr), doc = (), default = (en), tdoc = (), tdocdefault = (en)");
}
Also used : LocalizationAdministrationSectionPage(org.xwiki.administration.test.po.LocalizationAdministrationSectionPage) AdministrationPage(org.xwiki.administration.test.po.AdministrationPage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 79 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class LanguageTest method testTranslateDocument.

@Test
public void testTranslateDocument() throws Exception {
    LocalDocumentReference referenceDEFAULT = new LocalDocumentReference("LanguageTest", "Page");
    LocalDocumentReference referenceFR = new LocalDocumentReference(referenceDEFAULT, Locale.FRENCH);
    // Cleanup
    getUtil().rest().delete(referenceFR);
    getUtil().rest().delete(referenceDEFAULT);
    // Set 2 locales
    setLanguageSettings(true, "en", Arrays.asList("en", "fr"));
    // Create default version
    ViewPage viewPage = getUtil().createPage("LanguageTest", "Page", "en content", "en title");
    // Edit the page
    WikiEditPage editPage = viewPage.editWiki();
    // Make sure current translation is the right one
    assertTrue(getDriver().hasElement(By.xpath("//strong[text()='You are editing the original page (en).']")));
    assertEquals(Arrays.asList(Locale.FRENCH), editPage.getNotExistingLocales());
    assertEquals(Arrays.asList(), editPage.getExistingLocales());
    // Translated to French
    editPage = editPage.clickTranslate("fr");
    editPage.setTitle("titre fr");
    editPage.setContent("contenu fr");
    viewPage = editPage.clickSaveAndView();
    // Make sure both have the right content
    Page page = getUtil().rest().get(referenceFR);
    assertEquals("titre fr", page.getTitle());
    assertEquals("contenu fr", page.getContent());
    page = getUtil().rest().get(referenceDEFAULT);
    assertEquals("en title", page.getTitle());
    assertEquals("en content", page.getContent());
    // Make sure two locales are listed for this page in the UI
    assertEquals(new HashSet<>(Arrays.asList(Locale.ENGLISH, Locale.FRENCH)), new HashSet<>(viewPage.getLocales()));
    // Switch to en
    viewPage.clickLocale(Locale.ENGLISH);
    // Verify edit mode informations
    editPage = viewPage.editWiki();
    assertEquals(Arrays.asList(), editPage.getNotExistingLocales());
    assertEquals(Arrays.asList(Locale.FRENCH), editPage.getExistingLocales());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) LocalizationAdministrationSectionPage(org.xwiki.administration.test.po.LocalizationAdministrationSectionPage) Page(org.xwiki.rest.model.jaxb.Page) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) AdministrationPage(org.xwiki.administration.test.po.AdministrationPage) ViewPage(org.xwiki.test.ui.po.ViewPage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) Test(org.junit.Test)

Example 80 with ViewPage

use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.

the class LoginTest method testRedirectBackAfterLogin.

/**
 * Verify that the initial URL is not lost after logging in when the session has expired.
 * See XWIKI-5317.
 */
@Test
public void testRedirectBackAfterLogin() {
    try {
        // Test setup: disallow view right for unauthenticated users. We need to be logged as admin in order to
        // do that. Since this is not what we are testing use the fast way to log in
        GlobalRightsAdministrationSectionPage grasp = new GlobalRightsAdministrationSectionPage();
        getDriver().get(getUtil().getURLToLoginAsAdminAndGotoPage(grasp.getURL()));
        getUtil().recacheSecretToken();
        getUtil().setDefaultCredentials(TestUtils.ADMIN_CREDENTIALS);
        grasp.forceAuthenticatedView();
        // Go to a page, log out and expire session by removing cookies, log in again and verify that the user is
        // redirected to the initial page.
        ViewPage page = getUtil().gotoPage("SomeSpace", "SomePage");
        page.logout();
        // Since view is disallowed for unauthenticated users, at this point we see a log in page.
        LoginPage loginPage = new LoginPage();
        // Remove all cookie to simulate a session expiry
        getDriver().manage().deleteAllCookies();
        loginPage.loginAsAdmin();
        // We use startsWith since the URL contains a jsessionid and a srid.
        Assert.assertTrue(getDriver().getCurrentUrl().startsWith(getUtil().getURL("SomeSpace", "SomePage")));
    } finally {
        GlobalRightsAdministrationSectionPage grasp = GlobalRightsAdministrationSectionPage.gotoPage();
        if (!grasp.isAuthenticated()) {
            getDriver().get(getUtil().getURLToLoginAsAdminAndGotoPage(grasp.getURL()));
        }
        grasp.unforceAuthenticatedView();
    }
}
Also used : GlobalRightsAdministrationSectionPage(org.xwiki.administration.test.po.GlobalRightsAdministrationSectionPage) ViewPage(org.xwiki.test.ui.po.ViewPage) LoginPage(org.xwiki.test.ui.po.LoginPage) Test(org.junit.Test)

Aggregations

ViewPage (org.xwiki.test.ui.po.ViewPage)93 Test (org.junit.Test)75 AbstractTest (org.xwiki.test.ui.AbstractTest)41 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)26 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)18 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)11 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)10 DocumentReference (org.xwiki.model.reference.DocumentReference)8 CreatePagePage (org.xwiki.test.ui.po.CreatePagePage)8 FormElement (org.xwiki.test.ui.po.FormElement)7 HistoryPane (org.xwiki.test.ui.po.HistoryPane)7 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)7 WebElement (org.openqa.selenium.WebElement)6 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)6 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)6 URL (java.net.URL)5 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)5 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)5 ExtensionId (org.xwiki.extension.ExtensionId)5 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)5