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());
}
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"));
}
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());
}
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");
}
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);
}
Aggregations