Search in sources :

Example 1 with EntryNamePane

use of org.xwiki.appwithinminutes.test.po.EntryNamePane 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 EntryNamePane

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

the class AddEntryTest method testEntryNameWithURLSpecialCharacters.

/**
 * Tests that entry name is URL encoded.
 */
@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 testEntryNameWithURLSpecialCharacters() {
    EntryNamePane entryNamePane = homePage.clickAddNewEntry();
    String entryName = "A?b=c&d#" + RandomStringUtils.randomAlphanumeric(3);
    entryNamePane.setName(entryName);
    EntryEditPage entryEditPage = entryNamePane.clickAdd();
    entryEditPage.setValue("description", "This is a test panel.");
    entryEditPage.clickSaveAndView();
    getUtil().gotoPage(getTestClassName(), getTestMethodName());
    homePage = new ApplicationHomePage();
    LiveTableElement entriesLiveTable = homePage.getEntriesLiveTable();
    entriesLiveTable.waitUntilReady();
    // The column header is not translated because we haven't generated the document translation bundle.
    Assert.assertTrue(entriesLiveTable.hasRow("panel.livetable.doc.title", entryName));
}
Also used : EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) EntryNamePane(org.xwiki.appwithinminutes.test.po.EntryNamePane) ApplicationHomePage(org.xwiki.appwithinminutes.test.po.ApplicationHomePage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 3 with EntryNamePane

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

the class LiveTableGeneratorTest method titleField.

/**
 * @see "XWIKI-8728: AWM home page does not list entries when \"Title\" column is set to be the first one"
 */
@Test
public void titleField() {
    // Create an application that has a Title field and add a corresponding column to the live table.
    classEditPage.addField("Title");
    ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded();
    homeEditPage.addLiveTableColumn("Title");
    homeEditPage.moveLiveTableColumnBefore("Title", "Page Title");
    // Add first entry.
    EntryNamePane entryNamePane = homeEditPage.clickFinish().clickAddNewEntry();
    entryNamePane.setName("Foo");
    EntryEditPage entryEditPage = entryNamePane.clickAdd();
    entryEditPage.setTitle("The Mighty Foo");
    entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName);
    // Add second entry.
    entryNamePane = new ApplicationHomePage().clickAddNewEntry();
    entryNamePane.setName("Bar");
    entryEditPage = entryNamePane.clickAdd();
    entryEditPage.setTitle("The Empty Bar");
    entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName);
    // Filter the Title column of the live table.
    LiveTableElement liveTable = new ApplicationHomePage().getEntriesLiveTable();
    liveTable.waitUntilReady();
    Assert.assertEquals(2, liveTable.getRowCount());
    String filterInputId = getFilterInputId(0);
    liveTable.filterColumn(filterInputId, "mighty");
    Assert.assertEquals(1, liveTable.getRowCount());
    Assert.assertTrue(liveTable.hasRow("Location", appName + "Foo"));
    liveTable.filterColumn(filterInputId, "empty");
    Assert.assertEquals(1, liveTable.getRowCount());
    Assert.assertTrue(liveTable.hasRow("Location", appName + "Bar"));
    liveTable.filterColumn(filterInputId, "");
    Assert.assertEquals(2, liveTable.getRowCount());
}
Also used : EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) EntryNamePane(org.xwiki.appwithinminutes.test.po.EntryNamePane) ApplicationHomeEditPage(org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage) ApplicationHomePage(org.xwiki.appwithinminutes.test.po.ApplicationHomePage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 4 with EntryNamePane

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

the class LiveTableGeneratorTest method filterStaticList.

/**
 * @see "XWIKI-8616: Filter a static list in an AWM livetable does not work."
 */
@Test
public void filterStaticList() {
    // Create an application that has a Static List field and add a corresponding column to the live table.
    classEditPage.addField("Static List");
    ApplicationHomeEditPage homeEditPage = classEditPage.clickNextStep().clickNextStep().waitUntilPageIsLoaded();
    homeEditPage.addLiveTableColumn("Static List");
    // Add first entry.
    EntryNamePane entryNamePane = homeEditPage.clickFinish().clickAddNewEntry();
    entryNamePane.setName("Foo");
    EntryEditPage entryEditPage = entryNamePane.clickAdd();
    entryEditPage.setValue("staticList1", "value1");
    entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName);
    // Add second entry.
    entryNamePane = new ApplicationHomePage().clickAddNewEntry();
    entryNamePane.setName("Bar");
    entryEditPage = entryNamePane.clickAdd();
    entryEditPage.setValue("staticList1", "value2");
    entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName);
    // Filter the Static List column of the live table.
    LiveTableElement liveTable = new ApplicationHomePage().getEntriesLiveTable();
    liveTable.waitUntilReady();
    Assert.assertEquals(2, liveTable.getRowCount());
    String filterInputId = getFilterInputId(liveTable.getColumnIndex("Static List"));
    liveTable.filterColumn(filterInputId, "Second Choice");
    Assert.assertEquals(1, liveTable.getRowCount());
    Assert.assertTrue(liveTable.hasRow("Page Title", "Bar"));
    liveTable.filterColumn(filterInputId, "First Choice");
    Assert.assertEquals(1, liveTable.getRowCount());
    Assert.assertTrue(liveTable.hasRow("Page Title", "Foo"));
    liveTable.filterColumn(filterInputId, "All");
    Assert.assertEquals(2, liveTable.getRowCount());
}
Also used : EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) EntryNamePane(org.xwiki.appwithinminutes.test.po.EntryNamePane) ApplicationHomeEditPage(org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage) ApplicationHomePage(org.xwiki.appwithinminutes.test.po.ApplicationHomePage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 5 with EntryNamePane

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

the class WizardTest method testCreateApplication.

/**
 * Tests the application creation process from start to end.
 */
@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 testCreateApplication() {
    // Step 1
    // Set the application location.
    appCreatePage.getLocationPicker().browseDocuments();
    new DocumentPickerModal().selectDocument(getClass().getSimpleName(), this.testName.getMethodName(), "WebHome");
    appCreatePage.getLocationPicker().waitForLocation(Arrays.asList("", getClass().getSimpleName(), this.testName.getMethodName(), ""));
    // Enter the application name, making sure we also use some special chars.
    // See XWIKI-11747: Impossible to create new entry with an application having UTF8 chars in its name
    String appName = "Cities âé";
    String[] appPath = new String[] { getClass().getSimpleName(), this.testName.getMethodName(), appName };
    appCreatePage.setApplicationName(appName);
    // Wait for the preview.
    appCreatePage.waitForApplicationNamePreview();
    // Move to the next step.
    ApplicationClassEditPage classEditPage = appCreatePage.clickNextStep();
    // Step 2
    // Add a 'Short Text' field.
    ClassFieldEditPane fieldEditPane = classEditPage.addField("Short Text");
    // Set the field pretty name and default value
    fieldEditPane.setPrettyName("City Name");
    fieldEditPane.setDefaultValue("Paris");
    // Move to the next step.
    ApplicationTemplateProviderEditPage templateProviderEditPage = classEditPage.clickNextStep();
    // Move back to the second step.
    classEditPage = templateProviderEditPage.clickPreviousStep();
    // Open the configuration panel and set the field name
    fieldEditPane = new ClassFieldEditPane("shortText1");
    fieldEditPane.openConfigPanel();
    fieldEditPane.setName("cityName");
    // Move to the next step.
    templateProviderEditPage = classEditPage.clickNextStep();
    // Step 3
    templateProviderEditPage.setIcon("worl");
    templateProviderEditPage.setDescription("A city page");
    // Move to the next step.
    ApplicationHomeEditPage homeEditPage = templateProviderEditPage.clickNextStep().waitUntilPageIsLoaded();
    // Step 4
    // Enter the application description.
    String appDescription = "Simple application to manage data about various cities";
    homeEditPage.setDescription(appDescription);
    // Add the Short Text field from the previous step to the list of columns.
    homeEditPage.addLiveTableColumn("City Name");
    // Click the finish button which should lead us to the application home page.
    ApplicationHomePage homePage = homeEditPage.clickFinish();
    // Assert the application description is present.
    Assert.assertTrue(homePage.getContent().contains(appDescription));
    // Add a new entry.
    String firstEntryName = "City 1 âé";
    EntryNamePane entryNamePane = homePage.clickAddNewEntry();
    entryNamePane.setName(firstEntryName);
    EntryEditPage entryEditPage = entryNamePane.clickAdd();
    // Assert the pretty name and the default value of the Short Text field.
    // Apparently WebElement#getText() takes into account the text-transform CSS property.
    Assert.assertEquals("CITY NAME", entryEditPage.getLabel("cityName"));
    Assert.assertEquals("Paris", entryEditPage.getValue("cityName"));
    // Change the field value.
    entryEditPage.setValue("cityName", "London");
    // Save and go back to the application home page.
    entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName);
    homePage = new ApplicationHomePage();
    // Assert the entry we have just created is listed in the live table.
    LiveTableElement entriesLiveTable = homePage.getEntriesLiveTable();
    entriesLiveTable.waitUntilReady();
    Assert.assertTrue(entriesLiveTable.hasRow("City Name", "London"));
    // Assert that only the entry we have just created is listed as child of the application home page. The rest of
    // the documents (class, template, sheet, preferences) should be marked as hidden.
    PagesLiveTableElement childrenLiveTable = homePage.viewChildren().getLiveTable();
    childrenLiveTable.waitUntilReady();
    Assert.assertEquals(1, childrenLiveTable.getRowCount());
    Assert.assertTrue(childrenLiveTable.hasPageWithTitle(firstEntryName));
    // Go back to the application home page.
    getDriver().navigate().back();
    // Click the edit button.
    homePage.edit();
    homeEditPage = new ApplicationHomeEditPage();
    // Change the application description.
    appDescription = "The best app!";
    homeEditPage.setDescription(appDescription);
    // Remove one of the live table columns.
    homeEditPage.removeLiveTableColumn("Actions");
    // Save
    homePage = homeEditPage.clickSaveAndView();
    // Assert that the application description has changed and that the column has been removed.
    Assert.assertTrue(homePage.getContent().contains(appDescription));
    entriesLiveTable = homePage.getEntriesLiveTable();
    entriesLiveTable.waitUntilReady();
    Assert.assertFalse(entriesLiveTable.hasColumn("Actions"));
    // Click the link to edit the application.
    classEditPage = homePage.clickEditApplication();
    // Drag a Number field.
    fieldEditPane = classEditPage.addField("Number");
    // Set the field pretty name.
    fieldEditPane.setPrettyName("Population Size");
    // Fast forward.
    homeEditPage = classEditPage.clickNextStep().clickNextStep();
    // Just wait for the WYSIWYG editor (which is used for setting the application description) to load so that the
    // page layout is stable before we click on the Finish button.
    homeEditPage.setDescription(appDescription);
    homePage = homeEditPage.clickFinish();
    // Add a new entry.
    String secondEntryName = "City 2 âé";
    entryNamePane = homePage.clickAddNewEntry();
    entryNamePane.setName(secondEntryName);
    entryEditPage = entryNamePane.clickAdd();
    // Assert the new field is displayed in the edit sheet (field name was auto-generated).
    // Apparently WebElement#getText() takes into account the text-transform CSS property.
    Assert.assertEquals("POPULATION SIZE", entryEditPage.getLabel("number1"));
    // Save and go back to the application home page.
    entryEditPage.clickSaveAndView().clickBreadcrumbLink(appName);
    homePage = new ApplicationHomePage();
    // Assert both entries are displayed in the live table.
    entriesLiveTable = homePage.getEntriesLiveTable();
    entriesLiveTable.waitUntilReady();
    Assert.assertTrue(entriesLiveTable.hasRow("Page Title", firstEntryName));
    Assert.assertTrue(entriesLiveTable.hasRow("Page Title", secondEntryName));
    // Go to the App Within Minutes home page.
    AppWithinMinutesHomePage appWithinMinutesHomePage = AppWithinMinutesHomePage.gotoPage();
    // Assert that the created application is listed in the live table.
    ApplicationsLiveTableElement appsLiveTable = appWithinMinutesHomePage.getAppsLiveTable();
    appsLiveTable.waitUntilReady();
    Assert.assertTrue(appsLiveTable.isApplicationListed(appPath));
    // Delete the application entries.
    homePage = appsLiveTable.viewApplication(appPath);
    homePage.clickDeleteAllEntries().clickYes();
    // Verify that the entries live table is empty.
    entriesLiveTable = homePage.getEntriesLiveTable();
    entriesLiveTable.waitUntilReady();
    Assert.assertEquals(0, entriesLiveTable.getRowCount());
    // Delete the application.
    homePage.clickDeleteApplication().clickYes();
    // Verify that the application is not listed anymore.
    appsLiveTable = AppWithinMinutesHomePage.gotoPage().getAppsLiveTable();
    appsLiveTable.waitUntilReady();
    Assert.assertFalse(appsLiveTable.isApplicationListed(appPath));
}
Also used : EntryEditPage(org.xwiki.appwithinminutes.test.po.EntryEditPage) ApplicationsLiveTableElement(org.xwiki.appwithinminutes.test.po.ApplicationsLiveTableElement) PagesLiveTableElement(org.xwiki.test.ui.po.PagesLiveTableElement) LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) EntryNamePane(org.xwiki.appwithinminutes.test.po.EntryNamePane) ApplicationTemplateProviderEditPage(org.xwiki.appwithinminutes.test.po.ApplicationTemplateProviderEditPage) ClassFieldEditPane(org.xwiki.appwithinminutes.test.po.ClassFieldEditPane) AppWithinMinutesHomePage(org.xwiki.appwithinminutes.test.po.AppWithinMinutesHomePage) DocumentPickerModal(org.xwiki.index.tree.test.po.DocumentPickerModal) ApplicationHomeEditPage(org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage) ApplicationsLiveTableElement(org.xwiki.appwithinminutes.test.po.ApplicationsLiveTableElement) PagesLiveTableElement(org.xwiki.test.ui.po.PagesLiveTableElement) ApplicationHomePage(org.xwiki.appwithinminutes.test.po.ApplicationHomePage) ApplicationClassEditPage(org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Aggregations

Test (org.junit.Test)5 ApplicationHomePage (org.xwiki.appwithinminutes.test.po.ApplicationHomePage)5 EntryEditPage (org.xwiki.appwithinminutes.test.po.EntryEditPage)5 EntryNamePane (org.xwiki.appwithinminutes.test.po.EntryNamePane)5 AbstractTest (org.xwiki.test.ui.AbstractTest)5 LiveTableElement (org.xwiki.test.ui.po.LiveTableElement)5 ApplicationHomeEditPage (org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage)4 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)2 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)2 IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)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 ApplicationsLiveTableElement (org.xwiki.appwithinminutes.test.po.ApplicationsLiveTableElement)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 ViewPage (org.xwiki.test.ui.po.ViewPage)1 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)1