Search in sources :

Example 11 with ObjectEditPage

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

the class EditObjectsTest method testInlineObjectAddButton.

@Test
public void testInlineObjectAddButton() {
    ObjectEditPage oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.addObject("XWiki.XWikiUsers");
    oep.addObjectFromInlineLink("XWiki.XWikiUsers");
}
Also used : ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) Test(org.junit.Test)

Example 12 with ObjectEditPage

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

the class InvitationTest method testAcceptInvitationToClosedWiki.

/**
 * This test proves that:
 * 1. A guest cannot register if register permission is removed from XWikiPreferences.
 * 2. Upon receiving an email invitation the guest can register even without register permission.
 */
@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 testAcceptInvitationToClosedWiki() throws Exception {
    TestUtils.Session admin = getUtil().getSession();
    try {
        // First we ban anon from registering.
        ObjectEditPage oep = ObjectEditPage.gotoPage("XWiki", "XWikiPreferences");
        oep.getObjectsOfClass("XWiki.XWikiGlobalRights").get(0).getSelectElement(By.name("XWiki.XWikiGlobalRights_0_levels")).select("register");
        oep.clickSaveAndContinue();
        // now prove anon cannot register
        getUtil().forceGuestUser();
        RegistrationPage.gotoPage();
        getUtil().assertOnPage(getUtil().getURL("XWiki", "XWikiLogin", "login"));
        // Now we try sending and accepting an invitation.
        getUtil().setSession(admin);
        setSenderPage(InvitationSenderPage.gotoPage());
        getSenderPage().fillInDefaultValues();
        startGreenMail();
        getSenderPage().send();
        getGreenMail().waitForIncomingEmail(10000, 1);
        MimeMessage[] messages = getGreenMail().getReceivedMessages();
        String htmlMessage = getMessageContent(messages[0]).get("htmlPart");
        Assert.assertTrue("New invitation is not listed as pending in the footer.", getSenderPage().getFooter().myPendingInvitations() == 1);
        // Now switch to guest.
        getUtil().forceGuestUser();
        InvitationGuestActionsPage guestPage = InvitationGuestActionsPage.gotoPage(htmlMessage, InvitationGuestActionsPage.Action.ACCEPT);
        Assert.assertTrue("There was an error message when accepting the invitation message:\n" + guestPage.getMessage(), guestPage.getMessage().equals(""));
        // Register a new user.
        RegistrationPage rp = new RegistrationPage();
        rp.fillRegisterForm(null, null, "AnotherInvitedMember", "WeakPassword", "WeakPassword", null);
        rp.clickRegister();
        Assert.assertTrue("There were failure messages when registering.", rp.getValidationFailureMessages().isEmpty());
        getDriver().get(getUtil().getURLToLoginAs("AnotherInvitedMember", "WeakPassword"));
        Assert.assertTrue("Failed to log user in after registering from invitation.", rp.isAuthenticated());
    } finally {
        stopGreenMail();
        getUtil().setSession(admin);
        // Better open the wiki back up again.
        ObjectEditPage oep = ObjectEditPage.gotoPage("XWiki", "XWikiPreferences");
        oep.getObjectsOfClass("XWiki.XWikiGlobalRights").get(0).getSelectElement(By.name("XWiki.XWikiGlobalRights_0_levels")).unSelect("register");
        oep.clickSaveAndContinue();
    }
}
Also used : InvitationGuestActionsPage(org.xwiki.invitation.test.po.InvitationGuestActionsPage) RegistrationPage(org.xwiki.test.ui.po.RegistrationPage) TestUtils(org.xwiki.test.ui.TestUtils) MimeMessage(javax.mail.internet.MimeMessage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 13 with ObjectEditPage

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

the class EditObjectsTest method testEmptyGroupObjects.

/**
 * XWIKI-5832: Cannot create groups or add members to existing groups using the object editor.
 */
@Test
public void testEmptyGroupObjects() {
    // Create a doc
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add an XWikiGroups object
    ObjectEditPage oep = vp.editObjects();
    oep.addObject("XWiki.XWikiGroups");
    vp = oep.clickSaveAndView();
    oep = vp.editObjects();
    Assert.assertEquals(1, oep.getObjectsOfClass("XWiki.XWikiGroups").size());
}
Also used : ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) Test(org.junit.Test)

Example 14 with ObjectEditPage

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

the class EditObjectsTest method testChangeListMultipleSelect.

/**
 * Prove that a list can be changed from relational storage to plain storage and back without database corruption.
 * XWIKI-299 test
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeListMultipleSelect() {
    // 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(false);
    slcee.setValues("choice 1|choice 2|choice 3|choice 4|choice 5");
    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"), "choice 3");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: choice 3", vp.getContent());
    // Change list to a multiple select.
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getStaticListClassEditElement("prop").setMultiSelect(true);
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Verify conversion
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "choice 3");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "choice 4");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: choice 3 choice 4", 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 15 with ObjectEditPage

use of org.xwiki.test.ui.po.editor.ObjectEditPage 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)

Aggregations

ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)21 Test (org.junit.Test)15 ViewPage (org.xwiki.test.ui.po.ViewPage)11 FormElement (org.xwiki.test.ui.po.FormElement)9 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)9 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)8 ObjectEditPane (org.xwiki.test.ui.po.editor.ObjectEditPane)6 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)5 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)4 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)3 HashMap (java.util.HashMap)2 AbstractTest (org.xwiki.test.ui.AbstractTest)2 StaticListClassEditElement (org.xwiki.test.ui.po.editor.StaticListClassEditElement)2 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)1 MimeMessage (javax.mail.internet.MimeMessage)1 Before (org.junit.Before)1 TimeoutException (org.openqa.selenium.TimeoutException)1 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)1 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)1 LongTextClassFieldEditPane (org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane)1