Search in sources :

Example 46 with ViewPage

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

the class LoginTest method testDataIsPreservedAfterLogin.

@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 testDataIsPreservedAfterLogin() {
    getUtil().gotoPage("Test", "TestData", "save", "content=this+should+not+be+saved");
    getUtil().gotoPage("Test", "TestData", "save", "content=this+should+be+saved+instead&parent=Main.WebHome");
    LoginPage loginPage = new LoginPage();
    loginPage.loginAsAdmin();
    // we switched to another user, CSRF protection (if enabled) will ask for confirmation
    ResubmissionPage resubmissionPage = new ResubmissionPage();
    if (resubmissionPage.isOnResubmissionPage()) {
        resubmissionPage.resubmit();
    }
    Assert.assertTrue(getDriver().getCurrentUrl().contains("/xwiki/bin/view/Test/TestData"));
    ViewPage viewPage = new ViewPage();
    Assert.assertEquals("this should be saved instead", viewPage.getContent());
}
Also used : ResubmissionPage(org.xwiki.test.ui.po.ResubmissionPage) ViewPage(org.xwiki.test.ui.po.ViewPage) LoginPage(org.xwiki.test.ui.po.LoginPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 47 with ViewPage

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

the class LoginTest method setUp.

@Before
public void setUp() {
    // Force log out (we're using the fast way since this is not part of what we want to test)
    getUtil().forceGuestUser();
    // Go to any page in view mode. We choose to go to a nonexisting page so that it loads as fast as possible
    // Note: since the page doesn't exist, we need to disable the space redirect feature so that we end up on the
    // terminal page and not on WebHome in the space.
    getUtil().gotoPage("NonExistentSpace", "NonExistentPage", "view", "spaceRedirect=false");
    this.vp = new ViewPage();
    this.nonExistentPageURL = getDriver().getCurrentUrl();
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) Before(org.junit.Before)

Example 48 with ViewPage

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

the class SectionTest method testSectionSaveDoesNotOverwriteTheWholeContentWhenSyntax20.

/**
 * Verify section save does not override the whole document content (xwiki/2.0).
 * See XWIKI-4033: When saving after section edit entire page is overwritten.
 */
@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 testSectionSaveDoesNotOverwriteTheWholeContentWhenSyntax20() {
    ViewPage vp = createTestPages("xwiki/2.0");
    vp.editSection(4).editWiki().clickSaveAndView();
    WikiEditPage wep = vp.editWiki();
    Assert.assertEquals("= Section1 = Content1 = Section2 = Content2 == Section3 == Content3 " + "{{include document=\"Test.SectionEditingIncluded\"/}} = Section7 = Content7", wep.getContent());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 49 with ViewPage

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

the class SectionTest method testSectionEditInWikiEditorWhenSyntax2x.

private void testSectionEditInWikiEditorWhenSyntax2x(String syntaxId) {
    ViewPage vp = createTestPages(syntaxId);
    // Edit the second section in the wiki editor
    WikiEditPage wikiEditPage = vp.editSection(2).editWiki();
    Assert.assertEquals("= Section2 = Content2 == Section3 == Content3 " + "{{include document=\"Test.SectionEditingIncluded\"/}}", wikiEditPage.getContent());
    vp = wikiEditPage.clickCancel();
    // Edit the third section in the wiki editor
    wikiEditPage = vp.editSection(3).editWiki();
    Assert.assertEquals("== Section3 == Content3 {{include document=\"Test.SectionEditingIncluded\"/}}", wikiEditPage.getContent());
    vp = wikiEditPage.clickCancel();
    // Edit the fourth section in the wiki editor
    // Note: we prove that included documents don't generate editable sections by checking that the fourth section
    // is "Section7".
    wikiEditPage = vp.editSection(4).editWiki();
    Assert.assertEquals("= Section7 = Content7", wikiEditPage.getContent());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage)

Example 50 with ViewPage

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

the class MailTest method sendMailWithInvalidMailSetup.

private void sendMailWithInvalidMailSetup() throws Exception {
    // Remove existing pages (for pages that we create below)
    getUtil().deletePage(getTestClassName(), "SendInvalidMail");
    // Create a page with the Velocity script to send the template email.
    // Note that we don't set the type and thus this message should not appear in the LiveTable filter at the end
    // of the test.
    String velocity = "{{velocity}}\n" + "#set ($message = $services.mailsender.createMessage('from@doe.com', 'to@doe.com', 'Subject'))\n" + "#set ($discard = $message.addPart('text/plain', 'text message'))\n" + "#set ($result = $services.mailsender.send([$message], 'database'))\n" + "#foreach ($status in $result.statusResult.getAllErrors())\n" + "  MSGID $status.messageId SUMMARY $status.errorSummary DESCRIPTION $status.errorDescription\n" + "#end\n" + "{{/velocity}}";
    // This will create the page and execute its content and thus send the mail
    ViewPage vp = getUtil().createPage(getTestClassName(), "SendInvalidMail", velocity, "");
    // Verify that the page is not empty (and thus an error message is displayed). Note that it's difficult to
    // assert what is displayed because it could vary from system to system. This is why we only assert that
    // something is displayed and that it matches the defined pattern.
    assertTrue(vp.getContent().matches("(?s)MSGID.*SUMMARY.*DESCRIPTION.*"));
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage)

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