Search in sources :

Example 1 with ConfirmationPage

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

Example 2 with ConfirmationPage

use of org.xwiki.test.ui.po.ConfirmationPage 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());
    }
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage) ViewPage(org.xwiki.test.ui.po.ViewPage) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 3 with ConfirmationPage

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

the class DeletePageTest method deleteOkWhenConfirming.

@Test
public void deleteOkWhenConfirming() {
    ConfirmationPage confirmationPage = this.viewPage.delete();
    // This tests for regression of XWIKI-1388
    assertNotNull("The interface should not show the user as logged out while deleting page", confirmationPage.getCurrentUser());
    confirmationPage.clickYes();
    DeletingPage deletingPage = new DeletingPage();
    deletingPage.waitUntilIsTerminated();
    // Note: it's better to wait instead of using isSuccess() since there could be some timeframe between
    // the hiding of the progress UI and the display of the success message.
    deletingPage.waitUntilSuccessMessage();
    assertEquals(CONFIRMATION, deletingPage.getSuccessMessage());
    DeletePageOutcomePage deleteOutcome = deletingPage.getDeletePageOutcomePage();
    assertEquals(LOGGED_USERNAME, deleteOutcome.getPageDeleter());
    assertEquals(DOCUMENT_NOT_FOUND, deleteOutcome.getMessage());
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage) DeletePageOutcomePage(org.xwiki.test.ui.po.DeletePageOutcomePage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 4 with ConfirmationPage

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

the class FlamingoThemeTest method createNewTheme.

/**
 * @since 6.3RC1
 */
@Test
public void createNewTheme() throws Exception {
    // Go to the presentation section of the administration
    AdministrationPage administrationPage = AdministrationPage.gotoPage();
    ThemesAdministrationSectionPage presentationAdministrationSectionPage = administrationPage.clickThemesSection();
    // Click on "manage color theme"
    presentationAdministrationSectionPage.manageColorThemes();
    ThemeApplicationWebHomePage themeApplicationWebHomePage = new ThemeApplicationWebHomePage();
    // Ensure the current theme is correct
    assertEquals("Charcoal", themeApplicationWebHomePage.getCurrentTheme());
    // Ensure the other themes are correct
    List<String> otherThemes = themeApplicationWebHomePage.getOtherThemes();
    assertTrue(otherThemes.contains("Marina"));
    assertTrue(otherThemes.contains("Garden"));
    assertTrue(otherThemes.contains("Kitty"));
    assertFalse(otherThemes.contains("Charcoal"));
    // Create a new theme
    EditThemePage editThemePage = themeApplicationWebHomePage.createNewTheme("Test");
    editThemePage.waitUntilPreviewIsLoaded();
    // First, disable auto refresh because it slows down the test
    // (and can even make it fails if the computer is slow)
    editThemePage.setAutoRefresh(false);
    // Set variables
    editThemePage.selectVariableCategory("Base colors");
    editThemePage.setVariableValue("xwiki-page-content-bg", "#ff0000");
    editThemePage.selectVariableCategory("Typography");
    editThemePage.setVariableValue("font-family-base", "Monospace");
    editThemePage.selectVariableCategory("Advanced");
    // Insert lessCode too
    editThemePage.setTextareaValue("lessCode", ".main{ color: #0000ff; }");
    // Save the theme
    editThemePage.clickSaveAndView();
    // Go back to the theme application
    themeApplicationWebHomePage = ThemeApplicationWebHomePage.gotoPage();
    // Set the new theme as current
    themeApplicationWebHomePage.useTheme("Test");
    // Verify that the new theme is used
    assertEquals("Test", themeApplicationWebHomePage.getCurrentTheme());
    // Look at the values
    assertEquals("rgba(255, 0, 0, 1)", themeApplicationWebHomePage.getPageBackgroundColor());
    assertEquals("monospace", themeApplicationWebHomePage.getFontFamily().toLowerCase());
    // Test 'lessCode' is correctly handled
    assertEquals("rgba(0, 0, 255, 1)", themeApplicationWebHomePage.getTextColor());
    // Switch back to Charcoal
    themeApplicationWebHomePage.useTheme("Charcoal");
    // Remove the theme
    ViewThemePage themePage = themeApplicationWebHomePage.seeTheme("Test");
    themePage.waitUntilPreviewIsLoaded();
    ConfirmationPage confirmationPage = themePage.delete();
    confirmationPage.confirmDeletePage().waitUntilIsTerminated();
}
Also used : ThemesAdministrationSectionPage(org.xwiki.administration.test.po.ThemesAdministrationSectionPage) AdministrationPage(org.xwiki.administration.test.po.AdministrationPage) ThemeApplicationWebHomePage(org.xwiki.flamingo.test.po.ThemeApplicationWebHomePage) ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage) ViewThemePage(org.xwiki.flamingo.test.po.ViewThemePage) EditThemePage(org.xwiki.flamingo.test.po.EditThemePage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 5 with ConfirmationPage

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

the class OfficeImporterTest method deletePageWithChildren.

/**
 * Delete a page with all its children.
 *
 * @param pageToDelete the page to delete
 */
private void deletePageWithChildren(ViewPage pageToDelete) {
    ConfirmationPage confirmationPage = pageToDelete.delete();
    if (confirmationPage.hasAffectChildrenOption()) {
        confirmationPage.setAffectChildren(true);
    }
    DeletingPage deletingPage = confirmationPage.confirmDeletePage();
    deletingPage.waitUntilIsTerminated();
    assertTrue(deletingPage.isSuccess());
}
Also used : DeletingPage(org.xwiki.test.ui.po.DeletingPage) ConfirmationPage(org.xwiki.test.ui.po.ConfirmationPage)

Aggregations

ConfirmationPage (org.xwiki.test.ui.po.ConfirmationPage)5 Test (org.junit.Test)4 AbstractTest (org.xwiki.test.ui.AbstractTest)4 DeletingPage (org.xwiki.test.ui.po.DeletingPage)3 ViewPage (org.xwiki.test.ui.po.ViewPage)2 AdministrationPage (org.xwiki.administration.test.po.AdministrationPage)1 ThemesAdministrationSectionPage (org.xwiki.administration.test.po.ThemesAdministrationSectionPage)1 EditThemePage (org.xwiki.flamingo.test.po.EditThemePage)1 ThemeApplicationWebHomePage (org.xwiki.flamingo.test.po.ThemeApplicationWebHomePage)1 ViewThemePage (org.xwiki.flamingo.test.po.ViewThemePage)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 DeletePageOutcomePage (org.xwiki.test.ui.po.DeletePageOutcomePage)1