Search in sources :

Example 21 with ViewPage

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

the class CreatePageIT method createExistingPageAndSpace.

/**
 * Tests that creating a page or a space that already exists displays an error.
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void createExistingPageAndSpace() throws Exception {
    // Step 0: Setup the correct environment for the test
    EntityReference existingPageReference = getUtil().resolveDocumentReference(getTestClassName() + ".ExistingPage.WebHome");
    String existingSpaceName = getTestClassName() + "Existing";
    // All these pages are created during this test
    getUtil().rest().delete(existingPageReference);
    getUtil().rest().deletePage(existingSpaceName, "WebHome");
    // create a template to make sure that we have a template to create from
    String templateProviderName = TEMPLATE_NAME + "Provider";
    String templateContent = "Templates are fun";
    String templateTitle = "Funny templates";
    createTemplateAndTemplateProvider(templateProviderName, templateContent, templateTitle, false);
    // create a page and a space webhome
    getUtil().rest().savePage(existingPageReference, "Page that already exists", "Existing page");
    getUtil().rest().savePage(new LocalDocumentReference(existingSpaceName, "WebHome"), "Some content", "Existing space");
    // Step 1: Create an empty page for a page that already exists
    // First we must click on create from a page that already exists as otherwise we won't get the create UI
    ViewPage vp = getUtil().gotoPage(existingPageReference);
    CreatePagePage createPage = vp.createPage();
    createPage.getDocumentPicker().toggleLocationAdvancedEdit();
    createPage.getDocumentPicker().setParent(getTestClassName());
    createPage.getDocumentPicker().setName("ExistingPage");
    String currentURL = getDriver().getCurrentUrl();
    createPage.clickCreate();
    // make sure that we stay on the same page and that an error is displayed to the user. Maybe we should check the
    // error
    assertEquals(currentURL, getDriver().getCurrentUrl());
    createPage.waitForErrorMessage();
    // Step 2: Create a page from Template for a page that already exists
    // restart everything to make sure it's not the error before
    vp = getUtil().gotoPage(existingPageReference);
    createPage = vp.createPage();
    createPage.getDocumentPicker().toggleLocationAdvancedEdit();
    createPage.getDocumentPicker().setParent(getTestClassName());
    createPage.getDocumentPicker().setName("ExistingPage");
    createPage.setTemplate(getTestClassName() + "." + templateProviderName);
    currentURL = getDriver().getCurrentUrl();
    createPage.clickCreate();
    // make sure that we stay on the same page and that an error is displayed to the user. Maybe we should check the
    // error
    assertEquals(currentURL, getDriver().getCurrentUrl());
    createPage.waitForErrorMessage();
    // Step 3: Create a space that already exists
    // Since the Flamingo skin no longer supports creating a space from the UI, trigger the Space creation UI
    // by using directly the direct action URL for it.
    getUtil().gotoPage(getUtil().getURL("create", new String[] { getTestClassName(), "ExistingPage", "WebHome" }, "tocreate=space"));
    CreatePagePage createSpace = new CreatePagePage();
    // Check that the terminal choice is not displayed in this mode.
    assertFalse(createSpace.isTerminalOptionDisplayed());
    currentURL = getDriver().getCurrentUrl();
    // strip the parameters out of this URL
    currentURL = currentURL.substring(0, currentURL.indexOf('?') > 0 ? currentURL.indexOf('?') : currentURL.length());
    // Try to create the a space (non-terminal document) that already exist.
    createSpace.getDocumentPicker().toggleLocationAdvancedEdit();
    createSpace.fillForm(existingSpaceName, "", null, false);
    createSpace.clickCreate();
    String urlAfterSubmit = getDriver().getCurrentUrl();
    urlAfterSubmit = urlAfterSubmit.substring(0, urlAfterSubmit.indexOf('?') > 0 ? urlAfterSubmit.indexOf('?') : urlAfterSubmit.length());
    // make sure that we stay on the same page and that an error is displayed to the user. Maybe we should check the
    // error
    assertEquals(currentURL, urlAfterSubmit);
    createSpace.waitForErrorMessage();
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) EntityReference(org.xwiki.model.reference.EntityReference) ViewPage(org.xwiki.test.ui.po.ViewPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 22 with ViewPage

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

the class ImportIT method testImportAsBackup.

@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 testImportAsBackup() {
    URL fileUrl = this.getClass().getResource("/" + BACKUP_PACKAGE);
    this.sectionPage.attachPackage(fileUrl);
    this.sectionPage.selectPackage(BACKUP_PACKAGE);
    WebElement importAsBackup = getDriver().findElement(By.name("importAsBackup"));
    Assert.assertTrue(importAsBackup.isSelected());
    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("JohnDoe", history.getCurrentAuthor());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WebElement(org.openqa.selenium.WebElement) 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 23 with ViewPage

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

the class ImportIT method testImportWhenImportAsBackupIsNotSelected.

@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 testImportWhenImportAsBackupIsNotSelected() {
    URL fileUrl = this.getClass().getResource("/" + BACKUP_PACKAGE);
    this.sectionPage.attachPackage(fileUrl);
    this.sectionPage.selectPackage(BACKUP_PACKAGE);
    WebElement importAsBackup = getDriver().findElement(By.name("importAsBackup"));
    importAsBackup.click();
    Assert.assertFalse(importAsBackup.isSelected());
    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("superadmin", history.getCurrentAuthor());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WebElement(org.openqa.selenium.WebElement) 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 24 with ViewPage

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

the class CreatePageAndSpaceTest method testCreateUIInteraction.

/**
 * Test that the inputs in the create UI are updated, depending on the case.
 */
@Test
public void testCreateUIInteraction() {
    // Cleanup of the test space for any leftovers from previous tests.
    getUtil().deleteSpace(getTestClassName());
    // Create an existent page that will also be the parent of our documents.
    String existingPageTitle = "Test Area";
    getUtil().createPage(getTestClassName(), "WebHome", "", existingPageTitle);
    CreatePagePage createPage = new ViewPage().createPage();
    // Check that by default we have an empty title and name and the parent is the current document's space.
    assertEquals("", createPage.getDocumentPicker().getTitle());
    assertEquals("", createPage.getDocumentPicker().getName());
    assertEquals(getTestClassName(), createPage.getDocumentPicker().getParent());
    // Check the initial state of the breadcrumb.
    createPage.waitForLocationPreviewContent("/" + existingPageTitle + "/");
    // Set a new title and check that the page name and the breadcrumb are also updated.
    String newTitle = "New Title";
    createPage.getDocumentPicker().setTitle(newTitle);
    assertEquals(newTitle, createPage.getDocumentPicker().getName());
    createPage.waitForLocationPreviewContent("/" + existingPageTitle + "/" + newTitle);
    // Set a new page name and check that the breadcrumb is not updated, since we have a title specified.
    String newName = "SomeNewName";
    createPage.getDocumentPicker().setName(newName);
    createPage.waitForLocationPreviewContent("/" + existingPageTitle + "/" + newTitle);
    // Clear the title, set a page name and check that the breadcrumb now uses the page name as a fallback.
    createPage.getDocumentPicker().setTitle("");
    assertEquals("", createPage.getDocumentPicker().getName());
    createPage.getDocumentPicker().setName(newName);
    createPage.waitForLocationPreviewContent("/" + existingPageTitle + "/" + newName);
    // Set a new parent space and check that the breadcrumb is updated.
    // Before that, reset the title, just for completeness.
    createPage.getDocumentPicker().setTitle(newTitle);
    String newSpace = "SomeNewSpace";
    createPage.getDocumentPicker().setParent(newSpace);
    createPage.waitForLocationPreviewContent("/" + newSpace + "/" + newTitle);
    // Set a new parent in nested spaces and check that the breadcrumb is updated.
    String newSpaceLevel2 = "Level2";
    createPage.getDocumentPicker().setParent(newSpace + "." + newSpaceLevel2);
    createPage.waitForLocationPreviewContent("/" + newSpace + "/" + newSpaceLevel2 + "/" + newTitle);
    // Clear the parent and check that the breadcrumb is updated, since we are creating a top level document.
    createPage.getDocumentPicker().setParent("");
    createPage.waitForLocationPreviewContent("/" + newTitle);
}
Also used : CreatePagePage(org.xwiki.test.ui.po.CreatePagePage) ViewPage(org.xwiki.test.ui.po.ViewPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 25 with ViewPage

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

the class DeletePageTest method deletePageCanDoRedirect.

/**
 * Verify that we can skip the default delete result page and instead redirect to any page we want.
 */
@Test
public void deletePageCanDoRedirect() {
    // Set the current page to be any page (doesn't matter if it exists or not)
    String pageURL = getUtil().getURL(SPACE_VALUE, PAGE_VALUE + "Whatever");
    getUtil().gotoPage(SPACE_VALUE, PAGE_VALUE, DELETE_ACTION, "xredirect=" + pageURL);
    ConfirmationPage confirmation = new ConfirmationPage();
    confirmation.clickYes();
    ViewPage vp = new ViewPage();
    // Since the page PAGE_VALUE + "Whatever" doesn't exist the View Action will redirect to the Nested Document
    // SPACE_VALUE + "." + PAGE_VALUE + "Whatever + ".WebHome".
    assertEquals(SPACE_VALUE + "." + PAGE_VALUE + "Whatever", vp.getMetaDataValue("space"));
    assertEquals("WebHome", vp.getMetaDataValue("page"));
}
Also used : ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage) ViewPage(org.xwiki.test.ui.po.ViewPage) 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