Search in sources :

Example 51 with IgnoreBrowsers

use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.

the class StaticListClassFieldTest method testItemsEditor.

/**
 * Tests the ability to add, edit and remove list items.
 */
@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 testItemsEditor() {
    // Add a new static list field.
    StaticListClassFieldEditPane staticListField = new StaticListClassFieldEditPane(editor.addField("Static List").getName());
    // Open the configuration panel and edit the list items.
    staticListField.openConfigPanel();
    StaticListItemsEditor itemsEditor = staticListField.getItemsEditor();
    // Remove the second option.
    itemsEditor.remove("value2");
    // Add two new items.
    itemsEditor.add("foo", "bar");
    // Leave the value empty for the second item: it should fall back on the label.
    itemsEditor.add("", "XWiki");
    // Change the label of the last added item.
    itemsEditor.setLabel("XWiki", "XWiki Enterprise");
    // Move the last item before the first.
    itemsEditor.moveBefore("XWiki", "value1");
    Assert.assertEquals(4, itemsEditor.size());
    // Enable multiple selection and change display type to 'select' to check the value of the size property.
    staticListField.getDisplayTypeSelect().selectByVisibleText("select");
    staticListField.getMultipleSelectionCheckBox().click();
    Assert.assertEquals("4", staticListField.getSizeInput().getAttribute("value"));
    // Apply configuration changes and assert the result.
    staticListField.closeConfigPanel();
    // The initial second item was removed.
    Assert.assertNull(staticListField.getItemByValue("value2"));
    // We should have a new item with value "XWiki".
    staticListField.getItemByValue("XWiki").click();
    // Assert the order of the items.
    staticListField.getItemByValue("value1").click();
    Assert.assertEquals(Arrays.asList("XWiki", "value1"), staticListField.getDefaultSelectedValues());
}
Also used : StaticListClassFieldEditPane(org.xwiki.appwithinminutes.test.po.StaticListClassFieldEditPane) StaticListItemsEditor(org.xwiki.appwithinminutes.test.po.StaticListItemsEditor) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 52 with IgnoreBrowsers

use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.

the class StaticListClassFieldTest method testMultipleSelect.

/**
 * Tests that multiple select state is synchronized with the rest of the meta properties.
 */
@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 testMultipleSelect() {
    // Add a new static list field.
    StaticListClassFieldEditPane staticListField = new StaticListClassFieldEditPane(editor.addField("Static List").getName());
    // Open the configuration panel and play with the multiple selection option.
    staticListField.openConfigPanel();
    // Radio display type should disable multiple selection.
    staticListField.getMultipleSelectionCheckBox().click();
    Assert.assertTrue(staticListField.getMultipleSelectionCheckBox().isSelected());
    staticListField.getDisplayTypeSelect().selectByVisibleText("radio");
    Assert.assertFalse(staticListField.getMultipleSelectionCheckBox().isSelected());
    // Enabling multiple selection when display type is radio should change display type to check box.
    staticListField.getMultipleSelectionCheckBox().click();
    Assert.assertEquals("checkbox", staticListField.getDisplayTypeSelect().getFirstSelectedOption().getAttribute("value"));
    // 'select' display type supports properly multiple selection only if size is greater than 1.
    Assert.assertEquals("1", staticListField.getSizeInput().getAttribute("value"));
    staticListField.getDisplayTypeSelect().selectByVisibleText("select");
    Assert.assertEquals("3", staticListField.getSizeInput().getAttribute("value"));
}
Also used : StaticListClassFieldEditPane(org.xwiki.appwithinminutes.test.po.StaticListClassFieldEditPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 53 with IgnoreBrowsers

use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.

the class StaticListClassFieldTest method testDisplayType.

/**
 * Tests that the field preview is properly updated when the display type is changed. Currently selected items must
 * be preserved.
 */
@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 testDisplayType() {
    // Add a new static list field.
    StaticListClassFieldEditPane staticListField = new StaticListClassFieldEditPane(editor.addField("Static List").getName());
    // By default the list is displayed using check boxes.
    Assert.assertEquals("checkbox", staticListField.getPreviewInputType());
    // Enable multiple selection.
    staticListField.openConfigPanel();
    staticListField.getMultipleSelectionCheckBox().click();
    // Select the first and third options.
    staticListField.getItemByValue("value1").click();
    staticListField.getItemByValue("value3").click();
    // Change the display type to 'select'.
    staticListField.getDisplayTypeSelect().selectByVisibleText("select");
    staticListField.closeConfigPanel();
    // Assert that the field preview has been updated.
    Assert.assertEquals("select", staticListField.getPreviewInputType());
    // Assert that the selected values were preserved.
    Assert.assertEquals(Arrays.asList("value1", "value3"), staticListField.getDefaultSelectedValues());
    // Select only the second option.
    staticListField.setDefaultValue("value2");
    // Change the display type to 'radio'.
    staticListField.openConfigPanel();
    staticListField.getDisplayTypeSelect().selectByVisibleText("radio");
    staticListField.closeConfigPanel();
    // Assert that the field preview has been updated.
    Assert.assertEquals("radio", staticListField.getPreviewInputType());
    // Assert that the selected value was preserved.
    Assert.assertEquals("value2", staticListField.getDefaultValue());
}
Also used : StaticListClassFieldEditPane(org.xwiki.appwithinminutes.test.po.StaticListClassFieldEditPane) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) Test(org.junit.Test)

Example 54 with IgnoreBrowsers

use of org.xwiki.test.ui.browser.IgnoreBrowsers 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)

Example 55 with IgnoreBrowsers

use of org.xwiki.test.ui.browser.IgnoreBrowsers in project xwiki-platform by xwiki.

the class InvitationTest method testUnpermittedUserCannotSendToMultipleAddresses.

/**
 * This test proves that: 1. Non administrators trying to send to multiple email addresses without permission will
 * get an error message. and said mail will not be sent. 2. After permission is granted sending to multiple users
 * will work and message will say mail was sent.
 */
@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 testUnpermittedUserCannotSendToMultipleAddresses() throws Exception {
    TestUtils.Session admin = getUtil().getSession();
    // Make sure users don't have the right to send to multiple.
    AdministrationSectionPage config = AdministrationSectionPage.gotoPage("Invitation");
    config.getForm().setFieldValue(By.id("Invitation.InvitationConfig_Invitation.WebHome_0_" + "usersMaySendToMultiple"), "false");
    config.clickSave();
    try {
        getUtil().forceGuestUser();
        getUtil().createUserAndLogin("NonMailAdminUser", "WeakPassword");
        setSenderPage(InvitationSenderPage.gotoPage());
        startGreenMail();
        getSenderPage().fillForm("user@localhost.localdomain anotheruser@localhost.localdomain", null, null);
        InvitationSenderPage.InvitationSentPage sent = getSenderPage().send();
        getGreenMail().waitForIncomingEmail(2000, 2);
        MimeMessage[] messages = getGreenMail().getReceivedMessages();
        Assert.assertTrue("Messages were received when they shouldn't have been sent!", messages.length == 0);
        Assert.assertEquals("User was not shown the correct error message.", "Your message could not be sent because there were no valid email addresses to send to.", sent.getMessageBoxContent());
        stopGreenMail();
        // Become admin and allow users to send to multiple.
        TestUtils.Session nonAdmin = getUtil().getSession();
        getUtil().setSession(admin);
        config = AdministrationSectionPage.gotoPage("Invitation");
        config.getForm().setFieldValue(By.id("Invitation.InvitationConfig_Invitation.WebHome_0_" + "usersMaySendToMultiple"), "true");
        config.clickSave();
        getUtil().setSession(nonAdmin);
        // Prove that the user can now send to multiple recipients.
        startGreenMail();
        setSenderPage(InvitationSenderPage.gotoPage());
        getSenderPage().fillForm("user@localhost.localdomain anotheruser@localhost.localdomain", null, null);
        sent = getSenderPage().send();
        getGreenMail().waitForIncomingEmail(10000, 2);
        messages = getGreenMail().getReceivedMessages();
        Assert.assertTrue("Non admins cannot send mail to even with permission", messages.length == 2);
        Assert.assertTrue("User was not given the message that their mail was sent.", sent.getMessageBoxContent().equals("Your message has been sent."));
    } finally {
        stopGreenMail();
        getUtil().setSession(admin);
        getUtil().rest().deletePage("XWiki", "NonMailAdminUser");
    }
}
Also used : TestUtils(org.xwiki.test.ui.TestUtils) AdministrationSectionPage(org.xwiki.administration.test.po.AdministrationSectionPage) MimeMessage(javax.mail.internet.MimeMessage) InvitationSenderPage(org.xwiki.invitation.test.po.InvitationSenderPage) IgnoreBrowsers(org.xwiki.test.ui.browser.IgnoreBrowsers) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Aggregations

IgnoreBrowsers (org.xwiki.test.ui.browser.IgnoreBrowsers)80 Test (org.junit.Test)76 AbstractTest (org.xwiki.test.ui.AbstractTest)43 ViewPage (org.xwiki.test.ui.po.ViewPage)26 ClassFieldEditPane (org.xwiki.appwithinminutes.test.po.ClassFieldEditPane)12 LongTextClassFieldEditPane (org.xwiki.appwithinminutes.test.po.LongTextClassFieldEditPane)11 ApplicationClassEditPage (org.xwiki.appwithinminutes.test.po.ApplicationClassEditPage)10 WikiEditPage (org.xwiki.test.ui.po.editor.WikiEditPage)9 MimeMessage (javax.mail.internet.MimeMessage)7 TestUtils (org.xwiki.test.ui.TestUtils)6 HistoryPane (org.xwiki.test.ui.po.HistoryPane)6 LiveTableElement (org.xwiki.test.ui.po.LiveTableElement)6 LoginPage (org.xwiki.test.ui.po.LoginPage)6 PreferencesUserProfilePage (org.xwiki.user.test.po.PreferencesUserProfilePage)6 ApplicationHomePage (org.xwiki.appwithinminutes.test.po.ApplicationHomePage)5 EntryEditPage (org.xwiki.appwithinminutes.test.po.EntryEditPage)5 InvitationGuestActionsPage (org.xwiki.invitation.test.po.InvitationGuestActionsPage)5 ChangePasswordPage (org.xwiki.user.test.po.ChangePasswordPage)5 URL (java.net.URL)4 WebElement (org.openqa.selenium.WebElement)4