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());
}
Aggregations