Search in sources :

Example 1 with ViewPage

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

the class NotificationsIT method testNotificationDisplayerClass.

@Test
public void testNotificationDisplayerClass() throws Exception {
    // Create the pages and a custom displayer for "update" events
    getUtil().login(SUPERADMIN_USER_NAME, SUPERADMIN_PASSWORD);
    getUtil().gotoPage(getTestClassName(), "WebHome");
    getUtil().createPage(getTestClassName(), "ARandomPageThatShouldBeModified", "Page used for the tests of the NotificationDisplayerClass XObject.", "Test page");
    getUtil().createPage(getTestClassName(), "NotificationDisplayerClassTest", "Page used for the tests of the NotificationDisplayerClass XObject.", "Test page 2");
    Map<String, String> notificationDisplayerParameters = new HashMap<String, String>() {

        {
            put("XWiki.Notifications.Code.NotificationDisplayerClass_0_eventType", "update");
            put("XWiki.Notifications.Code.NotificationDisplayerClass_0_notificationTemplate", "This is a test template");
        }
    };
    ObjectEditPage editObjects = getUtil().editObjects(getTestClassName(), "NotificationDisplayerClassTest");
    editObjects.addObject("XWiki.Notifications.Code.NotificationDisplayerClass");
    editObjects.getObjectsOfClass("XWiki.Notifications.Code.NotificationDisplayerClass").get(0).fillFieldsByName(notificationDisplayerParameters);
    editObjects.clickSaveAndContinue(true);
    // Login as first user, and enable notifications on document updates
    getUtil().login(FIRST_USER_NAME, FIRST_USER_PASSWORD);
    NotificationsUserProfilePage p = NotificationsUserProfilePage.gotoPage(FIRST_USER_NAME);
    p.getApplication(SYSTEM).setCollapsed(false);
    p.setEventTypeState(SYSTEM, UPDATE, ALERT_FORMAT, BootstrapSwitch.State.ON);
    // Login as second user and modify ARandomPageThatShouldBeModified
    getUtil().login(SECOND_USER_NAME, SECOND_USER_PASSWORD);
    ViewPage viewPage = getUtil().gotoPage(getTestClassName(), "ARandomPageThatShouldBeModified");
    viewPage.edit();
    WikiEditPage editPage = new WikiEditPage();
    editPage.setContent("Something");
    editPage.clickSaveAndView(true);
    // Login as the first user, ensure that the notification is displayed with a custom template
    getUtil().login(FIRST_USER_NAME, FIRST_USER_PASSWORD);
    getUtil().gotoPage(getTestClassName(), "WebHome");
    NotificationsTrayPage tray = new NotificationsTrayPage();
    assertEquals("This is a test template", tray.getNotificationRawContent(0));
}
Also used : NotificationsUserProfilePage(org.xwiki.platform.notifications.test.po.NotificationsUserProfilePage) HashMap(java.util.HashMap) ObjectEditPage(org.xwiki.test.ui.po.editor.ObjectEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) NotificationsTrayPage(org.xwiki.platform.notifications.test.po.NotificationsTrayPage) WikiEditPage(org.xwiki.test.ui.po.editor.WikiEditPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test) ServerSetupTest(com.icegreen.greenmail.util.ServerSetupTest)

Example 2 with ViewPage

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

the class ExtensionIT method testDowngrade.

/**
 * Tests how an extension is downgraded.
 */
@Test
public void testDowngrade() throws Exception {
    // Setup the extension.
    String extensionId = "alice-xar-extension";
    String oldVersion = "1.3";
    String newVersion = "2.1.4";
    TestExtension oldExtension = getRepositoryTestUtils().getTestExtension(new ExtensionId(extensionId, oldVersion), "xar");
    getRepositoryTestUtils().addExtension(oldExtension);
    TestExtension newExtension = getRepositoryTestUtils().getTestExtension(new ExtensionId(extensionId, newVersion), "xar");
    getRepositoryTestUtils().attachFile(newExtension);
    getRepositoryTestUtils().addVersionObject(newExtension, newVersion, "attach:" + newExtension.getFile().getName());
    // Make sure the new version is installed.
    getExtensionTestUtils().install(new ExtensionId(extensionId, newVersion));
    // Downgrade the extension.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
    ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId, oldVersion).getExtension(0);
    assertEquals("remote-installed", extensionPane.getStatus());
    assertEquals("Version 2.1.4 is installed", extensionPane.getStatusMessage());
    extensionPane = extensionPane.downgrade();
    // Check the downgrade plan.
    List<DependencyPane> downgradePlan = extensionPane.openProgressSection().getJobPlan();
    assertEquals(1, downgradePlan.size());
    assertEquals(extensionId, downgradePlan.get(0).getName());
    assertEquals(oldVersion, downgradePlan.get(0).getVersion());
    assertEquals("remote-installed", downgradePlan.get(0).getStatus());
    assertEquals("Version 2.1.4 is installed", downgradePlan.get(0).getStatusMessage());
    // Finish the downgrade and check the downgrade log.
    extensionPane = extensionPane.confirm();
    assertEquals("installed", extensionPane.getStatus());
    assertEquals("Installed", extensionPane.getStatusMessage());
    List<LogItemPane> log = extensionPane.openProgressSection().getJobLog();
    assertTrue(log.size() > 2);
    assertEquals("info", log.get(2).getLevel());
    assertEquals("Resolving extension [alice-xar-extension 1.3] on namespace [Home]", log.get(2).getMessage());
    assertEquals("info", log.get(log.size() - 1).getLevel());
    assertEquals("Finished job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
    // Assert the changes.
    ViewPage viewPage = getUtil().gotoPage("ExtensionTest", "Alice");
    assertEquals("Alice Macro", viewPage.getDocumentTitle());
    assertTrue(viewPage.getContent().contains("Alice says hello!"));
}
Also used : LogItemPane(org.xwiki.extension.test.po.LogItemPane) ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) DependencyPane(org.xwiki.extension.test.po.DependencyPane) TestExtension(org.xwiki.repository.test.TestExtension) ExtensionId(org.xwiki.extension.ExtensionId) ViewPage(org.xwiki.test.ui.po.ViewPage) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) Test(org.junit.Test)

Example 3 with ViewPage

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

the class ExtensionIT method testInstallScriptService.

/**
 * Tests if a Java component script service is properly installed.
 */
@Test
public void testInstallScriptService() throws Exception {
    // Make sure the script service is not available before the extension is installed.
    ViewPage viewPage = getUtil().createPage(getTestClassName(), getTestMethodName(), "{{velocity}}$services.greeter.greet('world') " + "$services.greeter.greet('XWiki', 'default'){{/velocity}}", "");
    assertFalse(viewPage.getContent().contains("Hello world! Hello XWiki!"));
    // Setup the extension.
    ExtensionId extensionId = new ExtensionId("scriptServiceJarExtension", "4.2-milestone-1");
    TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "jar");
    getRepositoryTestUtils().addExtension(extension);
    // Search the extension and install it.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
    ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
    extensionPane.install().confirm();
    // Check the result.
    assertEquals("Hello world! Hello XWiki!", getUtil().gotoPage(getTestClassName(), getTestMethodName()).getContent());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) ExtensionId(org.xwiki.extension.ExtensionId) TestExtension(org.xwiki.repository.test.TestExtension) ViewPage(org.xwiki.test.ui.po.ViewPage) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) Test(org.junit.Test)

Example 4 with ViewPage

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

the class ExtensionIT method testInstall.

/**
 * Tests how an extension is installed.
 */
@Test
public void testInstall() throws Exception {
    // Setup the extension and its dependencies.
    ExtensionId extensionId = new ExtensionId("alice-xar-extension", "1.3");
    TestExtension extension = getRepositoryTestUtils().getTestExtension(extensionId, "xar");
    ExtensionId dependencyId = new ExtensionId("bob-xar-extension", "2.5-milestone-2");
    getRepositoryTestUtils().addExtension(getRepositoryTestUtils().getTestExtension(dependencyId, "xar"));
    extension.addDependency(new DefaultExtensionDependency(dependencyId.getId(), new DefaultVersionConstraint(dependencyId.getVersion().getValue())));
    extension.addDependency(new DefaultExtensionDependency("org.xwiki.platform:xwiki-platform-sheet-api", new DefaultVersionConstraint("[3.2,)")));
    getRepositoryTestUtils().addExtension(extension);
    // Search the extension and install it.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
    ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId).getExtension(0);
    extensionPane = extensionPane.install();
    // Assert the install plan.
    List<DependencyPane> installPlan = extensionPane.openProgressSection().getJobPlan();
    assertEquals(2, installPlan.size());
    assertEquals(dependencyId, installPlan.get(0).getId());
    assertEquals(extensionId, installPlan.get(1).getId());
    // Finish the install and assert the install log.
    List<LogItemPane> log = extensionPane.confirm().openProgressSection().getJobLog();
    int logSize = log.size();
    assertTrue(logSize > 1);
    assertEquals("info", log.get(0).getLevel());
    assertEquals("Starting job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(0).getMessage());
    assertEquals("info", log.get(logSize - 1).getLevel());
    assertEquals("Finished job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(logSize - 1).getMessage());
    // Test that both extensions are usable.
    ViewPage viewPage = getUtil().createPage(getTestClassName(), getTestMethodName(), "{{alice/}}\n\n{{bob/}}", "");
    String content = viewPage.getContent();
    assertTrue(content.contains("Alice says hello!"));
    assertTrue(content.contains("Bob says hi!"));
    // Check the list of installed extensions.
    adminPage = ExtensionAdministrationPage.gotoInstalledExtensions();
    SearchResultsPane searchResults = adminPage.getSearchBar().search("bob");
    assertEquals(1, searchResults.getDisplayedResultsCount());
    extensionPane = searchResults.getExtension(0);
    assertEquals("installed-dependency", extensionPane.getStatus());
    assertEquals("Installed as dependency", extensionPane.getStatusMessage());
    assertEquals(dependencyId, extensionPane.getId());
    assertNotNull(extensionPane.getUninstallButton());
    searchResults = new SimpleSearchPane().search("alice");
    assertEquals(1, searchResults.getDisplayedResultsCount());
    extensionPane = searchResults.getExtension(0);
    assertEquals("installed", extensionPane.getStatus());
    assertEquals("Installed", extensionPane.getStatusMessage());
    assertEquals(extensionId, extensionPane.getId());
    assertNotNull(extensionPane.getUninstallButton());
    // Check if the progress log is persisted.
    extensionPane = extensionPane.showDetails();
    log = extensionPane.openProgressSection().getJobLog();
    assertEquals(logSize, log.size());
    assertEquals("info", log.get(0).getLevel());
    assertEquals("Starting job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(0).getMessage());
    assertEquals("info", log.get(logSize - 1).getLevel());
    assertEquals("Finished job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(logSize - 1).getMessage());
    // Check if the dependency is properly listed as installed.
    List<DependencyPane> dependencies = extensionPane.openDependenciesSection().getDirectDependencies();
    assertEquals(2, dependencies.size());
    assertEquals(dependencyId, dependencies.get(0).getId());
    assertEquals("installed-dependency", dependencies.get(0).getStatus());
    assertEquals("Installed as dependency", dependencies.get(0).getStatusMessage());
    // Check the backward dependency.
    dependencies.get(0).getLink().click();
    extensionPane = new ExtensionAdministrationPage().getSearchResults().getExtension(0);
    dependencies = extensionPane.openDependenciesSection().getBackwardDependencies();
    assertEquals(1, dependencies.size());
    assertEquals(extensionId, dependencies.get(0).getId());
    assertEquals("installed", dependencies.get(0).getStatus());
    assertEquals("Installed", dependencies.get(0).getStatusMessage());
}
Also used : ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) DependencyPane(org.xwiki.extension.test.po.DependencyPane) ExtensionId(org.xwiki.extension.ExtensionId) TestExtension(org.xwiki.repository.test.TestExtension) ViewPage(org.xwiki.test.ui.po.ViewPage) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) SimpleSearchPane(org.xwiki.extension.test.po.SimpleSearchPane) DefaultVersionConstraint(org.xwiki.extension.version.internal.DefaultVersionConstraint) LogItemPane(org.xwiki.extension.test.po.LogItemPane) DefaultVersionConstraint(org.xwiki.extension.version.internal.DefaultVersionConstraint) SearchResultsPane(org.xwiki.extension.test.po.SearchResultsPane) DefaultExtensionDependency(org.xwiki.extension.DefaultExtensionDependency) Test(org.junit.Test)

Example 5 with ViewPage

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

the class ExtensionIT method testUpgrade.

/**
 * Tests how an extension is upgraded.
 */
@Test
public void testUpgrade() throws Exception {
    // Setup the extension.
    String extensionId = "alice-xar-extension";
    String oldVersion = "1.3";
    String newVersion = "2.1.4";
    TestExtension oldExtension = getRepositoryTestUtils().getTestExtension(new ExtensionId(extensionId, oldVersion), "xar");
    getRepositoryTestUtils().addExtension(oldExtension);
    TestExtension newExtension = getRepositoryTestUtils().getTestExtension(new ExtensionId(extensionId, newVersion), "xar");
    getRepositoryTestUtils().attachFile(newExtension);
    getRepositoryTestUtils().addVersionObject(newExtension, newVersion, "attach:" + newExtension.getFile().getName());
    // Make sure the old version is installed.
    getExtensionTestUtils().install(new ExtensionId(extensionId, oldVersion));
    // Upgrade the extension.
    ExtensionAdministrationPage adminPage = ExtensionAdministrationPage.gotoPage();
    ExtensionPane extensionPane = adminPage.getSearchBar().clickAdvancedSearch().search(extensionId, newVersion).getExtension(0);
    assertEquals("remote-installed", extensionPane.getStatus());
    assertEquals("Version 1.3 is installed", extensionPane.getStatusMessage());
    extensionPane = extensionPane.upgrade();
    // Check the upgrade plan.
    List<DependencyPane> upgradePlan = extensionPane.openProgressSection().getJobPlan();
    assertEquals(1, upgradePlan.size());
    assertEquals(extensionId, upgradePlan.get(0).getName());
    assertEquals(newVersion, upgradePlan.get(0).getVersion());
    assertEquals("remote-installed", upgradePlan.get(0).getStatus());
    assertEquals("Version 1.3 is installed", upgradePlan.get(0).getStatusMessage());
    // Finish the upgrade and check the upgrade log.
    extensionPane = extensionPane.confirm();
    assertEquals("installed", extensionPane.getStatus());
    assertEquals("Installed", extensionPane.getStatusMessage());
    List<LogItemPane> log = extensionPane.openProgressSection().getJobLog();
    assertTrue(log.size() > 2);
    assertEquals("info", log.get(2).getLevel());
    assertEquals("Resolving extension [alice-xar-extension 2.1.4] on namespace [Home]", log.get(2).getMessage());
    assertEquals("info", log.get(log.size() - 1).getLevel());
    assertEquals("Finished job of type [install] with identifier " + "[extension/action/alice-xar-extension/wiki:xwiki]", log.get(log.size() - 1).getMessage());
    // Assert the changes.
    ViewPage viewPage = getUtil().gotoPage("ExtensionTest", "Alice");
    assertEquals("Alice Wiki Macro (upgraded)", viewPage.getDocumentTitle());
    assertTrue(viewPage.getContent().contains("Alice says hi guys!"));
}
Also used : LogItemPane(org.xwiki.extension.test.po.LogItemPane) ExtensionAdministrationPage(org.xwiki.extension.test.po.ExtensionAdministrationPage) DependencyPane(org.xwiki.extension.test.po.DependencyPane) TestExtension(org.xwiki.repository.test.TestExtension) ExtensionId(org.xwiki.extension.ExtensionId) ViewPage(org.xwiki.test.ui.po.ViewPage) ExtensionPane(org.xwiki.extension.test.po.ExtensionPane) Test(org.junit.Test)

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