Permalink
Browse files

XWIKI-7381: Add the Actions column to the applications live table

* Add functional tests.
* Update tests that were using DeletePage and DeleteConfirmationPage.
  • Loading branch information...
1 parent 6ec250b commit fbd0f090527919105a9ddc1fc6fe3527abf429d9 @mflorea mflorea committed Mar 19, 2012
@@ -21,7 +21,6 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
-import org.xwiki.test.ui.po.LiveTableElement;
import org.xwiki.test.ui.po.ViewPage;
/**
@@ -43,7 +42,7 @@
/**
* The live table that lists the existing applications.
*/
- private LiveTableElement appsLiveTable = new LiveTableElement("livetable");
+ private ApplicationsLiveTableElement appsLiveTable = new ApplicationsLiveTableElement();
/**
* Opens the App Within Minutes home page.
@@ -78,7 +77,7 @@ public ApplicationCreatePage clickCreateApplication()
/**
* @return the live table that list existing applications
*/
- public LiveTableElement getAppsLiveTable()
+ public ApplicationsLiveTableElement getAppsLiveTable()
{
return appsLiveTable;
}
@@ -0,0 +1,145 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.xwiki.test.po.appwithinminutes;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+import org.xwiki.test.ui.po.ConfirmationPage;
+import org.xwiki.test.ui.po.LiveTableElement;
+
+/**
+ * Represents the live table that lists the existing applications on the AppWithinMinuts home page.
+ *
+ * @version $Id$
+ * @since 4.0M2
+ */
+public class ApplicationsLiveTableElement extends LiveTableElement
+{
+ /**
+ * Identifies the application name filter input.
+ */
+ private static final String APP_NAME_FILTER_ID = "xwiki-livetable-livetable-filter-1";
+
+ /**
+ * The title of the live table column that displays the application name.
+ */
+ private static final String APP_NAME_COLUMN_TITLE = "Application name";
+
+ /**
+ * Creates a new instance.
+ */
+ public ApplicationsLiveTableElement()
+ {
+ super("livetable");
+ }
+
+ /**
+ * @param appName the name of an application
+ * @return {@code true} if the specified application is listed, {@code false} otherwise
+ */
+ public boolean isApplicationListed(String appName)
+ {
+ return hasRow(APP_NAME_COLUMN_TITLE, appName);
+ }
+
+ /**
+ * Clicks on the link to delete the specified application.
+ *
+ * @param appName the name of the application to delete
+ */
+ public ConfirmationPage clickDeleteApplication(String appName)
+ {
+ clickAction(appName, "delete");
+ return new ConfirmationPage();
+ }
+
+ /**
+ * @param appName the name of an application
+ * @return {@code true} if the delete link is displayed for the specified application
+ */
+ public boolean canDeleteApplication(String appName)
+ {
+ return hasAction(appName, "delete");
+ }
+
+ /**
+ * Clicks on the link to edit the specified application.
+ *
+ * @param appName the name of the application to delete.
+ */
+ public ApplicationClassEditPage clickEditApplication(String appName)
+ {
+ clickAction(appName, "edit");
+ return new ApplicationClassEditPage();
+ }
+
+ /**
+ * @param appName the name of an application
+ * @return {@code true} if the edit link is displayed for the specified application
+ */
+ public boolean canEditApplication(String appName)
+ {
+ return hasAction(appName, "edit");
+ }
+
+ /**
+ * Clicks one of the action links corresponding to the specified application.
+ *
+ * @param appName the action target
+ * @param action the action name
+ */
+ protected void clickAction(String appName, String action)
+ {
+ String escapedAppName = appName.replace("\\", "\\\\").replace("'", "\\'");
+ String actionLinkXPath =
+ "//tr[td[contains(@class, 'doc_space') and . = '" + escapedAppName
+ + "']]/td[@class = 'actions']//a[contains(@class, 'action" + action + "')]";
+ WebElement liveTableBody = getDriver().findElement(By.id("livetable-display"));
+ liveTableBody.findElement(By.xpath(actionLinkXPath)).click();
+ }
+
+ /**
+ * @return {@code true} if the given action is listed for the specified application, {@code false} otherwise
+ */
+ protected boolean hasAction(String appName, String action)
+ {
+ String escapedAppName = appName.replace("\\", "\\\\").replace("'", "\\'");
+ String actionLinkXPath =
+ "//tr[td[contains(@class, 'doc_space') and . = '" + escapedAppName
+ + "']]/td[@class = 'actions']//a[contains(@class, 'action" + action + "')]";
+ WebElement liveTableBody = getDriver().findElement(By.id("livetable-display"));
+ return liveTableBody.findElements(By.xpath(actionLinkXPath)).size() > 0;
+ }
+
+ /**
+ * Filters by application name.
+ *
+ * @param appNameFilter the string to filter the application names with
+ */
+ public void filterApplicationName(String appNameFilter)
+ {
+ super.filterColumn(APP_NAME_FILTER_ID, appNameFilter);
+ }
+
+ public String getApplicationNameFilter()
+ {
+ return super.getFilterValue(APP_NAME_FILTER_ID);
+ }
+}
@@ -22,7 +22,7 @@
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
-import org.xwiki.test.ui.po.DeletePage;
+import org.xwiki.test.ui.po.ConfirmationPage;
import org.xwiki.test.ui.po.ViewPage;
import org.xwiki.test.po.scheduler.editor.SchedulerEditPage;
@@ -69,10 +69,10 @@ public SchedulerEditPage clickJobActionEdit(String jobName)
return sep;
}
- public DeletePage clickJobActionDelete(String jobName)
+ public ConfirmationPage clickJobActionDelete(String jobName)
{
clickAction(jobName, "delete");
- return new DeletePage();
+ return new ConfirmationPage();
}
public void clickJobActionScheduler(String jobName)
@@ -25,10 +25,10 @@
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
-import org.xwiki.test.ui.po.DeleteConfirmationPage;
-import org.xwiki.test.ui.po.DeletePage;
-import org.xwiki.test.ui.po.ViewPage;
import org.xwiki.test.po.xe.HomePage;
+import org.xwiki.test.ui.po.ConfirmationPage;
+import org.xwiki.test.ui.po.DeletePageOutcomePage;
+import org.xwiki.test.ui.po.ViewPage;
/**
* Tests the Delete button present in the top level menu.
@@ -67,13 +67,14 @@ public void setUp()
@Test
public void testDeleteOkWhenConfirming()
{
- DeletePage deletePage = this.viewPage.delete();
+ ConfirmationPage confirmationPage = this.viewPage.delete();
// This tests for regression of XWIKI-1388
Assert.assertNotNull("The interface should not show the user as logged out while deleting page",
- this.viewPage.getCurrentUser());
- DeleteConfirmationPage deleteConfirmationPage = deletePage.confirm();
- Assert.assertEquals(LOGGED_USERNAME, deleteConfirmationPage.getPageDeleter());
- Assert.assertEquals(CONFIRMATION, deleteConfirmationPage.getConfirmationMessage());
+ confirmationPage.getCurrentUser());
+ confirmationPage.clickYes();
+ DeletePageOutcomePage deleteOutcome = new DeletePageOutcomePage();
+ Assert.assertEquals(LOGGED_USERNAME, deleteOutcome.getPageDeleter());
+ Assert.assertEquals(CONFIRMATION, deleteOutcome.getMessage());
}
/**
@@ -108,8 +109,7 @@ public void testDeletePageCanDoRedirect()
@Test
public void testDeletePageGoesToOriginalPageWhenCancelled()
{
- DeletePage deletePage = this.viewPage.delete();
- deletePage.cancel();
+ this.viewPage.delete().clickNo();
Assert.assertTrue(getDriver().getCurrentUrl().equals(getUtil().getURL(SPACE_VALUE, PAGE_VALUE)));
}
Oops, something went wrong.

0 comments on commit fbd0f09

Please sign in to comment.