Search in sources :

Example 6 with ObjectEditPane

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

the class PreviewTest method previewWithSheet.

/**
 * @see "XWIKI-9527: Sheets are not applied on preview action if the document is new"
 */
@Test
public void previewWithSheet() throws Exception {
    // Create the class.
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName() + "Class");
    ClassEditPage classEditor = ClassEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Class");
    classEditor.addProperty("color", "String");
    // Create the sheet.
    getUtil().rest().savePage(new LocalDocumentReference(getTestClassName(), getTestMethodName() + "Sheet"), "{{velocity}}$doc.display('color'){{/velocity}}", "");
    // Bind the class to the sheet.
    ObjectEditPage objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Class");
    ObjectEditPane objectEditPane = objectEditor.addObject("XWiki.ClassSheetBinding");
    objectEditPane.setFieldValue(objectEditPane.byPropertyName("sheet"), getTestClassName() + "." + getTestMethodName() + "Sheet");
    objectEditor.clickSaveAndContinue();
    // Create the template.
    String classFullName = getTestClassName() + "." + getTestMethodName() + "Class";
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName() + "Template");
    objectEditor = ObjectEditPage.gotoPage(getTestClassName(), getTestMethodName() + "Template");
    objectEditPane = objectEditor.addObject(classFullName);
    objectEditPane.setFieldValue(objectEditPane.byPropertyName("color"), "red");
    objectEditor.clickSaveAndContinue();
    // Create the test instance.
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
    getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", "template=" + getTestClassName() + "." + getTestMethodName() + "Template");
    objectEditPane = new ObjectEditPane(new InlinePage().getForm(), classFullName, 0);
    objectEditPane.setFieldValue(objectEditPane.byPropertyName("color"), "green");
    // Test the preview when the page is not yet saved.
    PreviewableEditPage editPage = new PreviewableEditPage();
    PreviewEditPage previewPage = editPage.clickPreview();
    assertEquals("green", previewPage.getContent());
    // Test the preview after the page is saved.
    previewPage.clickBackToEdit().clickSaveAndView().editInline().clickPreview();
    assertEquals("green", previewPage.getContent());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) ObjectEditPane(org.xwiki.test.ui.po.editor.ObjectEditPane) PreviewableEditPage(org.xwiki.test.ui.po.editor.PreviewableEditPage) ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) PreviewEditPage(org.xwiki.test.ui.po.editor.PreviewEditPage) InlinePage(org.xwiki.test.ui.po.InlinePage) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) Test(org.junit.Test)

Aggregations

ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)6 ObjectEditPane (org.xwiki.test.ui.po.editor.ObjectEditPane)6 Test (org.junit.Test)3 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)2 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)2 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)1 FormElement (org.xwiki.test.ui.po.FormElement)1 InlinePage (org.xwiki.test.ui.po.InlinePage)1 ViewPage (org.xwiki.test.ui.po.ViewPage)1 PreviewEditPage (org.xwiki.test.ui.po.editor.PreviewEditPage)1 PreviewableEditPage (org.xwiki.test.ui.po.editor.PreviewableEditPage)1