Search in sources :

Example 21 with WikiEditPage

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

the class PreviewTest method previewWithProgrammingRights.

/**
 * @see "XWIKI-2490: Preview doesn't work when the document content has script requiring programming rights"
 */
@Test
public void previewWithProgrammingRights() {
    WikiEditPage wikiEditPage = WikiEditPage.gotoPage(getTestClassName(), getTestMethodName());
    wikiEditPage.setContent("{{velocity}}$xwiki.hasAccessLevel('programming')" + " $tdoc.author $tdoc.contentAuthor $tdoc.creator{{/velocity}}");
    PreviewEditPage previewPage = wikiEditPage.clickPreview();
    assertEquals("true XWiki.Admin XWiki.Admin XWiki.Admin", previewPage.getContent());
}
Also used : PreviewEditPage(org.xwiki.test.ui.po.editor.PreviewEditPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) Test(org.junit.Test)

Example 22 with WikiEditPage

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

the class SectionTest method testSectionSaveDoesNotOverwriteTheTitle.

/**
 * Verify that the document title is not overwritten when saving a section.
 *
 * @see <a href="https://jira.xwiki.org/browse/XWIKI-8938">XWIKI-8938: Translated title is overwritten by the default
 *      translation title when editing a document section</a>
 */
@Test
public void testSectionSaveDoesNotOverwriteTheTitle() throws Exception {
    LocalDocumentReference pageReference = new LocalDocumentReference(getTestClassName(), getTestMethodName());
    // Create the English version.
    setLanguageSettings(false, "en", "en");
    getUtil().rest().delete(pageReference);
    getUtil().rest().savePage(pageReference, "Original content", "Original title");
    try {
        // Create the French version.
        setLanguageSettings(true, "en", "en,fr");
        Map<String, String> parameters = new HashMap<String, String>();
        parameters.put("language", "fr");
        parameters.put("title", "Translated title");
        parameters.put("content", "= Chapter 1 =\n\n Once upon a time ...");
        getUtil().gotoPage(pageReference, "save", parameters);
        // Switch back to monolingual with French as default language.
        setLanguageSettings(false, "fr", "fr");
        // Edit and save a document section and check if the document title was overwritten.
        getUtil().gotoPage(pageReference, "edit", "editor=wiki&section=1");
        Assert.assertEquals("Translated title", new WikiEditPage().clickSaveAndView().getDocumentTitle());
    } finally {
        // Restore language settings.
        setLanguageSettings(false, "en", "en");
    }
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) HashMap(java.util.HashMap) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) Test(org.junit.Test)

Example 23 with WikiEditPage

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

the class SkinxTest method testJavascriptExtension.

/**
 * https://jira.xwiki.org/browse/XWIKI-7913
 */
@Test
public void testJavascriptExtension() {
    // Create a doc
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "SkinxTest");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add an XWikiGroups object
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("XWiki.JavaScriptExtension");
    objectForm.setFieldValue(By.id("XWiki.JavaScriptExtension_0_code"), SCRIPT);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("always");
    oep.clickSaveAndView();
    waitForScriptResult();
    HomePage.gotoPage();
    waitForScriptResult();
    oep = ObjectEditPage.gotoPage("Test", "SkinxTest");
    objectForm = oep.getObjectsOfClass("XWiki.JavaScriptExtension").get(0);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("currentPage");
    oep.clickSaveAndView();
    waitForScriptResult();
    HomePage.gotoPage();
    try {
        waitForScriptResult();
        Assert.fail("The JSX should be active only on the current page.");
    } catch (TimeoutException e) {
    }
    oep = ObjectEditPage.gotoPage("Test", "SkinxTest");
    objectForm = oep.getObjectsOfClass("XWiki.JavaScriptExtension").get(0);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("onDemand");
    oep.clickSaveAndView();
    try {
        waitForScriptResult();
        Assert.fail("The JSX should be active only on demand.");
    } catch (TimeoutException e) {
    }
}
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) FormElement(org.xwiki.test.ui.po.FormElement) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 24 with WikiEditPage

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

the class VersionTest method testDeleteLatestVersion.

/**
 * See XWIKI-8781
 */
@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 testDeleteLatestVersion() throws Exception {
    getUtil().rest().deletePage(SPACE_NAME, PAGE_NAME);
    // Create first version of the page
    ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);
    // Adds second version
    WikiEditPage wikiEditPage = vp.editWiki();
    wikiEditPage.setContent(CONTENT2);
    wikiEditPage.clickSaveAndView();
    // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
    // view mode) is fixed.
    vp.waitForDocExtraPaneActive("comments");
    // Verify and delete the latest version.
    HistoryPane historyTab = vp.openHistoryDocExtraPane();
    Assert.assertEquals("2.1", historyTab.getCurrentVersion());
    historyTab = historyTab.deleteVersion("2.1");
    // Verify that the current version is now the previous one.
    Assert.assertEquals("1.1", historyTab.getCurrentVersion());
    Assert.assertEquals("Administrator", historyTab.getCurrentAuthor());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) HistoryPane(org.xwiki.test.ui.po.HistoryPane) 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