Search in sources :

Example 11 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class EditObjectsTest method testChangeNumberType.

/**
 * Tests that XWIKI-2214 remains fixed.
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeNumberType() {
    // 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", "Number");
    cep.getNumberClassEditElement("prop").setNumberType("integer");
    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"), "3");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 3", vp.getContent());
    // Change number to double type
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getNumberClassEditElement("prop").setNumberType("double");
    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"), "2.5");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 2.5", vp.getContent());
    // Change number to long type
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getNumberClassEditElement("prop").setNumberType("long");
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Verify conversion
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 2", 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) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 12 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class AnnotationsTest method annotationsShouldNotBeShownInXWiki10Syntax.

/**
 * This test creates a XWiki 1.0 syntax page, and tries to add annotations to it, and checks if the warning messages
 * are shown This test is against XAANNOTATIONS-17
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177")
public void annotationsShouldNotBeShownInXWiki10Syntax() {
    getUtil().deletePage(getTestClassName(), getTestMethodName());
    // Note: Make sure Annotations and Comments are merged (this is not the default ATM!) by setting the
    // $showannotation velocity variable to false in the page content
    AnnotatableViewPage annotatableViewPage = new AnnotatableViewPage(getUtil().createPage(getTestClassName(), getTestMethodName(), "#set ($showannotations = false)\nSome content", "AnnotationsTest in XWiki 1.0 Syntax", "xwiki/1.0"));
    annotatableViewPage.showAnnotationsPane();
    // Annotations are disabled in 1.0 Pages. This element should no be here
    Assert.assertTrue(annotatableViewPage.checkIfAnnotationsAreDisabled());
    annotatableViewPage.simulateCTRL_M();
    annotatableViewPage.waitforAnnotationWarningNotification();
}
Also used : AnnotatableViewPage(org.xwiki.annotation.test.po.AnnotatableViewPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 13 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class AutoWatchTest method testAutomaticWatchDefaultAndNone.

@Test
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177")
public void testAutomaticWatchDefaultAndNone() {
    /*
         * Scenario 1: 'Default' autowatch mode should watch new and modified documents.
         */
    WatchlistUserProfilePage watchlistPage = WatchlistUserProfilePage.gotoPage(testUserName);
    String newPageName1 = "testpage";
    // Ensure the pages are not already watched.
    Assert.assertFalse("The test page should not be already watched when just starting", watchlistPage.getWatchlistMacro().isWatched(this.testSpace, newPageName1));
    Assert.assertFalse("The test page should not be already watched when just starting", watchlistPage.getWatchlistMacro().isWatched(this.testSpace, this.existingPageName));
    // Set to 'default' automatic watch mode.
    WatchlistPreferencesEditPage preferences = watchlistPage.editPreferences();
    preferences.setAutomaticWatchDefault();
    preferences.clickSaveAndContinue();
    // Create the new page and modify the existing one.
    getUtil().createPage(this.testSpace, newPageName1, null, null);
    getUtil().gotoPage(this.testSpace, this.existingPageName, "save", "content", "Test content");
    // Go back to watchlist profile.
    watchlistPage = WatchlistUserProfilePage.gotoPage(testUserName);
    // Check if they are registered in the watchlist.
    Assert.assertTrue("Newly created page is not watched", watchlistPage.getWatchlistMacro().isWatched(this.testSpace, newPageName1));
    Assert.assertTrue("Newly created page is not watched", watchlistPage.getWatchlistMacro().isWatched(this.testSpace, this.existingPageName));
    /*
         * Scenario 2: 'None' autowatch mode should not watch new or modified documents.
         */
    String newPageName2 = "testpage2";
    // Cleanup from the previous test. Assume the existing page is unwatched.
    watchlistPage.getWatchlistMacro().unWatch(this.testSpace, this.existingPageName);
    // Ensure the pages are not already watched.
    Assert.assertFalse("The test page should not be already watched when just starting", watchlistPage.getWatchlistMacro().isWatched(this.testSpace, newPageName2));
    Assert.assertFalse("The test page should not be already watched when just starting", watchlistPage.getWatchlistMacro().isWatched(this.testSpace, this.existingPageName));
    // Set to 'none' automatic watch mode.
    preferences = watchlistPage.editPreferences();
    preferences.setAutomaticWatchNone();
    preferences.clickSaveAndContinue();
    // Create the new page and modify the existing one.
    getUtil().createPage(this.testSpace, newPageName2, null, null);
    getUtil().gotoPage(this.testSpace, this.existingPageName, "save", "content", "Test content");
    // Go back to watchlist profile
    watchlistPage = WatchlistUserProfilePage.gotoPage(testUserName);
    // Check if it's registered in the watchlist
    Assert.assertFalse("Newly created page is watched even if autowatch is set to 'none'", watchlistPage.getWatchlistMacro().isWatched(this.testSpace, newPageName2));
    Assert.assertFalse("Modified page is watched even if autowatch is set to 'none'", watchlistPage.getWatchlistMacro().isWatched(this.testSpace, this.existingPageName));
}
Also used : WatchlistUserProfilePage(org.xwiki.watchlist.test.po.WatchlistUserProfilePage) WatchlistPreferencesEditPage(org.xwiki.watchlist.test.po.editor.WatchlistPreferencesEditPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 14 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class InvitationTest method testNonAdminCanSend.

@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testNonAdminCanSend() throws Exception {
    TestUtils.Session s = getUtil().getSession();
    try {
        getUtil().forceGuestUser();
        getUtil().createUserAndLogin("NonMailAdminUser", "WeakPassword");
        setSenderPage(InvitationSenderPage.gotoPage());
        startGreenMail();
        getSenderPage().fillForm("user@localhost.localdomain", null, null);
        InvitationSenderPage.InvitationSentPage sent = getSenderPage().send();
        // Prove that the message was sent.
        getGreenMail().waitForIncomingEmail(10000, 1);
        MimeMessage[] messages = getGreenMail().getReceivedMessages();
        Map<String, String> message = getMessageContent(messages[0]);
        Assert.assertTrue(message.get("recipient").contains("user@localhost.localdomain"));
        assertMessageValid(message);
        // Check that the page has the table and the message.
        Assert.assertTrue(sent.getMessageBoxContent().contains("Your message has been sent."));
        TableElement table = sent.getTable();
        Assert.assertTrue(table.numberOfRows() == 2);
        Assert.assertTrue(table.numberOfColumns() == 3);
        Assert.assertTrue(table.getRow(1).get(1).getText().contains("user@localhost.localdomain"));
        Assert.assertTrue(table.getRow(1).get(2).getText().contains("Pending"));
    } finally {
        stopGreenMail();
        getUtil().setSession(s);
        getUtil().rest().deletePage("XWiki", "NonMailAdminUser");
    }
}
Also used : TestUtils(org.xwiki.test.ui.TestUtils) MimeMessage(javax.mail.internet.MimeMessage) InvitationSenderPage(org.xwiki.invitation.test.po.InvitationSenderPage) TableElement(org.xwiki.test.ui.po.TableElement) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 15 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class InvitationTest method testSendManyToOneAddress.

/**
 * This test proves that:
 * 1. A user cannot send to the same address multiple (8000) times which would be very annoying for the recipient.
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177")
public void testSendManyToOneAddress() throws Exception {
    TestUtils.Session admin = getUtil().getSession();
    try {
        // Allow users to send to multiple.
        AdministrationSectionPage config = AdministrationSectionPage.gotoPage("Invitation");
        config.getForm().setFieldValue(By.id("Invitation.InvitationConfig_Invitation.WebHome_0_" + "usersMaySendToMultiple"), "true");
        config.clickSave();
        // Now switch to a wizeguy user
        getUtil().forceGuestUser();
        getUtil().createUserAndLogin("tr0ll", "StrongPassword");
        setSenderPage(InvitationSenderPage.gotoPage());
        startGreenMail();
        getSenderPage().fillForm("user@localhost.localdomain user@localhost.localdomain " + "user@localhost.localdomain user@localhost.localdomain", null, null);
        getSenderPage().send();
        getGreenMail().waitForIncomingEmail(10000, 1);
        MimeMessage[] messages = getGreenMail().getReceivedMessages();
        Assert.assertTrue("One user is able to send multiple messages to the same poor recipient.", messages.length == 1);
    } finally {
        stopGreenMail();
        getUtil().setSession(admin);
        getUtil().rest().deletePage("XWiki", "tr0ll");
    }
}
Also used : TestUtils(org.xwiki.test.ui.TestUtils) AdministrationSectionPage(org.xwiki.administration.test.po.AdministrationSectionPage) MimeMessage(javax.mail.internet.MimeMessage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Aggregations

Test (org.junit.Test)22 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)22 AbstractTest (org.xwiki.test.ui.AbstractTest)12 ViewPage (org.xwiki.test.ui.po.ViewPage)10 AddTagsPane (org.xwiki.tag.test.po.AddTagsPane)5 FormElement (org.xwiki.test.ui.po.FormElement)5 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)5 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)5 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)4 MimeMessage (javax.mail.internet.MimeMessage)3 CopyPage (org.xwiki.index.test.po.CopyPage)2 InvitationSenderPage (org.xwiki.invitation.test.po.InvitationSenderPage)2 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)2 TaggablePage (org.xwiki.tag.test.po.TaggablePage)2 TestUtils (org.xwiki.test.ui.TestUtils)2 CopyOrRenameStatusPage (org.xwiki.test.ui.po.CopyOrRenameStatusPage)2 DocumentPicker (org.xwiki.test.ui.po.DocumentPicker)2 TableElement (org.xwiki.test.ui.po.TableElement)2 StaticListClassEditElement (org.xwiki.test.ui.po.editor.StaticListClassEditElement)2 AdministrationPage (org.xwiki.administration.test.po.AdministrationPage)1