Search in sources :

Example 41 with ViewPage

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

the class ApplicationsPanelEntryTest method testApplicationPanelEntry.

@Test
public void testApplicationPanelEntry() {
    // Test the icon remains the same between edits
    editPage.setIcon("icon:bell");
    editPage.clickSaveAndView();
    getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit");
    Assert.assertEquals("icon:bell", editPage.getIcon());
    ApplicationsPanel panel = ApplicationsPanel.gotoPage();
    ViewPage page = panel.clickApplication(getTestClassName());
    // Verify we're on the right page!
    Assert.assertEquals(getTestClassName(), page.getMetaDataValue("space"));
    Assert.assertEquals(getTestMethodName(), page.getMetaDataValue("page"));
}
Also used : ApplicationsPanel(org.xwiki.panels.test.po.ApplicationsPanel) ViewPage(org.xwiki.test.ui.po.ViewPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 42 with ViewPage

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

the class ClassEditorTest method testFieldNameAutoGeneration.

/**
 * Tests that fields names are auto-generated properly.
 */
@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 testFieldNameAutoGeneration() {
    // Add a class field and set its name to an auto-generated field name for a different type.
    ClassFieldEditPane field = editor.addField("Short Text");
    field.openConfigPanel();
    field.setName("number1");
    editor.clickSaveAndContinue();
    // Add a new field of the type implied by the name set to the previous field.
    field = editor.addField("Number");
    field.openConfigPanel();
    Assert.assertEquals("number2", field.getName());
    // Save and assert both fields have been added.
    ViewPage viewer = editor.clickSaveAndView();
    Assert.assertTrue(viewer.getContent().contains("Short Text (number1: String)"));
    Assert.assertTrue(viewer.getContent().contains("Number (number2: Number)"));
}
Also used : LongTextClassFieldEditPane(org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) ViewPage(org.xwiki.test.ui.po.ViewPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 43 with ViewPage

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

the class ClassEditorTest method testReorderFields.

/**
 * Tests that class fields can be reordered.
 */
@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 testReorderFields() {
    // Add two class fields.
    editor.addField("Date").setPrettyName("Start Date");
    editor.addField("Date").setPrettyName("End Date");
    // Save and edit the class template in in-line edit mode.
    editor.clickSaveAndView();
    new ClassSheetPage().clickTemplateLink().edit();
    // Assert the order of the form fields.
    List<String> fieldNames = new EntryEditPage().getFieldNames();
    Assert.assertEquals("date1", fieldNames.get(0));
    Assert.assertEquals("date2", fieldNames.get(1));
    // Go back to the class editor.
    getDriver().navigate().back();
    getDriver().navigate().back();
    new ViewPage().edit();
    editor = new ApplicationClassEditPage();
    // Change the order of the class fields.
    editor.moveFieldBefore("date2", "date1");
    // Save and edit the class template again.
    editor.clickSaveAndView();
    new ClassSheetPage().clickTemplateLink().edit();
    // Assert the order of the form fields.
    fieldNames = new EntryEditPage().getFieldNames();
    Assert.assertEquals("date2", fieldNames.get(0));
    Assert.assertEquals("date1", fieldNames.get(1));
}
Also used : EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) 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)

Example 44 with ViewPage

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

the class EditObjectsTest method testChangeNumberType.

/**
 * Tests that XWIKI-2214 remains fixed.
 */
@Test
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason = "See https://jira.xwiki.org/browse/XE-1146")
public void testChangeNumberType() {
    // Create class page
    WikiEditPage wep = WikiEditPage.gotoPage("Test", "EditObjectsTestClass");
    wep.setContent("this is the content");
    ViewPage vp = wep.clickSaveAndView();
    // Add class
    ClassEditPage cep = vp.editClass();
    cep.addProperty("prop", "Number");
    cep.getNumberClassEditElement("prop").setNumberType("integer");
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Create object page
    wep = WikiEditPage.gotoPage("Test", "EditObjectsTestObject");
    wep.setContent("this is the content: {{velocity}}$doc.display('prop'){{/velocity}}");
    vp = wep.clickSaveAndView();
    // Add object
    ObjectEditPage oep = vp.editObjects();
    FormElement objectForm = oep.addObject("Test.EditObjectsTestClass");
    objectForm.setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "3");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 3", vp.getContent());
    // Change number to double type
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getNumberClassEditElement("prop").setNumberType("double");
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Verify conversion
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    oep.getObjectsOfClass("Test.EditObjectsTestClass").get(0).setFieldValue(By.id("Test.EditObjectsTestClass_0_prop"), "2.5");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 2.5", vp.getContent());
    // Change number to long type
    cep = ClassEditPage.gotoPage("Test", "EditObjectsTestClass");
    cep.getNumberClassEditElement("prop").setNumberType("long");
    vp = cep.clickSaveAndView();
    Assert.assertEquals("this is the content", vp.getContent());
    // Verify conversion
    oep = ObjectEditPage.gotoPage("Test", "EditObjectsTestObject");
    vp = oep.clickSaveAndView();
    Assert.assertEquals("this is the content: 2", vp.getContent());
}
Also used : ClassEditPage(org.xwiki.test.ui.po.editor.ClassEditPage) 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) Test(org.junit.Test) IgnoreBrowser(org.xwiki.test.ui.browser.IgnoreBrowser)

Example 45 with ViewPage

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

the class LanguageTest method checkLanguageTagsArePresent.

/**
 * Assert that the given <code>language</code> is present in various attributes and tags on the page
 *
 * @param language the language to use, should be a valid language, e.g. "en"
 */
private void checkLanguageTagsArePresent(String language) {
    WebElement html = getDriver().findElement(By.tagName("html"));
    Assert.assertEquals(language, html.getAttribute("lang"));
    Assert.assertEquals(language, html.getAttribute("xml:lang"));
    ViewPage vp = new ViewPage();
    // For retro-compatibility only
    Assert.assertEquals(language, vp.getHTMLMetaDataValue("language"));
    String content = getDriver().getPageSource();
    Assert.assertTrue(content.contains("language=" + language));
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) WebElement(org.openqa.selenium.WebElement)

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