use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class DeletePageTest method deleteChildren.
/**
* Test that when you delete a page and you select "affect children", it delete children properly. It also test
* the opposite.
*
* @since 7.2RC1
*/
@Test
public void deleteChildren() {
// Initialize the parent
DocumentReference parentReference = new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName()), "WebHome");
ViewPage parentPage = getUtil().createPage(parentReference, "Content", "Parent");
// Test 1: Try to delete it to make sure we don't have the "affect children" option yet
ConfirmationPage confirmationPage = parentPage.delete();
assertFalse(confirmationPage.hasAffectChildrenOption());
// Initialize the children pages
final int NB_CHILDREN = 3;
DocumentReference[] childrenReferences = new DocumentReference[NB_CHILDREN];
for (int i = 0; i < NB_CHILDREN; ++i) {
childrenReferences[i] = new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName(), "Child_" + (i + 1)), "WebHome");
getUtil().createPage(childrenReferences[i], "Content", "Child " + (i + 1));
}
// Test 2: when you don't select "affect children", the children are not deleted
parentPage = getUtil().gotoPage(parentReference);
confirmationPage = parentPage.delete();
assertTrue(confirmationPage.hasAffectChildrenOption());
confirmationPage.setAffectChildren(false);
DeletingPage deletingPage = confirmationPage.confirmDeletePage();
deletingPage.waitUntilIsTerminated();
deletingPage.waitUntilSuccessMessage();
assertEquals("The page has been deleted.", deletingPage.getSuccessMessage());
// Check the page have been effectively removed
ViewPage page = getUtil().gotoPage(parentReference);
assertFalse(page.exists());
// But not the children
for (int i = 0; i < NB_CHILDREN; ++i) {
page = getUtil().gotoPage(childrenReferences[i]);
assertTrue(page.exists());
}
// Test 3: when you select "affect children", the children are deleted too
parentPage = getUtil().createPage(parentReference, "Content", "Parent");
confirmationPage = parentPage.delete();
assertTrue(confirmationPage.hasAffectChildrenOption());
confirmationPage.setAffectChildren(true);
deletingPage = confirmationPage.confirmDeletePage();
deletingPage.waitUntilIsTerminated();
deletingPage.waitUntilSuccessMessage();
// Check the page have been effectively removed
page = getUtil().gotoPage(parentReference);
assertFalse(page.exists());
// And also the children
for (int i = 0; i < NB_CHILDREN; ++i) {
page = getUtil().gotoPage(childrenReferences[i]);
assertFalse(page.exists());
}
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class DeletePageTest method deleteTerminalAndNonTerminalPages.
/**
* Verify that when you delete a terminal and a non terminal page sharing the same location, both deleted versions
* are present in the recycle bin list when you hit the location afterwards.
* @see: "XWIKI-12563: Cannot restore a terminal page from its location"
* @since 7.2RC1
*/
@Test
public void deleteTerminalAndNonTerminalPages() {
DocumentReference terminalPageRef = new DocumentReference("xwiki", Arrays.asList(getTestClassName()), getTestMethodName());
DocumentReference nonTerminalPageRef = new DocumentReference("xwiki", Arrays.asList(getTestClassName(), getTestMethodName()), "WebHome");
// Clean up.
getUtil().deletePage(terminalPageRef);
getUtil().deletePage(nonTerminalPageRef);
// Create the non terminal page.
ViewPage nonTerminalPage = getUtil().createPage(nonTerminalPageRef, "Content", "Title");
// Delete it
nonTerminalPage.delete().clickYes();
DeletingPage deletingPage = new DeletingPage();
deletingPage.waitUntilIsTerminated();
// Look at the recycle bin
DeletePageOutcomePage deletePageOutcomePage = deletingPage.getDeletePageOutcomePage();
assertFalse(deletePageOutcomePage.hasTerminalPagesInRecycleBin());
// Create the terminal page.
ViewPage terminalPage = getUtil().createPage(terminalPageRef, "Content", "Title");
// Delete it
terminalPage.delete().clickYes();
deletingPage.waitUntilIsTerminated();
// Look at the recycle bin
deletePageOutcomePage = deletingPage.getDeletePageOutcomePage();
assertTrue(deletePageOutcomePage.hasTerminalPagesInRecycleBin());
// Delete both version in the recycle bin
deletePageOutcomePage.clickDeletePage();
deletePageOutcomePage.clickDeleteTerminalPage();
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class RenamePageTest method convertNestedPageToTerminalPage.
// Convert a nested page to a terminal page
@Test
public void convertNestedPageToTerminalPage() throws Exception {
// Clean-up: delete the pages that will be used in this test
getUtil().rest().deletePage("1", "2");
getUtil().rest().delete(getUtil().resolveDocumentReference("1.2.WebHome"));
// Create 1.2.WebHome
getUtil().createPage(Arrays.asList("1", "2"), "WebHome", "", "");
// Go to 1.2.WebHome to start the test
getUtil().gotoPage(Arrays.asList("1", "2"), "WebHome", "", "");
ViewPage vp = new ViewPage();
// Go to the Rename page view for 1.2.WebHome and check the Terminal checkbox. We also need to uncheck the Auto
// Redirect checkbox so the page 1.2.WebHome will not appear as existing after the Rename operation.
RenamePage renamePage = vp.rename();
renamePage.setTerminal(true);
renamePage.setAutoRedirect(false);
renamePage.clickRenameButton().waitUntilFinished();
// Test if 1.2.WebHome has been renamed to 1.2 (1.2.WebHome doesn't exist while 1.2 exists)
assertTrue("Page 1.2 doesn't exist!", getUtil().pageExists(Arrays.asList("1"), "2"));
assertFalse("Page 1.2.WebHome exists!", getUtil().pageExists(Arrays.asList("1", "2"), "WebHome"));
}
use of org.xwiki.test.ui.po.ViewPage in project xwiki-platform by xwiki.
the class RestoreDeletedPageTest method restore.
/**
* @see "XWIKI-9421: Attachment version is incremented when a document is restored from recycle bin"
*/
@Test
public void restore() throws Exception {
// Clean up.
getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
// Create a new page.
ViewPage page = getUtil().createPage(getTestClassName(), getTestMethodName(), "Once upon a time..", "A story");
// Add an attachment.
page.openAttachmentsDocExtraPane().setFileToUpload(getClass().getResource("/SmallAttachment.txt").getPath());
// Delete the page.
page.delete().clickYes();
DeletingPage deletingPage = new DeletingPage();
deletingPage.waitUntilIsTerminated();
// Restore the page.
page = deletingPage.getDeletePageOutcomePage().clickRestore();
// Check the page title and content.
assertEquals("A story", page.getDocumentTitle());
assertEquals("Once upon a time..", page.getContent());
// Check document version/history.
HistoryPane historyPane = page.openHistoryDocExtraPane();
assertEquals("2.1", historyPane.getCurrentVersion());
// Check the attachment.
AttachmentsPane attachmentsPane = page.openAttachmentsDocExtraPane();
assertEquals(1, attachmentsPane.getNumberOfAttachments());
assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("SmallAttachment.txt"));
// Check the attachment content.
attachmentsPane.getAttachmentLink("SmallAttachment.txt").click();
Assert.assertEquals("This is a small attachment.", getDriver().findElement(By.tagName("html")).getText());
}
use of org.xwiki.test.ui.po.ViewPage 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());
}
Aggregations