use of org.xwiki.test.ui.po.InlinePage 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");
}
}
use of org.xwiki.test.ui.po.InlinePage in project xwiki-platform by xwiki.
the class UserClassFieldTest method testApplicationEntry.
@Test
public void testApplicationEntry() {
// Create the application class.
UserPicker userPicker = new UserClassFieldEditPane(editor.addField("User").getName()).getUserPicker();
userPicker.sendKeys("thomas").waitForSuggestions().sendKeys(Keys.ENTER);
editor.clickSaveAndView();
// Create the application entry.
ClassSheetPage classSheetPage = new ClassSheetPage();
InlinePage entryEditPage = classSheetPage.createNewDocument(getTestClassName(), getTestMethodName() + "Entry");
// Assert the initial value.
String id = getTestClassName() + "." + getTestMethodName() + "_0_user1";
userPicker = new UserPicker(getDriver().findElement(By.id(id)));
List<UserElement> selectedUsers = userPicker.waitToLoad().getAcceptedSuggestions();
Assert.assertEquals(1, selectedUsers.size());
assertUserElement(selectedUsers.get(0), "Thomas Mortagne");
Assert.assertEquals("", userPicker.getValue());
// Change the selected user.
userPicker.sendKeys("eduard").waitForSuggestions().sendKeys(Keys.ENTER).waitForSuggestionsToFadeOut();
// We wait for the page to load because Selenium doesn't do it all the time when Save & View is clicked.
entryEditPage.clickSaveAndView().waitUntilPageIsLoaded();
// Assert the view mode.
List<WebElement> users = getDriver().findElements(By.className("user"));
Assert.assertEquals(1, users.size());
assertUserElement(new UserElement(users.get(0)), "Eduard Moraru", "Enygma2002");
}
use of org.xwiki.test.ui.po.InlinePage 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());
}
use of org.xwiki.test.ui.po.InlinePage in project xwiki-platform by xwiki.
the class EditInlineTest method testInlineEditCanChangeTitle.
/* See XE-168 and XWIKI-6992 */
@Test
public void testInlineEditCanChangeTitle() {
String title = RandomStringUtils.randomAlphanumeric(4);
getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", "editor=inline&title=" + title);
InlinePage inlinePage = new InlinePage();
// Check if the title specified on the request is properly displayed.
Assert.assertEquals(title, inlinePage.getDocumentTitle());
// Check if the title specified on the request is displayed in the document hierarchy.
Assert.assertTrue(inlinePage.getBreadcrumbContent().contains(title));
// Save the document and check again the displayed title
ViewPage viewPage = inlinePage.clickSaveAndView();
Assert.assertEquals(title, viewPage.getDocumentTitle());
}
use of org.xwiki.test.ui.po.InlinePage in project xwiki-platform by xwiki.
the class EditInlineTest method testInlineEditPreservesTitle.
/* See XWIKI-2389 */
@Test
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177")
public void testInlineEditPreservesTitle() {
String title = RandomStringUtils.randomAlphanumeric(4);
getUtil().gotoPage(getTestClassName(), getTestMethodName(), "save", "title=" + title);
ViewPage vp = new ViewPage();
Assert.assertEquals(title, vp.getDocumentTitle());
InlinePage ip = vp.editInline();
ViewPage vp2 = ip.clickSaveAndView();
Assert.assertEquals(title, vp2.getDocumentTitle());
}
Aggregations