Search in sources :

Example 16 with WikiEditPage

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

the class EditObjectsTest method testChangeMultiselectProperty.

/**
 * Tests that XWIKI-1621 remains fixed.
 */
@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 testChangeMultiselectProperty() {
    // Create a class with a database list property set to return all documents
    ClassEditPage cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.addProperty("prop", "DBList");
    cep.getDatabaseListClassEditElement("prop").setHibernateQuery("select doc.fullName from XWikiDocument doc where doc.space = 'Test'");
    cep.clickSaveAndView();
    // Create a second page to hold the Object and set its content
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add an object of the class created and set the value to be the test page
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
    objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "Test.EditObjectsTestClass");
    oep.clickSaveAndView();
    // Set multiselect to true
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getDatabaseListClassEditElement("prop").setMultiSelect(true);
    cep.clickSaveAndView();
    // Select a second document in the DB list select field.
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "Test.EditObjectsTestObject");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) 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) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 17 with WikiEditPage

use of org.xwiki.test.ui.po.editor.WikiEditPage 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 18 with WikiEditPage

use of org.xwiki.test.ui.po.editor.WikiEditPage 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 19 with WikiEditPage

use of org.xwiki.test.ui.po.editor.WikiEditPage 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 20 with WikiEditPage

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

the class LoginTest method testRedirectPreservesPOSTParameters.

@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 testRedirectPreservesPOSTParameters() {
    String test = "Test string " + System.currentTimeMillis();
    final String space = "Main";
    final String page = "POSTTest";
    LoginPage loginPage = this.vp.login();
    loginPage.loginAsAdmin();
    // start editing a page
    WikiEditPage editPage = WikiEditPage.gotoPage(space, page);
    editPage.setTitle(test);
    editPage.setContent(test);
    // emulate expired session: delete the cookies
    getDriver().manage().deleteAllCookies();
    // try to save
    editPage.clickSaveAndView();
    // we should have been redirected to login
    String wantUrl = getUtil().getURL("XWiki", "XWikiLogin", "login");
    if (wantUrl.indexOf('?') > 0) {
        // strip parameters
        wantUrl = wantUrl.substring(0, wantUrl.indexOf('?'));
    }
    Assert.assertTrue(getDriver().getCurrentUrl().startsWith(wantUrl));
    loginPage.loginAsAdmin();
    // we should have been redirected back to view, and the page should have been saved
    Assert.assertTrue(getDriver().getCurrentUrl().startsWith(getUtil().getURL(space, page)));
    editPage = WikiEditPage.gotoPage(space, page);
    Assert.assertEquals(test, editPage.getTitle());
    Assert.assertEquals(test, editPage.getContent());
}
Also used : WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) LoginPage(org.xwiki.test.ui.po.LoginPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Aggregations

WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)24 Test (org.junit.Test)20 ViewPage (org.xwiki.test.ui.po.ViewPage)17 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)8 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)8 AbstractTest (org.xwiki.test.ui.AbstractTest)6 FormElement (org.xwiki.test.ui.po.FormElement)6 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)5 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)4 HashMap (java.util.HashMap)3 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)3 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)2 AdministrationPage (org.xwiki.administration.test.po.AdministrationPage)2 LocalizationAdministrationSectionPage (org.xwiki.administration.test.po.LocalizationAdministrationSectionPage)2 NotificationsTrayPage (org.xwiki.platform.notifications.test.po.NotificationsTrayPage)2 NotificationsUserProfilePage (org.xwiki.platform.notifications.test.po.NotificationsUserProfilePage)2 CommentsTab (org.xwiki.test.ui.po.CommentsTab)2 CreatePagePage (org.xwiki.test.ui.po.CreatePagePage)2 HistoryPane (org.xwiki.test.ui.po.HistoryPane)2 LiveTableElement (org.xwiki.test.ui.po.LiveTableElement)2