Search in sources :

Example 1 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class CopyPageTest method testCopyOverwritePage.

@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testCopyOverwritePage() throws Exception {
    String sourceSpaceName = getTestClassName();
    String sourcePageName = getTestMethodName();
    String targetSpaceName = getTestClassName() + "Copy";
    String targetPageName = getTestMethodName() + "Copy";
    // Delete page that may already exist
    getUtil().rest().deletePage(sourceSpaceName, sourcePageName);
    getUtil().rest().deletePage(targetSpaceName, targetPageName);
    // Create a new page that will be overwritten.
    getUtil().rest().savePage(new LocalDocumentReference(targetSpaceName, targetPageName), OVERWRITTEN_PAGE_CONTENT, targetPageName);
    // Create a new page that will be copied.
    ViewPage viewPage = getUtil().createPage(sourceSpaceName, sourcePageName, PAGE_CONTENT, sourcePageName);
    // Click on Copy from the Page top menu.
    viewPage.copy();
    CopyPage copyPage = new CopyPage();
    // Fill the target destination the page to be copied to.
    DocumentPicker documentPicker = copyPage.getDocumentPicker();
    documentPicker.setTitle(targetPageName);
    documentPicker.browseDocuments();
    DocumentPickerModal documentPickerModal = new DocumentPickerModal();
    documentPickerModal.waitForDocumentSelected(sourceSpaceName, "WebHome").selectDocument(targetSpaceName, "WebHome");
    documentPicker.waitForLocation(Arrays.asList("", targetSpaceName, targetPageName));
    Assert.assertEquals(targetSpaceName, copyPage.getTargetSpaceName());
    // Click copy button
    CopyOverwritePromptPage copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
    // Check overwrite warning
    Assert.assertEquals(OVERWRITE_PROMPT1 + targetSpaceName + '.' + targetPageName + OVERWRITE_PROMPT2, copyOverwritePrompt.getWarningMessage());
    // Cancel the copy
    viewPage = copyOverwritePrompt.clickCancelButton();
    // Verify that we have been sent back to the original page
    Assert.assertEquals(sourcePageName, viewPage.getDocumentTitle());
    // Click on Copy from the Page top menu.
    viewPage.copy();
    copyPage = new CopyPage();
    // Fill the target destination the page to be copied to.
    copyPage.getDocumentPicker().toggleLocationAdvancedEdit().setParent(targetSpaceName).setName(targetPageName);
    // Click copy button
    copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
    // Click change target
    copyOverwritePrompt.clickChangeTargetButton();
    copyPage = new CopyPage();
    // Check the source document
    Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), copyPage.getSourceLocation().getPath());
    Assert.assertEquals(sourceSpaceName, copyPage.getSourceSpaceName());
    Assert.assertEquals(sourcePageName, copyPage.getSourcePageName());
    // Check the default target document.
    documentPicker = copyPage.getDocumentPicker();
    Assert.assertEquals(sourcePageName, documentPicker.getTitle());
    Assert.assertEquals(Arrays.asList("", sourceSpaceName, sourcePageName), documentPicker.getLocation().getPath());
    Assert.assertEquals(sourceSpaceName, copyPage.getTargetSpaceName());
    Assert.assertEquals(sourcePageName, copyPage.getTargetPageName());
    // Fill the target destination the page to be copied to.
    documentPicker.setTitle("My copy").toggleLocationAdvancedEdit().setParent(targetSpaceName).setName(targetPageName);
    // Copy and confirm overwrite
    copyOverwritePrompt = copyPage.clickCopyButtonExpectingOverwritePrompt();
    CopyOrRenameStatusPage copyStatusPage = copyOverwritePrompt.clickCopyButton().waitUntilFinished();
    // Check successful copy confirmation
    Assert.assertEquals(COPY_SUCCESSFUL, copyStatusPage.getInfoMessage());
    viewPage = copyStatusPage.gotoNewPage();
    // Verify that the title of the copy has been updated (independent from the name of the copy).
    Assert.assertEquals("My copy", viewPage.getDocumentTitle());
    Assert.assertEquals(PAGE_CONTENT, viewPage.getContent());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) CopyOrRenameStatusPage(org.xwiki.test.ui.po.CopyOrRenameStatusPage) CopyPage(org.xwiki.index.test.po.CopyPage) DocumentPickerModal(org.xwiki.index.tree.test.po.DocumentPickerModal) CopyOverwritePromptPage(org.xwiki.test.ui.po.CopyOverwritePromptPage) ViewPage(org.xwiki.test.ui.po.ViewPage) DocumentPicker(org.xwiki.test.ui.po.DocumentPicker) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 2 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class EditClassTest method testAddProperty.

@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testAddProperty() {
    // We verify that we can click on Edit Class from View Page (we need to test this at
    // least once to ensure the UI works).
    getUtil().gotoPage("Test", "EditObjectsTestClass", "view", "spaceRedirect=false");
    ClassEditPage cep = new ViewPage().editClass();
    // Create a class with a string property
    cep.addProperty("prop", "String");
    cep.clickSaveAndView();
    // Create object page
    ViewPage vp = getUtil().createPage("Test", "EditObjectsTestObject", "this is the content: {{velocity}}$doc.display('prop'){{/velocity}}", getTestMethodName());
    // Add an object of the class created
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
    objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "testing value");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: testing value", vp.getContent());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) FormElement(org.xwiki.test.ui.po.FormElement) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 3 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class EditClassTest method testDeleteProperty.

@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testDeleteProperty() {
    // Create a class with two string properties
    getUtil().addClassProperty("Test", "EditObjectsTestClass", "prop1", "String");
    getUtil().addClassProperty("Test", "EditObjectsTestClass", "prop2", "String");
    // Create object page
    ViewPage vp = getUtil().createPage("Test", "EditObjectsTestObject", "this is the content: {{velocity}}$doc.display('prop1')/$doc.display('prop2')/" + "$!doc.getObject('Test.EditObjectsTestClass').getProperty('prop1').value{{/velocity}}", getTestMethodName());
    // Add an object of the class created
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
    objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop1"), "testing value 1");
    objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop2"), "testing value 2");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: testing value 1/testing value 2/testing value 1", vp.getContent());
    // Delete the first property from the class
    ClassEditPage cep = getUtil().editClass("Test", "EditObjectsTestClass");
    cep.deleteProperty("prop1");
    cep.clickSaveAndView();
    vp = getUtil().gotoPage("Test", "EditObjectsTestObject");
    Assert.assertEquals("this is the content: /testing value 2/testing value 1", vp.getContent());
    oep = vp.editObjects();
    Assert.assertNotNull(getDriver().findElement(By.className("deprecatedProperties")));
    Assert.assertNotNull(getDriver().findElement(By.cssSelector(".deprecatedProperties label")));
    Assert.assertEquals("prop1:", getDriver().findElement(By.cssSelector(".deprecatedProperties label")).getText());
    // Remove deprecated properties
    oep.removeAllDeprecatedProperties();
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: /testing value 2/", vp.getContent());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) FormElement(org.xwiki.test.ui.po.FormElement) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 4 with IgnoreBrowser

use of org.xwiki.test.ui.browser.IgnoreBrowser in project xwiki-platform by xwiki.

the class EditInlineTest method testInlineEditPreservesTags.

/* See XWIKI-2199 */
@Test
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177")
public void testInlineEditPreservesTags() {
    String tag1 = RandomStringUtils.randomAlphanumeric(4);
    String tag2 = RandomStringUtils.randomAlphanumeric(4);
    getUtil().gotoPage(getTestClassName(), getTestMethodName(), "save", "tags=" + tag1 + "%7C" + tag2);
    TaggablePage taggablePage = new TaggablePage();
    Assert.assertTrue(taggablePage.hasTag(tag1));
    Assert.assertTrue(taggablePage.hasTag(tag2));
    taggablePage.editInline().clickSaveAndView();
    taggablePage = new TaggablePage();
    Assert.assertTrue(taggablePage.hasTag(tag1));
    Assert.assertTrue(taggablePage.hasTag(tag2));
}
Also used : TaggablePage(org.xwiki.tag.test.po.TaggablePage) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 5 with IgnoreBrowser

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

Aggregations

Test (org.junit.Test)22 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)22 AbstractTest (org.xwiki.test.ui.AbstractTest)12 ViewPage (org.xwiki.test.ui.po.ViewPage)10 AddTagsPane (org.xwiki.tag.test.po.AddTagsPane)5 FormElement (org.xwiki.test.ui.po.FormElement)5 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)5 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)5 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)4 MimeMessage (javax.mail.internet.MimeMessage)3 CopyPage (org.xwiki.index.test.po.CopyPage)2 InvitationSenderPage (org.xwiki.invitation.test.po.InvitationSenderPage)2 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)2 TaggablePage (org.xwiki.tag.test.po.TaggablePage)2 TestUtils (org.xwiki.test.ui.TestUtils)2 CopyOrRenameStatusPage (org.xwiki.test.ui.po.CopyOrRenameStatusPage)2 DocumentPicker (org.xwiki.test.ui.po.DocumentPicker)2 TableElement (org.xwiki.test.ui.po.TableElement)2 StaticListClassEditElement (org.xwiki.test.ui.po.editor.StaticListClassEditElement)2 AdministrationPage (org.xwiki.administration.test.po.AdministrationPage)1