Search in sources :

Example 1 with ApplicationsPanel

use of org.xwiki.panels.test.po.ApplicationsPanel in project xwiki-platform by xwiki.

the class PanelTest method verifyApplicationsPanelEntry.

@Test
public void verifyApplicationsPanelEntry() {
    // Navigate to the Panels app by clicking in the Application Panel.
    // This verifies that the Panels application is registered in the Applications Panel.
    // It also verifies that the Translation is registered properly.
    ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage();
    ViewPage vp = applicationPanel.clickApplication("Panels");
    // Verify we're on the right page!
    assertEquals(PanelsHomePage.getSpace(), vp.getMetaDataValue("space"));
    assertEquals(PanelsHomePage.getPage(), vp.getMetaDataValue("page"));
    // Now log out to verify that the Panels entry is not displayed for non admin users
    getUtil().forceGuestUser();
    // Navigate again to the Application Panels page to perform the verification
    applicationPanel = ApplicationsPanel.gotoPage();
    assertFalse(applicationPanel.containsApplication("Panels"));
}
Also used : ApplicationsPanel(org.xwiki.panels.test.po.ApplicationsPanel) ViewPage(org.xwiki.test.ui.po.ViewPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 2 with ApplicationsPanel

use of org.xwiki.panels.test.po.ApplicationsPanel in project xwiki-platform by xwiki.

the class ApplicationsPanelAdministrationTest method testApplicationsPanelAdministration.

@Test
public void testApplicationsPanelAdministration() throws Exception {
    createApplicationUIXs();
    // First: check that the panel displays everything in the right order
    checkInitialState(ApplicationsPanel.gotoPage());
    // No go to the administration
    ApplicationsPanelAdministrationPage appPanelAdminPage = ApplicationsPanelAdministrationPage.gotoPage();
    // Check that everything is as expected
    checkInitialState(appPanelAdminPage);
    // Make changes and revert them, check that it works
    applyChanges(appPanelAdminPage);
    appPanelAdminPage.revert();
    checkInitialState(appPanelAdminPage);
    // Do the changes again, and save them
    applyChanges(appPanelAdminPage);
    appPanelAdminPage.save();
    assertTrue(appPanelAdminPage.hasSuccessNotification());
    // Go to the panel and see what are the new results
    ApplicationsPanel applicationsPanel = ApplicationsPanel.gotoPage();
    List<String> applications = applicationsPanel.getApplications();
    assertEquals(3, applications.size());
    Iterator<String> iterator = applications.iterator();
    assertEquals("App3", iterator.next());
    assertEquals("App1", iterator.next());
    assertEquals("App2", iterator.next());
    // Go back to the app panel admin page and verify that the settings are well displayed
    appPanelAdminPage = ApplicationsPanelAdministrationPage.gotoPage();
    assertFalse(appPanelAdminPage.getApplicationsInBar().contains("Panels"));
    assertTrue(appPanelAdminPage.getApplicationsNotInBar().contains("Panels"));
    iterator = appPanelAdminPage.getApplicationsInBar().iterator();
    assertEquals("App3", iterator.next());
    assertEquals("App1", iterator.next());
    assertEquals("App2", iterator.next());
    // Put the application back to the bar
    appPanelAdminPage.addApplicationInBar("Panels");
    assertTrue(appPanelAdminPage.getApplicationsInBar().contains("Panels"));
    assertFalse(appPanelAdminPage.getApplicationsNotInBar().contains("Panels"));
    // Put back the initial order
    appPanelAdminPage.moveAppBefore("App1", appPanelAdminPage.getApplicationsInBar().get(0));
    appPanelAdminPage.moveAppBefore("App2", appPanelAdminPage.getApplicationsInBar().get(1));
    appPanelAdminPage.moveAppBefore("App3", appPanelAdminPage.getApplicationsInBar().get(2));
    // Save again
    appPanelAdminPage.save();
    assertTrue(appPanelAdminPage.hasSuccessNotification());
    // Go back to the panel and check everything is good
    checkInitialState(ApplicationsPanel.gotoPage());
    // Verify that the settings have been saved
    checkInitialState(ApplicationsPanelAdministrationPage.gotoPage());
    // Cleanup
    cleanUp();
}
Also used : ApplicationsPanel(org.xwiki.panels.test.po.ApplicationsPanel) ApplicationsPanelAdministrationPage(org.xwiki.panels.test.po.ApplicationsPanelAdministrationPage) Test(org.junit.Test) AbstractTest(org.xwiki.test.ui.AbstractTest)

Example 3 with ApplicationsPanel

use of org.xwiki.panels.test.po.ApplicationsPanel in project xwiki-platform by xwiki.

the class ReleaseTest method testRelease.

@Test
public void testRelease() {
    // Create a user and log in with it so that we test the application with a standard user
    // Note that using the superadmin user would also fail since the uservatar macro doesn't work with it.
    getUtil().createUserAndLogin(getTestClassName() + "User", "password");
    // Delete pages that we create in the test (we have to be logged in).
    getUtil().deletePage("Release", RELEASE_PAGE_NAME);
    // Navigate to the Release app by clicking in the Application Panel.
    // This verifies that the Release application is registered in the Applications Panel.
    // It also verifies that the Translation is registered properly.
    ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage();
    ViewPage vp = applicationPanel.clickApplication("Release");
    // Verify we're on the right page!
    Assert.assertEquals(ReleaseHomePage.getSpace(), vp.getMetaDataValue("space"));
    Assert.assertEquals(ReleaseHomePage.getPage(), vp.getMetaDataValue("page"));
    ReleaseHomePage homePage = new ReleaseHomePage();
    // Add new Release
    ReleaseEntryEditPage entryPage = homePage.addRelease(RELEASE_VERSION);
    vp = entryPage.waitUntilPageIsLoaded().clickSaveAndView();
    // Go back to the home page by clicking in the breadcrumb
    vp.clickBreadcrumbLink("Releases");
    homePage.waitUntilPageIsLoaded();
    // Assert Livetable:
    // - verify that the Translation has been applied by checking the Translated livetable column name
    // - verify that the Livetable contains our new Release entry
    LiveTableElement lt = homePage.getReleaseLiveTable();
    Assert.assertTrue(lt.hasRow("Version", RELEASE_VERSION));
}
Also used : LiveTableElement(org.xwiki.test.ui.po.LiveTableElement) ApplicationsPanel(org.xwiki.panels.test.po.ApplicationsPanel) ReleaseEntryEditPage(org.xwiki.release.test.po.ReleaseEntryEditPage) ViewPage(org.xwiki.test.ui.po.ViewPage) ReleaseHomePage(org.xwiki.release.test.po.ReleaseHomePage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 4 with ApplicationsPanel

use of org.xwiki.panels.test.po.ApplicationsPanel in project xwiki-platform by xwiki.

the class ApplicationsPanelEntryTest method testApplicationPanelEntry.

@Test
public void testApplicationPanelEntry() {
    // Test the icon remains the same between edits
    editPage.setIcon("icon:bell");
    editPage.clickSaveAndView();
    getUtil().gotoPage(getTestClassName(), getTestMethodName(), "edit");
    Assert.assertEquals("icon:bell", editPage.getIcon());
    ApplicationsPanel panel = ApplicationsPanel.gotoPage();
    ViewPage page = panel.clickApplication(getTestClassName());
    // Verify we're on the right page!
    Assert.assertEquals(getTestClassName(), page.getMetaDataValue("space"));
    Assert.assertEquals(getTestMethodName(), page.getMetaDataValue("page"));
}
Also used : ApplicationsPanel(org.xwiki.panels.test.po.ApplicationsPanel) ViewPage(org.xwiki.test.ui.po.ViewPage) AbstractTest(org.xwiki.test.ui.AbstractTest) Test(org.junit.Test)

Example 5 with ApplicationsPanel

use of org.xwiki.panels.test.po.ApplicationsPanel in project xwiki-platform by xwiki.

the class ActiveInstallsIT method verifyActiveInstalls.

@Test
public void verifyActiveInstalls() throws Exception {
    // provision ES).
    if (ElasticSearchRunner.esSetup != null) {
        // When XWiki was started by ElasticSearchRunner from AllITs, a page was checked to verify that the XWiki
        // instance was up. This, in turn, triggered the send of an asynchronous ping to the ES instance
        // (started prior to the XWiki start in ElasticSearchRunner).
        // 
        // Since the ping may take some time to be sent to our ES instance, we wait till we have 1 index in ES or
        // till the timeout expires.
        long count = 0;
        long time = System.currentTimeMillis();
        while (count != 1 && (System.currentTimeMillis() - time) < 5000L) {
            count = ElasticSearchRunner.esSetup.countAll();
            Thread.sleep(100L);
        }
        assertEquals("AS ping wasn't sent by the XWiki instance", 1, count);
        // In order to verify backward compatibility with the previous Active Install format, we also add an index
        // in the older format.
        ElasticSearchRunner.esSetup.execute(index("installs", "install", "156231f3-705b-44c6-afe3-e191bcc4b746").withSource("{ \"formatVersion\": \"1.0\", \"distributionVersion\": \"5.2\", " + "\"distributionId\": \"org.xwiki.platform:xwiki-platform-web\", " + "\"date\": \"2013-09-16T20:00:34.277Z\", \"extensions\": [ ] }"));
    }
    // Navigate to the ActiveInstalls app by clicking in the Application Panel.
    // This verifies that the ActiveInstalls application is registered in the Applications Panel.
    // It also verifies that the Translation is registered properly.
    ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage();
    ViewPage vp = applicationPanel.clickApplication("Active Installs");
    // Verify we're on the right page!
    Assert.assertEquals(ActiveInstallsHomePage.getSpace(), vp.getMetaDataValue("space"));
    Assert.assertEquals(ActiveInstallsHomePage.getPage(), vp.getMetaDataValue("page"));
    // Configure the Active Installs feature to count "org.xwiki.*" distribution ids.
    getUtil().updateObject("ActiveInstalls", "ActiveInstallsConfig", "ActiveInstalls.ActiveInstallsConfig", 0, "distributionId", "org.xwiki.*");
    // By default we don't show SNAPSHOTs, verify that!
    // The default query doesn't show SNAPSHOT versions and thus we expect 0
    getUtil().gotoPage("ActiveInstalls", "ActiveCounterValue2");
    vp = new ViewPage();
    assertEquals("0", vp.getContent());
    // The default query doesn't show SNAPSHOT versions and thus we expect 0
    getUtil().gotoPage("ActiveInstalls", "TotalCounterValue2");
    vp = new ViewPage();
    assertEquals("0", vp.getContent());
    // Configure the Active Installs feature to count SNAPSHOTs and to count
    // "org.xwiki.platform:xwiki-platform-web" distribution ids.
    getUtil().updateObject("ActiveInstalls", "ActiveInstallsConfig", "ActiveInstalls.ActiveInstallsConfig", 0, "snapshots", true);
    // Navigate to the Active Installs Counter Value page to verify that the ping has been received
    getUtil().gotoPage("ActiveInstalls", "ActiveCounterValue2");
    vp = new ViewPage();
    assertEquals("1", vp.getContent());
    // Also verify the Active Installs Counter for the old format
    getUtil().gotoPage("ActiveInstalls", "ActiveCounterValue1");
    vp = new ViewPage();
    assertEquals("0", vp.getContent());
    // Navigate to the Total Installs Counter Value page to verify that the ping has been received
    getUtil().gotoPage("ActiveInstalls", "TotalCounterValue2");
    vp = new ViewPage();
    assertEquals("1", vp.getContent());
    // Also verify the Total Installs Counter for the old format
    getUtil().gotoPage("ActiveInstalls", "TotalCounterValue1");
    vp = new ViewPage();
    assertEquals("1", vp.getContent());
    // Verify JavaVersion data
    getUtil().gotoPage("ActiveInstalls", "JavaVersionsData");
    vp = new ViewPage();
    assertTrue("Got [" + vp.getContent() + "]", vp.getContent().matches("Java Version Active Installs Count\\r?\\n1\\.[0-9_\\.]* 1"));
    // Verify Databases data
    getUtil().gotoPage("ActiveInstalls", "DatabasesData");
    vp = new ViewPage();
    assertTrue("Got [" + vp.getContent() + "]", vp.getContent().matches("Database Active Installs Count\\r?\\nHSQL Database Engine 1"));
    // Verify Distribution data
    getUtil().gotoPage("ActiveInstalls", "DistributionData");
    vp = new ViewPage();
    assertTrue("Got [" + vp.getContent() + "]", vp.getContent().matches("Distributions Active Installs Count\\r?\\n" + "org.xwiki.platform:xwiki-platform-web 1"));
    // Verify top 10 XWiki versions data
    getUtil().gotoPage("ActiveInstalls", "XWikiVersionsData");
    vp = new ViewPage();
    assertTrue("Got [" + vp.getContent() + "]", vp.getContent().matches("XWiki Version Active Installs Count\\r?\\n[0-9]+\\.[0-9]+.* 1"));
    // Verify XWiki Cycle versions data
    getUtil().gotoPage("ActiveInstalls", "XWikiVersionsCycleData");
    vp = new ViewPage();
    assertTrue("Got [" + vp.getContent() + "]", vp.getContent().matches("XWiki Version Active Installs Count\\r?\\n[0-9]+\\.x 1"));
    // Verify ServletContainers data
    getUtil().gotoPage("ActiveInstalls", "ServletContainersData");
    vp = new ViewPage();
    assertTrue("Got [" + vp.getContent() + "]", vp.getContent().matches("Servlet Container Active Installs Count\\r?\\njetty 1"));
    // Verify Extension Count
    // Create a page calling the Extension Count macro
    String content = "{{include reference=\"ActiveInstalls.ExtensionCount\"/}}\n" + "\n" + "{{velocity}}\n" + "#set ($extensionIds = [\n" + "  'org.xwiki.contrib:xwiki-totem-application',\n" + "  'jsimard:event-reporter-application',\n" + "  'mouhb:likeapplication'\n" + "])\n" + "|=Extension Id|=Count\n" + "#foreach($extensionId in $extensionIds)\n" + "  #countActiveInstallsUsingExtension($extensionId $count)\n" + "  |$extensionId|$count\n" + "#end\n" + "{{/velocity}}";
    vp = getUtil().createPage(getTestClassName(), "ExtensionCountExample", content, "Example");
    assertTrue("Got [" + vp.getContent() + "]", vp.getContent().matches("Extension Id Count\n" + "org.xwiki.contrib:xwiki-totem-application 0\n" + "jsimard:event-reporter-application 0\n" + "mouhb:likeapplication 0"));
}
Also used : ApplicationsPanel(org.xwiki.panels.test.po.ApplicationsPanel) ViewPage(org.xwiki.test.ui.po.ViewPage) AbstractTest(org.xwiki.test.ui.AbstractTest)

Aggregations

ApplicationsPanel (org.xwiki.panels.test.po.ApplicationsPanel)6 AbstractTest (org.xwiki.test.ui.AbstractTest)5 Test (org.junit.Test)4 ViewPage (org.xwiki.test.ui.po.ViewPage)4 Before (org.junit.Before)1 ApplicationsPanelAdministrationPage (org.xwiki.panels.test.po.ApplicationsPanelAdministrationPage)1 ReleaseEntryEditPage (org.xwiki.release.test.po.ReleaseEntryEditPage)1 ReleaseHomePage (org.xwiki.release.test.po.ReleaseHomePage)1 LiveTableElement (org.xwiki.test.ui.po.LiveTableElement)1