Search in sources :

Example 1 with PreviewableEditPage

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

Test (org.junit.Test)1 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 InlinePage (org.xwiki.test.ui.po.InlinePage)1 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)1 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)1 ObjectEditPane (org.xwiki.test.ui.po.editor.ObjectEditPane)1 PreviewEditPage (org.xwiki.test.ui.po.editor.PreviewEditPage)1 PreviewableEditPage (org.xwiki.test.ui.po.editor.PreviewableEditPage)1