Search in sources :

Example 6 with WikiEditPage

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

the class SpacesTest method spacesMacro.

@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 spacesMacro() {
    // Create a page with special characters in space name
    // See XE-1228: Broken links displayed in the Spaces widget if a space name contains a colon
    // See XE-1298: Spaces macro doesn't list spaces that contain a colon in their name
    String spaceName = getTestClassName() + ":" + getTestMethodName() + "&";
    String referenceEscapedSpaceName = getTestClassName() + "\\:" + getTestMethodName() + "&";
    // Make sure the new space's WebHome page doesn't exist.
    getUtil().deletePage(spaceName, "WebHome");
    // Create the new space using the UI and verify it leads to the space home page being edited.
    SpacesMacroPage macroPage = SpacesMacroPage.gotoPage();
    macroPage.getSpacesMacroPane().createSpace(spaceName).clickCreate();
    WikiEditPage editPage = new WikiEditPage();
    // Verify that space creation uses the space name as the space home page's title
    assertEquals(spaceName, editPage.getDocumentTitle());
    // Verify that the space created is correct by looking at the generate metadata in the HTML header
    // (they contain the space reference amongst other data).
    // Note: the value will be escaped since it is the space reference, not the space name.
    assertEquals(referenceEscapedSpaceName, editPage.getMetaDataValue("space"));
    // Go back to the Spaces Macro page and verify that the link to space index works
    // First, save the space's home page
    editPage.clickSaveAndContinue();
    macroPage = SpacesMacroPage.gotoPage();
    macroPage.getSpacesMacroPane().clickSpaceIndex(referenceEscapedSpaceName);
    // Assert the content of the space index live table.
    LiveTableElement spaceIndexLiveTable = new SpaceIndexPage().getLiveTable();
    spaceIndexLiveTable.waitUntilReady();
    assertEquals(1, spaceIndexLiveTable.getRowCount());
    assertTrue(spaceIndexLiveTable.hasRow("Page", "WebHome"));
    assertTrue(spaceIndexLiveTable.hasRow("Space", referenceEscapedSpaceName));
    // Go back to the Spaces Macro page and this time verify that the link to the space home page works
    macroPage = SpacesMacroPage.gotoPage();
    ViewPage spaceHomePage = macroPage.getSpacesMacroPane().clickSpaceHome(referenceEscapedSpaceName);
    assertEquals(spaceName, spaceHomePage.getDocumentTitle());
}
Also used : LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) SpacesMacroPage(org.xwiki.index.test.po.SpacesMacroPage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) SpaceIndexPage(org.xwiki.index.test.po.SpaceIndexPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 7 with WikiEditPage

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

the class DocumentFieldsTest method titleAndContent.

@Test
public void titleAndContent() {
    // Create a new application.
    String appName = RandomStringUtils.randomAlphabetic(6);
    ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
    appCreatePage.setApplicationName(appName);
    appCreatePage.waitForApplicationNamePreview();
    ApplicationClassEditPage classEditPage = appCreatePage.clickNextStep();
    // Add a standard field.
    ClassFieldEditPane numberField = classEditPage.addField("Number");
    // Add the Title and Content fields.
    ClassFieldEditPane titleField = classEditPage.addField("Title");
    ClassFieldEditPane contentField = classEditPage.addField("Content");
    // Change the default field pretty names.
    // See XWIKI-9154: The application live table uses the standard 'Page title' heading instead of the pretty name
    // set for the Title field
    titleField.setPrettyName("My Title");
    contentField.setPrettyName("My Content");
    // Set the default values that will be saved in the template.
    numberField.setDefaultValue("13");
    String defaultTitle = "Enter title here";
    titleField.setDefaultValue(defaultTitle);
    String defaultContent = "Enter content here";
    contentField.setDefaultValue(defaultContent);
    // Add live table columns for Title and Content.
    ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded();
    homeEditPage.addLiveTableColumn("My Title");
    homeEditPage.addLiveTableColumn("My Content");
    // Add an application entry.
    EntryNamePane entryNamePane = homeEditPage.clickFinish().clickAddNewEntry();
    entryNamePane.setName("Test");
    EntryEditPage entryEditPage = entryNamePane.clickAdd();
    Assert.assertEquals("13", entryEditPage.getValue("number1"));
    // The page name is used as the default value for the title field.
    Assert.assertEquals("Test", entryEditPage.getDocumentTitle());
    Assert.assertEquals("Test", entryEditPage.getTitle());
    entryEditPage.setTitle("Foo");
    Assert.assertEquals(defaultContent, entryEditPage.getContent());
    entryEditPage.setContent("Bar");
    // Check that the title and the content of the entry have been updated.
    ViewPage entryViewPage = entryEditPage.clickSaveAndView();
    Assert.assertEquals("Foo", entryViewPage.getDocumentTitle());
    Assert.assertTrue(entryViewPage.getContent().contains("Bar"));
    entryViewPage.clickBreadcrumbLink(appName);
    // Check the entries live table.
    LiveTableElement liveTable = new ApplicationHomePage().getEntriesLiveTable();
    liveTable.waitUntilReady();
    Assert.assertEquals(1, liveTable.getRowCount());
    Assert.assertTrue(liveTable.hasRow("My Title", "Foo"));
    Assert.assertTrue(liveTable.hasRow("My Content", "Bar"));
    // Check that the title and the content of the class have not been changed.
    getUtil().gotoPage(new LocalDocumentReference(Arrays.asList(appName, "Code"), appName + "Class"), "edit", "editor=wiki");
    WikiEditPage editPage = new WikiEditPage();
    Assert.assertEquals(appName + " Class", editPage.getTitle());
    Assert.assertEquals("", editPage.getContent());
    // Now edit the class and check if the default values for title and content are taken from the template.
    editPage.editInline();
    Assert.assertEquals(defaultTitle, new ClassFieldEditPane("title1").getDefaultValue());
    Assert.assertEquals(defaultContent, new ClassFieldEditPane("content1").getDefaultValue());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) EntryNamePane(org.xwiki.appwithinminutes.test.po.EntryNamePane) ApplicationHomeEditPage(org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) ApplicationCreatePage(org.xwiki.appwithinminutes.test.po.ApplicationCreatePage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) ApplicationHomePage(org.xwiki.appwithinminutes.test.po.ApplicationHomePage) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 8 with WikiEditPage

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

the class VersionTest method testRollbackToFirstVersion.

@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 testRollbackToFirstVersion() 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 that we can rollback to the first version
    HistoryPane historyTab = vp.openHistoryDocExtraPane();
    vp = historyTab.rollbackToVersion("1.1");
    // Rollback doesn't wait...
    // Wait for the comment tab to be selected since we're currently on the history tab and rolling
    // back is going to load a new page and make the focus active on the comments tab.
    vp.waitForDocExtraPaneActive("comments");
    Assert.assertEquals("First version of Content", vp.getContent());
    historyTab = vp.openHistoryDocExtraPane();
    Assert.assertEquals("Rollback to version 1.1", historyTab.getCurrentVersionComment());
    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)

Example 9 with WikiEditPage

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

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

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