Search in sources :

Example 81 with ViewPage

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

the class SkinxTest method testJavascriptExtension.

/**
 * https://jira.xwiki.org/browse/XWIKI-7913
 */
@Test
public void testJavascriptExtension() {
    // Create a doc
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "SkinxTest");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add an XWikiGroups object
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("XWiki.JavaScriptExtension");
    objectForm.setFieldValue(By.id("XWiki.JavaScriptExtension_0_code"), SCRIPT);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("always");
    oep.clickSaveAndView();
    waitForScriptResult();
    HomePage.gotoPage();
    waitForScriptResult();
    oep = ObjectEditPage.gotoPage("Test", "SkinxTest");
    objectForm = oep.getObjectsOfClass("XWiki.JavaScriptExtension").get(0);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("currentPage");
    oep.clickSaveAndView();
    waitForScriptResult();
    HomePage.gotoPage();
    try {
        waitForScriptResult();
        Assert.fail("The JSX should be active only on the current page.");
    } catch (TimeoutException e) {
    }
    oep = ObjectEditPage.gotoPage("Test", "SkinxTest");
    objectForm = oep.getObjectsOfClass("XWiki.JavaScriptExtension").get(0);
    objectForm.getSelectElement(By.id("XWiki.JavaScriptExtension_0_use")).select("onDemand");
    oep.clickSaveAndView();
    try {
        waitForScriptResult();
        Assert.fail("The JSX should be active only on demand.");
    } catch (TimeoutException e) {
    }
}
Also used : ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) FormElement(org.xwiki.test.ui.po.FormElement) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 82 with ViewPage

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

the class VersionTest method testDeleteLatestVersion.

/**
 * See XWIKI-8781
 */
@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 testDeleteLatestVersion() throws Exception {
    getUtil().rest().deletePage(SPACE_NAME, PAGE_NAME);
    // Create first version of the page
    ViewPage vp = getUtil().createPage(SPACE_NAME, PAGE_NAME, CONTENT1, TITLE);
    // Adds second version
    WikiEditPage wikiEditPage = vp.editWiki();
    wikiEditPage.setContent(CONTENT2);
    wikiEditPage.clickSaveAndView();
    // TODO: Remove when XWIKI-6688 (Possible race condition when clicking on a tab at the bottom of a page in
    // view mode) is fixed.
    vp.waitForDocExtraPaneActive("comments");
    // Verify and delete the latest version.
    HistoryPane historyTab = vp.openHistoryDocExtraPane();
    Assert.assertEquals("2.1", historyTab.getCurrentVersion());
    historyTab = historyTab.deleteVersion("2.1");
    // Verify that the current version is now the previous one.
    Assert.assertEquals("1.1", historyTab.getCurrentVersion());
    Assert.assertEquals("Administrator", historyTab.getCurrentAuthor());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) HistoryPane(org.xwiki.test.ui.po.HistoryPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 83 with ViewPage

use of org.xwiki.test.ui.po.ViewPage 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 84 with ViewPage

use of org.xwiki.test.ui.po.ViewPage 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 85 with ViewPage

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

the class ClassEditorTest method testRenameField.

/**
 * Tests that class fields can be renamed.
 */
@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 testRenameField() {
    // Add a class field.
    editor.addField("Number").setDefaultValue("13");
    // Save and edit the class template.
    editor.clickSaveAndView();
    new ClassSheetPage().clickTemplateLink().edit();
    // Change the field value.
    EntryEditPage inlineEditor = new EntryEditPage();
    Assert.assertEquals("13", inlineEditor.getValue("number1"));
    inlineEditor.setValue("number1", "27");
    // Save and edit again the class.
    inlineEditor.clickSaveAndView();
    getUtil().gotoPage(getTestClassName(), getTestMethodName());
    new ViewPage().edit();
    // Rename the class field.
    ClassFieldEditPane field = new ClassFieldEditPane("number1");
    field.openConfigPanel();
    field.setName("age");
    // Save and edit again the class template.
    new ApplicationClassEditPage().clickSaveAndView();
    new ClassSheetPage().clickTemplateLink().edit();
    Assert.assertEquals("27", new EntryEditPage().getValue("age"));
}
Also used : EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) LongTextClassFieldEditPane(org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) ClassSheetPage(org.xwiki.xclass.test.po.ClassSheetPage) 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)

Aggregations

ViewPage (org.xwiki.test.ui.po.ViewPage)93 Test (org.junit.Test)75 AbstractTest (org.xwiki.test.ui.AbstractTest)41 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)26 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)18 ObjectEditPage (org.xwiki.test.ui.po.editor.ObjectEditPage)11 IgnoreBrowser (org.xwiki.test.ui.browser.IgnoreBrowser)10 DocumentReference (org.xwiki.model.reference.DocumentReference)8 CreatePagePage (org.xwiki.test.ui.po.CreatePagePage)8 FormElement (org.xwiki.test.ui.po.FormElement)7 HistoryPane (org.xwiki.test.ui.po.HistoryPane)7 ClassEditPage (org.xwiki.test.ui.po.editor.ClassEditPage)7 WebElement (org.openqa.selenium.WebElement)6 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)6 AttachmentsPane (org.xwiki.test.ui.po.AttachmentsPane)6 URL (java.net.URL)5 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)5 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)5 ExtensionId (org.xwiki.extension.ExtensionId)5 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)5