Search in sources :

Example 1 with ApplicationHomeEditPage

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

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

the class LiveTableEditorTest method testNoColumns.

/**
 * Tests that the live table isn't generated if the list of columns is empty.
 */
@Test
public void testNoColumns() {
    // Make sure the list of columns is empty.
    editQueryStringParameters.put("AppWithinMinutes.LiveTableClass_0_columns", "");
    getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", editQueryStringParameters);
    // Wait for the page to load before clicking on the save button to be sure the page layout is stable.
    ApplicationHomePage viewPage = new ApplicationHomeEditPage().waitUntilPageIsLoaded().clickSaveAndView();
    Assert.assertFalse(viewPage.hasEntriesLiveTable());
    Assert.assertEquals("", viewPage.editWiki().getContent());
}
Also used : 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 3 with ApplicationHomeEditPage

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

the class AddEntryTest method setUp.

@Before
public void setUp() throws Exception {
    getUtil().rest().deletePage(getTestClassName(), getTestMethodName());
    Map<String, String> editQueryStringParameters = new HashMap<String, String>();
    editQueryStringParameters.put("editor", "inline");
    editQueryStringParameters.put("template", "AppWithinMinutes.LiveTableTemplate");
    editQueryStringParameters.put("AppWithinMinutes.LiveTableClass_0_class", "Panels.PanelClass");
    getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", editQueryStringParameters);
    // Wait for the page to load before clicking on the save button to make sure the page layout is stable.
    homePage = new ApplicationHomeEditPage().waitUntilPageIsLoaded().clickSaveAndView();
}
Also used : HashMap(java.util.HashMap) ApplicationHomeEditPage(org.xwiki.appwithinminutes.test.po.ApplicationHomeEditPage) Before(org.junit.Before)

Example 4 with ApplicationHomeEditPage

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

the class LiveTableEditorTest method testDeprecatedColumns.

/**
 * Tests how deprecated columns are handled.
 */
@Test
public void testDeprecatedColumns() {
    // Fake a deprecated column by using a column that doesn't exist.
    editQueryStringParameters.put("AppWithinMinutes.LiveTableClass_0_columns", "doc.name foo");
    getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit", editQueryStringParameters);
    editPage = new ApplicationHomeEditPage().waitUntilPageIsLoaded();
    Assert.assertTrue(editPage.isDeprecatedLiveTableColumnsWarningDisplayed());
    Assert.assertFalse(editPage.isLiveTableColumnDeprecated("Page Name"));
    Assert.assertTrue(editPage.isLiveTableColumnDeprecated("foo"));
    // Keep deprecated columns.
    editPage.removeAllDeprecatedLiveTableColumns(false);
    Assert.assertFalse(editPage.isDeprecatedLiveTableColumnsWarningDisplayed());
    Assert.assertTrue(editPage.isLiveTableColumnDeprecated("foo"));
    ApplicationHomePage viewPage = editPage.clickSaveAndView();
    LiveTableElement liveTable = viewPage.getEntriesLiveTable();
    liveTable.waitUntilReady();
    // The column header isn't translated because we haven't generated the document translation bundle.
    Assert.assertTrue(liveTable.hasColumn("xwikiusers.livetable.foo"));
    // Edit again and remove the deprecated column.
    editPage = viewPage.editInline();
    Assert.assertTrue(editPage.isDeprecatedLiveTableColumnsWarningDisplayed());
    editPage.removeLiveTableColumn("foo");
    Assert.assertFalse(editPage.hasLiveTableColumn("foo"));
    // The warning must disappear if we remove the deprecated column.
    Assert.assertFalse(editPage.isDeprecatedLiveTableColumnsWarningDisplayed());
    // Reload and remove all deprecated columns.
    getDriver().navigate().refresh();
    editPage = new ApplicationHomeEditPage().waitUntilPageIsLoaded();
    editPage.removeAllDeprecatedLiveTableColumns(true);
    Assert.assertFalse(editPage.isDeprecatedLiveTableColumnsWarningDisplayed());
    Assert.assertTrue(editPage.hasLiveTableColumn("Page Name"));
    Assert.assertFalse(editPage.hasLiveTableColumn("foo"));
}
Also used : LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) 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 ApplicationHomeEditPage

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

Aggregations

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