Search in sources :

Example 1 with ClassEditPage

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

the class CompareVersionsTest method setUp.

@Before
public void setUp() throws Exception {
    String pageName = "PageWithManyVersions";
    // Check if the test page exists.
    testPage = getUtil().gotoPage(getTestClassName(), pageName);
    if (testPage.exists()) {
        // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
        // view mode) is fixed.
        testPage.waitForDocExtraPaneActive("comments");
        // versions of the test page.
        return;
    }
    // Since this test also verifies diffs when the parent/child relationship is modified, use this mode (which
    // isn't the default) for testing purpose. Also note that in the "reference" mode there's no diff to display
    // when the document is moved to a different parent since it means changing the identity of the document for
    // now and thus changing it means getting a new document.
    getUtil().setHierarchyMode("parentchild");
    getDriver().navigate().refresh();
    // Create the test page.
    testPage = getUtil().createPage(getTestClassName(), pageName, "one\ntwo\nthree", "Test");
    // Change the content and the meta data.
    WikiEditPage wikiEditPage = testPage.editWiki();
    wikiEditPage.setContent("one\n**two**\nfour");
    wikiEditPage.setTitle("Compare verSions test");
    wikiEditPage.setParent("Sandbox.WebHome");
    wikiEditPage.setEditComment("Changed content and meta data.");
    wikiEditPage.clickSaveAndContinue();
    wikiEditPage.setTitle("Compare versions test");
    wikiEditPage.setMinorEdit(true);
    wikiEditPage.setEditComment("Fix typo in title.");
    wikiEditPage.clickSaveAndContinue();
    // Add objects.
    ObjectEditPage objectEditPage = wikiEditPage.editObjects();
    FormElement form = objectEditPage.addObject("XWiki.JavaScriptExtension");
    Map<String, String> assignment = new HashMap<String, String>();
    assignment.put("XWiki.JavaScriptExtension_0_name", "JavaScript code");
    assignment.put("XWiki.JavaScriptExtension_0_code", "var tmp = alice;\nalice = bob;\nbob = tmp;");
    assignment.put("XWiki.JavaScriptExtension_0_use", "onDemand");
    form.fillFieldsByName(assignment);
    objectEditPage.clickSaveAndContinue();
    assignment.put("XWiki.JavaScriptExtension_0_name", "Code snippet");
    assignment.put("XWiki.JavaScriptExtension_0_code", "var tmp = alice;\nalice = 2 * bob;\nbob = tmp;");
    form.fillFieldsByName(assignment);
    objectEditPage.clickSaveAndContinue();
    // Create class.
    ClassEditPage classEditPage = objectEditPage.editClass();
    classEditPage.addProperty("age", "Number");
    classEditPage.addProperty("color", "String");
    classEditPage.getNumberClassEditElement("age").setNumberType("integer");
    classEditPage.clickSaveAndContinue();
    classEditPage.deleteProperty("color");
    testPage = classEditPage.clickSaveAndView();
    // Add tags.
    TaggablePage taggablePage = new TaggablePage();
    AddTagsPane addTagsPane = taggablePage.addTags();
    addTagsPane.setTags("foo,bar");
    addTagsPane.add();
    taggablePage.removeTag("foo");
    // Attach files.
    AttachmentsPane attachmentsPane = testPage.openAttachmentsDocExtraPane();
    // TODO: Update this code when we (re)add support for uploading multiple files at once.
    for (String fileName : new String[] { "SmallAttachment.txt", "SmallAttachment2.txt", "SmallAttachment.txt" }) {
        attachmentsPane.setFileToUpload(this.getClass().getResource('/' + fileName).getPath());
        attachmentsPane.waitForUploadToFinish(fileName);
        attachmentsPane.clickHideProgress();
    }
    attachmentsPane.deleteAttachmentByFileByName("SmallAttachment2.txt");
    // Add comments.
    getUtil().createUserAndLogin("Alice", "ecila");
    testPage = getUtil().gotoPage(getTestClassName(), pageName);
    CommentsTab commentsTab = testPage.openCommentsDocExtraPane();
    commentsTab.postComment("first line\nsecond line", true);
    commentsTab.editCommentByID(0, "first line\nline in between\nsecond line");
    commentsTab.replyToCommentByID(0, "this is a reply");
    commentsTab.deleteCommentByID(1);
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) HashMap(java.util.HashMap) AttachmentsPane(org.xwiki.test.ui.po.AttachmentsPane) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) CommentsTab(org.xwiki.test.ui.po.CommentsTab) TaggablePage(org.xwiki.tag.test.po.TaggablePage) AddTagsPane(org.xwiki.tag.test.po.AddTagsPane) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) FormElement(org.xwiki.test.ui.po.FormElement) Before(org.junit.Before)

Example 2 with ClassEditPage

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

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

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

the class ClassSheetTest method createClass.

/**
 * Tests the process of creating a class, its template, its sheet and an instance.
 */
@Test
public void createClass() {
    // TODO: rewrite the test to not rely on the breadcrumb based on parent/child mechanism.
    getUtil().setHierarchyMode("parentchild");
    try {
        String spaceName = getTestClassName();
        String className = RandomStringUtils.randomAlphabetic(5);
        String classDocName = className + "Class";
        String classTitle = className + " Class";
        String pageName = getTestMethodName();
        // Make sure the document doesn't exist.
        getUtil().deletePage(spaceName, pageName);
        // Create the class document.
        DataTypesPage dataTypesPage = DataTypesPage.gotoPage().waitUntilPageIsLoaded();
        String dataTypesPageTitle = dataTypesPage.getDocumentTitle();
        Assert.assertTrue(dataTypesPage.isClassListed("XWiki", "XWikiRights"));
        Assert.assertFalse(dataTypesPage.isClassListed(spaceName, classDocName));
        ClassSheetPage classSheetPage = dataTypesPage.createClass(spaceName, className).waitUntilPageIsLoaded();
        Assert.assertEquals(classTitle, classSheetPage.getDocumentTitle());
        Assert.assertTrue(classSheetPage.hasBreadcrumbContent(dataTypesPageTitle, false));
        // Add a property.
        ClassEditPage classEditor = classSheetPage.clickDefineClassLink();
        classEditor.addProperty("color", "String").setPrettyName("Your favorite color");
        classEditor.clickSaveAndView();
        // Add a new property.
        classEditor = classSheetPage.waitUntilPageIsLoaded().clickEditClassLink();
        classEditor.addProperty("age", "Number").setPrettyName("Your current age");
        classEditor.clickSaveAndView();
        // We have to wait for the page to load because Selenium doesn't do it all the time when we click on Save & View
        // (even if the Save & View button triggers a plain form submit; there must be something with the JavaScript
        // code that is executed on submit that interferes with Selenium).
        classSheetPage.waitUntilPageIsLoaded();
        // Assert that the properties are listed.
        Assert.assertTrue(classSheetPage.hasProperty("color", "Your favorite color", "String"));
        Assert.assertTrue(classSheetPage.hasProperty("age", "Your current age", "Number"));
        // Create and bind a sheet.
        classSheetPage = classSheetPage.clickCreateSheetButton().waitUntilPageIsLoaded().clickBindSheetLink().waitUntilPageIsLoaded();
        ViewPage sheetPage = classSheetPage.clickSheetLink();
        Assert.assertEquals(className + " Sheet", sheetPage.getDocumentTitle());
        sheetPage.clickBreadcrumbLink(classTitle);
        classSheetPage.waitUntilPageIsLoaded();
        // Create the template.
        classSheetPage = classSheetPage.clickCreateTemplateButton().waitUntilPageIsLoaded().clickAddObjectToTemplateLink().waitUntilPageIsLoaded();
        ViewPage templatePage = classSheetPage.clickTemplateLink();
        Assert.assertEquals(className + " Template", templatePage.getDocumentTitle());
        // The default edit button should take us to the In-line edit mode.
        templatePage.edit();
        InlinePage editPage = new InlinePage();
        editPage.setValue("color", "red");
        editPage.setValue("age", "13");
        editPage.clickSaveAndContinue();
        editPage.clickBreadcrumbLink(classTitle);
        classSheetPage.waitUntilPageIsLoaded();
        // Create a document based on the class template.
        Assert.assertEquals(spaceName, classSheetPage.getNewPagePicker().getParentInput().getAttribute("value"));
        editPage = classSheetPage.createNewDocument(spaceName, pageName);
        Assert.assertEquals(pageName, editPage.getDocumentTitle());
        Assert.assertEquals("red", editPage.getValue("color"));
        Assert.assertEquals("13", editPage.getValue("age"));
        editPage.setValue("color", "blue");
        editPage.setValue("age", "27");
        ViewPage viewPage = editPage.clickSaveAndView();
        Assert.assertEquals(pageName, viewPage.getDocumentTitle());
        Assert.assertEquals("Your favorite color\nblue\nYour current age\n27", viewPage.getContent());
        viewPage.clickBreadcrumbLink(classTitle);
        classSheetPage.waitUntilPageIsLoaded();
        // Assert the created document is listed.
        Assert.assertTrue(classSheetPage.hasDocument(pageName));
    } finally {
        getUtil().setHierarchyMode("reference");
    }
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) InlinePage(org.xwiki.test.ui.po.InlinePage) ClassSheetPage(org.xwiki.xclass.test.po.ClassSheetPage) ViewPage(org.xwiki.test.ui.po.ViewPage) DataTypesPage(org.xwiki.xclass.test.po.DataTypesPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 5 with ClassEditPage

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

the class EditObjectsTest method testChangeNumberType.

/**
 * Tests that XWIKI-2214 remains fixed.
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeNumberType() {
    // Create class page
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestClass");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add class
    ClassEditPage cep = vp.editClass();
    cep.addProperty("prop", "Number");
    cep.getNumberClassEditElement("prop").setNumberType("integer");
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Create object page
    wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
    wep.setContent("this is the content: {{velocity}}$doc.display('prop'){{/velocity}}");
    vp = wep.clickSaveAndView();
    // Add object
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
    objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "3");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 3", vp.getContent());
    // Change number to double type
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getNumberClassEditElement("prop").setNumberType("double");
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Verify conversion
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "2.5");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 2.5", vp.getContent());
    // Change number to long type
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getNumberClassEditElement("prop").setNumberType("long");
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Verify conversion
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 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) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) FormElement(org.xwiki.test.ui.po.FormElement) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Aggregations

ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)11 Test (org.junit.Test)10 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)9 FormElement (org.xwiki.test.ui.po.FormElement)7 ViewPage (org.xwiki.test.ui.po.ViewPage)7 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)5 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)5 InlinePage (org.xwiki.test.ui.po.InlinePage)2 ObjectEditPane (org.xwiki.test.ui.po.editor.ObjectEditPane)2 StaticListClassEditElement (org.xwiki.test.ui.po.editor.StaticListClassEditElement)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 AddTagsPane (org.xwiki.tag.test.po.AddTagsPane)1 TaggablePage (org.xwiki.tag.test.po.TaggablePage)1 AbstractTest (org.xwiki.test.ui.AbstractTest)1 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)1 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)1 CommentsTab (org.xwiki.test.ui.po.CommentsTab)1 PreviewEditPage (org.xwiki.test.ui.po.editor.PreviewEditPage)1