Search in sources :

Example 56 with ViewPage

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

the class CreatePageIT method createPageWithSaveAndEditTemplate.

/**
 * Tests the creation of a page from a save and edit template, tests that the page is indeed saved.
 */
@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 createPageWithSaveAndEditTemplate() throws Exception {
    // Cleanup of the test space for any leftovers from previous tests.
    getUtil().deleteSpace(getTestClassName());
    // Create a template
    String templateProviderName = TEMPLATE_NAME + "Provider";
    String templateContent = "Templates are fun";
    String templateTitle = "Funny templates";
    String templateProviderFullName = getTestClassName() + "." + templateProviderName;
    ViewPage templatePage = createTemplateAndTemplateProvider(templateProviderName, templateContent, templateTitle, true);
    // create the page
    CreatePagePage createPage = templatePage.createPage();
    createPage.getDocumentPicker().toggleLocationAdvancedEdit();
    EditPage editCreatedPage = createPage.createPageFromTemplate(getTestClassName(), "NewPage", templateProviderFullName);
    // and now cancel it
    ViewPage newPage = editCreatedPage.clickCancel();
    // make sure we're not in unexisting page
    assertTrue(newPage.exists());
    // we should be in view mode (useless check since the impl of isNonExisting page calls it anyway)
    assertTrue(getUtil().isInViewMode());
    // make sure it's the page we want
    assertEquals(getTestClassName() + ".NewPage", newPage.getMetaDataValue("space"));
    assertEquals("WebHome", newPage.getMetaDataValue("page"));
    // and now test the title is the name of the page and the content is the one from the template
    assertEquals("NewPage", newPage.getDocumentTitle());
    assertEquals(templateContent, newPage.getContent());
    // and the parent, it should be the template provider, since that's where we created it from
    assertEquals("/" + getTestClassName() + "/NewPage", newPage.getBreadcrumbContent());
}
Also used : CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) EditPage(org.xwiki.test.ui.po.editor.EditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 57 with ViewPage

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

the class ImportIT method testImportWithHistory.

@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 testImportWithHistory() {
    URL fileUrl = this.getClass().getResource("/" + PACKAGE_WITH_HISTORY);
    this.sectionPage.attachPackage(fileUrl);
    this.sectionPage.selectPackage(PACKAGE_WITH_HISTORY);
    this.sectionPage.selectReplaceHistoryOption();
    this.sectionPage.importPackage();
    ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage");
    // Since the page by default opens the comments pane, if we instantly click on the history, the two tabs
    // will race for completion. Let's wait for comments first.
    importedPage.openCommentsDocExtraPane();
    HistoryPane history = importedPage.openHistoryDocExtraPane();
    Assert.assertEquals("3.1", history.getCurrentVersion());
    Assert.assertEquals("A third version of the document", history.getCurrentVersionComment());
    Assert.assertTrue(history.hasVersionWithSummary("A new version of the document"));
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) URL(java.net.URL) HistoryPane(org.xwiki.test.ui.po.HistoryPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 58 with ViewPage

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

the class ImportIT method testImportWithNewHistoryVersion.

@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 testImportWithNewHistoryVersion() {
    URL fileUrl = this.getClass().getResource("/" + PACKAGE_WITHOUT_HISTORY);
    this.sectionPage.attachPackage(fileUrl);
    this.sectionPage.selectPackage(PACKAGE_WITHOUT_HISTORY);
    this.sectionPage.importPackage();
    ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage");
    // Since the page by default opens the comments pane, if we instantly click on the history, the two tabs
    // will race for completion. Let's wait for comments first.
    importedPage.openCommentsDocExtraPane();
    HistoryPane history = importedPage.openHistoryDocExtraPane();
    Assert.assertEquals("1.1", history.getCurrentVersion());
    Assert.assertEquals("Imported from XAR", history.getCurrentVersionComment());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) URL(java.net.URL) HistoryPane(org.xwiki.test.ui.po.HistoryPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 59 with ViewPage

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

the class BreadcrumbsTest method verifyBreadcrumbInParentChildMode.

@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 verifyBreadcrumbInParentChildMode() {
    // Delete the page to reset the rights on it (since the test below modifies them).
    getUtil().deletePage(getTestClassName(), getTestMethodName());
    getUtil().setHierarchyMode("parentchild");
    String parentPageName = getTestMethodName() + "ParentPage";
    String parentPageFullName = getTestClassName() + "." + parentPageName;
    getUtil().createPage(getTestClassName(), parentPageName, null, PARENT_TITLE);
    ViewPage vp = getUtil().createPage(getTestClassName(), getTestMethodName(), null, CHILD_TITLE, null, parentPageFullName);
    // Verify standard breadcrumb behavior.
    assertTrue(vp.hasBreadcrumbContent(PARENT_TITLE, false));
    assertTrue(vp.hasBreadcrumbContent(CHILD_TITLE, true));
    // Remove view rights on the Test.ParentPage page to everyone except superadmin user so that we can verify
    // that the breadcrumb of the child page doesn't display page titles for pages for which you don't have view
    // rights.
    getUtil().addObject(getTestClassName(), parentPageName, "XWiki.XWikiRights", "levels", "view", "users", "XWiki.superadmin", "allow", "1");
    // Log out...
    getUtil().forceGuestUser();
    // Verify breadcrumb doesn't display page title for the parent page (since the guest user doesn't have view
    // permission for it).
    vp = getUtil().gotoPage(getTestClassName(), getTestMethodName());
    assertFalse(vp.isAuthenticated());
    assertFalse(vp.hasBreadcrumbContent(PARENT_TITLE, false, true));
    assertTrue(vp.hasBreadcrumbContent(CHILD_TITLE, true, true));
    assertTrue(vp.hasBreadcrumbContent(parentPageName, false, false));
    // Set back the default hierarchy mode (but first we need to log back).
    adminAuthenticationRule.authenticate();
    getUtil().setHierarchyMode("reference");
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 60 with ViewPage

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

the class BreadcrumbsTest method verifyBreadcrumbInLongHierarchy.

@Test
public void verifyBreadcrumbInLongHierarchy() throws Exception {
    DocumentReference documentReference = new DocumentReference("xwiki", Arrays.asList("A", "B", "C", "D", "E", "F", "G", "H"), "WebHome");
    ViewPage page = getUtil().createPage(documentReference, "Content", getTestMethodName());
    BreadcrumbElement breadcrumb = page.getBreadcrumb();
    // Verify that the breadcrumb is limited
    assertEquals("/A/…/F/G/" + getTestMethodName(), breadcrumb.getPathAsString());
    // Verify we can expand it
    breadcrumb.expand();
    assertEquals("/A/B/C/D/E/F/G/" + getTestMethodName(), breadcrumb.getPathAsString());
    // Clean
    getUtil().deletePage(documentReference);
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) DocumentReference(org.xwiki.model.reference.DocumentReference) BreadcrumbElement(org.xwiki.test.ui.po.BreadcrumbElement) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

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