Search in sources :

Example 6 with ClassFieldEditPane

use of org.xwiki.appwithinminutes.test.po.ClassFieldEditPane in project xwiki-platform by xwiki.

the class ClassEditorTest method testDeleteField.

/**
 * Tests that class fields can be deleted and that documents having objects of that class are updated.
 */
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testDeleteField() {
    // Add two fields.
    editor.addField("Boolean").setPrettyName("Available");
    editor.addField("Date").setPrettyName("Day");
    // Save and assert they are present.
    ViewPage classView = editor.clickSaveAndView();
    Assert.assertTrue(classView.getContent().contains("Available (boolean1: Boolean)"));
    Assert.assertTrue(classView.getContent().contains("Day (date1: Date)"));
    // Edit again and delete one of the fields.
    classView.edit();
    new ClassFieldEditPane("boolean1").delete().clickYes();
    // Save and check if the field was removed.
    classView = new ApplicationClassEditPage().clickSaveAndView();
    Assert.assertFalse(classView.getContent().contains("Available (boolean1: Boolean)"));
    Assert.assertTrue(classView.getContent().contains("Day (date1: Date)"));
    // Edit the class template and see if the deleted field is now deprecated.
    ObjectEditPage objectEditor = new ClassSheetPage().clickTemplateLink().editObjects();
    String className = String.format("%s.%s", getTestClassName(), getTestMethodName());
    Assert.assertTrue(objectEditor.isPropertyDeprecated(className, "boolean1"));
    Assert.assertFalse(objectEditor.isPropertyDeprecated(className, "date1"));
}
Also used : LongTextClassFieldEditPane(org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) ClassSheetPage(org.xwiki.xclass.test.po.ClassSheetPage) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 7 with ClassFieldEditPane

use of org.xwiki.appwithinminutes.test.po.ClassFieldEditPane in project xwiki-platform by xwiki.

the class ClassEditorTest method testInvalidFieldName.

/**
 * Tests that invalid field names are not allowed.
 */
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testInvalidFieldName() {
    String invalidFieldNameErrorMessage = "Property names must follow these naming rules:";
    ClassFieldEditPane field = editor.addField("Static List");
    field.openConfigPanel();
    field.setName("3times");
    // Save the page and expect the error.
    editor.getSaveAndViewButton().click();
    waitForPageSourceContains(invalidFieldNameErrorMessage);
    getDriver().navigate().back();
    editor = new ApplicationClassEditPage();
    field = editor.addField("User");
    field.openConfigPanel();
    // Unfortunately we don't allow Unicode letters because they are not fully supported in tag names.
    // See XWIKI-7306: The class editor doesn't validate properly the field names
    field.setName("\u021Bar\u0103");
    // Save the page and expect the error.
    editor.getSaveAndViewButton().click();
    waitForPageSourceContains(invalidFieldNameErrorMessage);
    getDriver().navigate().back();
    editor = new ApplicationClassEditPage();
    field = editor.addField("Group");
    field.openConfigPanel();
    field.setName("alice>bob");
    // Save the page and expect the error.
    editor.getSaveAndViewButton().click();
    waitForPageSourceContains(invalidFieldNameErrorMessage);
}
Also used : LongTextClassFieldEditPane(org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 8 with ClassFieldEditPane

use of org.xwiki.appwithinminutes.test.po.ClassFieldEditPane in project xwiki-platform by xwiki.

the class ClassEditorTest method testEmptyCanvasHint.

/**
 * Tests that the hint is displayed only when the canvas is empty.
 */
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testEmptyCanvasHint() {
    Assert.assertTrue(editor.getContent().contains(EMPTY_CANVAS_HINT));
    ClassFieldEditPane field = editor.addField("Short Text");
    Assert.assertFalse(editor.getContent().contains(EMPTY_CANVAS_HINT));
    field.delete().clickYes();
    Assert.assertTrue(editor.getContent().contains(EMPTY_CANVAS_HINT));
}
Also used : LongTextClassFieldEditPane(org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 9 with ClassFieldEditPane

use of org.xwiki.appwithinminutes.test.po.ClassFieldEditPane in project xwiki-platform by xwiki.

the class ClassEditorTest method testSaveAndContinue.

/**
 * Tests the Save & Continue button.
 */
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testSaveAndContinue() {
    editor.addField("Date");
    editor.clickSaveAndContinue();
    // Check if the field was added.
    ViewPage viewer = editor.clickCancel();
    Assert.assertTrue(viewer.getContent().contains("Date (date1: Date)"));
    // Edit again. This time check the error message.
    viewer.edit();
    editor = new ApplicationClassEditPage();
    // Try to set the field name to an invalid value.
    ClassFieldEditPane field = new ClassFieldEditPane("date1");
    field.openConfigPanel();
    field.setName("-delta");
    editor.clickSaveAndContinue(false);
    editor.waitForNotificationErrorMessage("Failed to save the page.");
    // Double check that the field wasn't renamed.
    Assert.assertTrue(editor.clickCancel().getContent().contains("Date (date1: Date)"));
}
Also used : LongTextClassFieldEditPane(org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) ViewPage(org.xwiki.test.ui.po.ViewPage) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 10 with ClassFieldEditPane

use of org.xwiki.appwithinminutes.test.po.ClassFieldEditPane in project xwiki-platform by xwiki.

the class ClassEditorTest method testSwapFieldNames.

/**
 * Tests that swapping field names is not allowed.
 */
@Test
@IgnoreBrowsers({ @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146"), @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason = "See https://jira.xwiki.org/browse/XE-1177") })
public void testSwapFieldNames() {
    ClassFieldEditPane field = editor.addField("Short Text");
    field.openConfigPanel();
    field.setName("alice");
    field = editor.addField("Number");
    field.openConfigPanel();
    field.setName("bob");
    editor.clickSaveAndView().edit();
    editor = new ApplicationClassEditPage();
    field = new ClassFieldEditPane("alice");
    field.openConfigPanel();
    field.setName("bob");
    field = new ClassFieldEditPane("bob");
    field.openConfigPanel();
    field.setName("alice");
    // Save the page and expect the error.
    editor.getSaveAndViewButton().click();
    waitForPageSourceContains("The class has two fields with the same name: alice");
}
Also used : LongTextClassFieldEditPane(org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)13 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)13 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)12 LongTextClassFieldEditPane (org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane)10 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)9 ViewPage (org.xwiki.test.ui.po.ViewPage)5 EntryEditPage (org.xwiki.appwithinminutes.test.po.EntryEditPage)4 ApplicationHomeEditPage (org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage)3 ApplicationHomePage (org.xwiki.appwithinminutes.test.po.ApplicationHomePage)3 AbstractTest (org.xwiki.test.ui.AbstractTest)3 ClassSheetPage (org.xwiki.xclass.test.po.ClassSheetPage)3 ApplicationsLiveTableElement (org.xwiki.appwithinminutes.test.po.ApplicationsLiveTableElement)2 EntryNamePane (org.xwiki.appwithinminutes.test.po.EntryNamePane)2 LiveTableElement (org.xwiki.test.ui.po.LiveTableElement)2 AppWithinMinutesHomePage (org.xwiki.appwithinminutes.test.po.AppWithinMinutesHomePage)1 ApplicationCreatePage (org.xwiki.appwithinminutes.test.po.ApplicationCreatePage)1 ApplicationTemplateProviderEditPage (org.xwiki.appwithinminutes.test.po.ApplicationTemplateProviderEditPage)1 DocumentPickerModal (org.xwiki.index.tree.test.po.DocumentPickerModal)1 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 PagesLiveTableElement (org.xwiki.test.ui.po.PagesLiveTableElement)1