Search in sources :

Example 1 with ApplicationCreatePage

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

the class DocumentFieldsTest method titleAndContent.

@Test
public void titleAndContent() {
    // Create a new application.
    String appName = RandomStringUtils.randomAlphabetic(6);
    ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
    appCreatePage.setApplicationName(appName);
    appCreatePage.waitForApplicationNamePreview();
    ApplicationClassEditPage classEditPage = appCreatePage.clickNextStep();
    // Add a standard field.
    ClassFieldEditPane numberField = classEditPage.addField("Number");
    // Add the Title and Content fields.
    ClassFieldEditPane titleField = classEditPage.addField("Title");
    ClassFieldEditPane contentField = classEditPage.addField("Content");
    // Change the default field pretty names.
    // See XWIKI-9154: The application live table uses the standard 'Page title' heading instead of the pretty name
    // set for the Title field
    titleField.setPrettyName("My Title");
    contentField.setPrettyName("My Content");
    // Set the default values that will be saved in the template.
    numberField.setDefaultValue("13");
    String defaultTitle = "Enter title here";
    titleField.setDefaultValue(defaultTitle);
    String defaultContent = "Enter content here";
    contentField.setDefaultValue(defaultContent);
    // Add live table columns for Title and Content.
    ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded();
    homeEditPage.addLiveTableColumn("My Title");
    homeEditPage.addLiveTableColumn("My Content");
    // Add an application entry.
    EntryNamePane entryNamePane = homeEditPage.clickFinish().clickAddNewEntry();
    entryNamePane.setName("Test");
    EntryEditPage entryEditPage = entryNamePane.clickAdd();
    Assert.assertEquals("13", entryEditPage.getValue("number1"));
    // The page name is used as the default value for the title field.
    Assert.assertEquals("Test", entryEditPage.getDocumentTitle());
    Assert.assertEquals("Test", entryEditPage.getTitle());
    entryEditPage.setTitle("Foo");
    Assert.assertEquals(defaultContent, entryEditPage.getContent());
    entryEditPage.setContent("Bar");
    // Check that the title and the content of the entry have been updated.
    ViewPage entryViewPage = entryEditPage.clickSaveAndView();
    Assert.assertEquals("Foo", entryViewPage.getDocumentTitle());
    Assert.assertTrue(entryViewPage.getContent().contains("Bar"));
    entryViewPage.clickBreadcrumbLink(appName);
    // Check the entries live table.
    LiveTableElement liveTable = new ApplicationHomePage().getEntriesLiveTable();
    liveTable.waitUntilReady();
    Assert.assertEquals(1, liveTable.getRowCount());
    Assert.assertTrue(liveTable.hasRow("My Title", "Foo"));
    Assert.assertTrue(liveTable.hasRow("My Content", "Bar"));
    // Check that the title and the content of the class have not been changed.
    getUtil().gotoPage(new LocalDocumentReference(Arrays.asList(appName, "Code"), appName + "Class"), "edit", "editor=wiki");
    WikiEditPage editPage = new WikiEditPage();
    Assert.assertEquals(appName + " Class", editPage.getTitle());
    Assert.assertEquals("", editPage.getContent());
    // Now edit the class and check if the default values for title and content are taken from the template.
    editPage.editInline();
    Assert.assertEquals(defaultTitle, new ClassFieldEditPane("title1").getDefaultValue());
    Assert.assertEquals(defaultContent, new ClassFieldEditPane("content1").getDefaultValue());
}
Also used : LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) EntryNamePane(org.xwiki.appwithinminutes.test.po.EntryNamePane) ApplicationHomeEditPage(org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) ApplicationCreatePage(org.xwiki.appwithinminutes.test.po.ApplicationCreatePage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) ApplicationHomePage(org.xwiki.appwithinminutes.test.po.ApplicationHomePage) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 2 with ApplicationCreatePage

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

the class ApplicationNameTest method testEmptyAppNameWithNextStepButton.

/**
 * Try to create an application with an empty name using the next step 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 testEmptyAppNameWithNextStepButton() {
    ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
    Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
    // Try to move to the next step without typing the application name.
    String urlBeforeClick = getDriver().getCurrentUrl();
    appCreatePage.clickNextStepButton();
    Assert.assertEquals(urlBeforeClick, getDriver().getCurrentUrl());
    // Type the application name.
    appCreatePage.setApplicationName("A");
    appCreatePage.waitForApplicationNamePreview();
    Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
    // Clear the application name using the Backspace key.
    appCreatePage.getApplicationNameInput().sendKeys(Keys.BACK_SPACE);
    appCreatePage.waitForApplicationNameError();
    Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
    // Try to create the application even if the error message is displayed.
    urlBeforeClick = getDriver().getCurrentUrl();
    appCreatePage.clickNextStepButton();
    Assert.assertEquals(urlBeforeClick, getDriver().getCurrentUrl());
    // Fix the application name and move to the next step.
    appCreatePage.setApplicationName(getTestMethodName());
    appCreatePage.waitForApplicationNamePreview();
    Assert.assertEquals(getTestMethodName() + " Structure", appCreatePage.clickNextStep().getDocumentTitle());
}
Also used : ApplicationCreatePage(org.xwiki.appwithinminutes.test.po.ApplicationCreatePage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 3 with ApplicationCreatePage

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

the class ApplicationNameTest method testEmptyAppNameWithEnter.

/**
 * Try to create an application with an empty name using the Enter key.
 */
@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 testEmptyAppNameWithEnter() {
    ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
    Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
    // Press Enter key without typing the application name.
    appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
    appCreatePage.waitForApplicationNameError();
    Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
    // Type the application name.
    appCreatePage.setApplicationName("B");
    appCreatePage.waitForApplicationNamePreview();
    Assert.assertFalse(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
    // Clear the application name using the Backspace key.
    appCreatePage.getApplicationNameInput().sendKeys(Keys.BACK_SPACE);
    appCreatePage.waitForApplicationNameError();
    Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
    // Try to create the application even if the error message is displayed.
    appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
    Assert.assertTrue(appCreatePage.getContent().contains(EMPTY_APP_NAME_ERROR_MESSAGE));
    // Fix the application name and move to the next step using the Enter key.
    appCreatePage.setApplicationName(getTestMethodName());
    appCreatePage.waitForApplicationNamePreview();
    appCreatePage.getApplicationNameInput().sendKeys(Keys.RETURN);
    Assert.assertEquals(getTestMethodName() + " Structure", new ViewPage().getDocumentTitle());
}
Also used : ViewPage(org.xwiki.test.ui.po.ViewPage) ApplicationCreatePage(org.xwiki.appwithinminutes.test.po.ApplicationCreatePage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 4 with ApplicationCreatePage

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

the class AppsLiveTableTest method createApplication.

/**
 * Creates an application with the specified name. The application class will have just one field.
 *
 * @param appName the name of the application to create
 */
private void createApplication(String appName) {
    ApplicationCreatePage appCreatePage = homePage.clickCreateApplication();
    appCreatePage.setApplicationName(appName);
    appCreatePage.waitForApplicationNamePreview();
    ApplicationClassEditPage classEditPage = appCreatePage.clickNextStep();
    classEditPage.addField("Short Text");
    classEditPage.clickNextStep().clickNextStep().clickFinish();
    homePage = AppWithinMinutesHomePage.gotoPage();
}
Also used : ApplicationCreatePage(org.xwiki.appwithinminutes.test.po.ApplicationCreatePage) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)

Example 5 with ApplicationCreatePage

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

the class LiveTableGeneratorTest method setUp.

@Before
public void setUp() throws Exception {
    appName = RandomStringUtils.randomAlphabetic(6);
    ApplicationCreatePage appCreatePage = ApplicationCreatePage.gotoPage();
    appCreatePage.setApplicationName(appName);
    appCreatePage.waitForApplicationNamePreview();
    classEditPage = appCreatePage.clickNextStep();
}
Also used : ApplicationCreatePage(org.xwiki.appwithinminutes.test.po.ApplicationCreatePage) Before(org.junit.Before)

Aggregations

ApplicationCreatePage (org.xwiki.appwithinminutes.test.po.ApplicationCreatePage)6 Test (org.junit.Test)4 AbstractTest (org.xwiki.test.ui.AbstractTest)4 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)3 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)2 ViewPage (org.xwiki.test.ui.po.ViewPage)2 Before (org.junit.Before)1 ApplicationHomeEditPage (org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage)1 ApplicationHomePage (org.xwiki.appwithinminutes.test.po.ApplicationHomePage)1 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)1 EntryEditPage (org.xwiki.appwithinminutes.test.po.EntryEditPage)1 EntryNamePane (org.xwiki.appwithinminutes.test.po.EntryNamePane)1 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)1 LiveTableElement (org.xwiki.test.ui.po.LiveTableElement)1 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)1