bug3529 Added selenium tests for regatta overview settings handling

This commit is contained in:
Vladislav Chumak committed 2017-04-05 20:28:08 +02:00
1 parent 2400e72e39
commit ff32915b09
18 files changed
+530 -38

No files matched your search

@@ -119,6 +119,7 @@ public class RegattaOverviewPanel extends SimplePanel {
});
settingsButton = new Anchor(" ", true);
settingsButton.ensureDebugId("RegattaOverviewSettingsButton");
settingsButton.setStyleName(style.settingsButton());
settingsButton.addStyleName(RES.mainCss().button());
settingsButton.addStyleName(style.button());
@@ -53,6 +53,7 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
private FlowPanel fillCourseAreaWidget(DataEntryDialog<?> dialog) {
FlowPanel flowPanel = new FlowPanel();
flowPanel.ensureDebugId("CourseAreaPanel");
flowPanel.addStyleName(SETTINGS_DIALOG_COMPONENT);
flowPanel.add(dialog.createHeadline(stringMessages.showFollowingCourseAreas(), true));
FlowPanel courseAreaPanel = new FlowPanel();
@@ -112,6 +113,7 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
private FlowPanel fillRegattaNamesWidget(DataEntryDialog<?> dialog) {
FlowPanel flowPanel = new FlowPanel();
flowPanel.ensureDebugId("RegattaNamesPanel");
flowPanel.addStyleName(SETTINGS_DIALOG_COMPONENT);
flowPanel.add(dialog.createHeadline(stringMessages.showFollowingRegattas(), true));
FlowPanel regattaNamesPanel = new FlowPanel();
@@ -179,12 +181,14 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
private CheckBox getShowOnlyRacesOfSameDayWidget(DataEntryDialog<?> dialog) {
showOnlyRacesOfSameDayCheckBox = dialog.createCheckbox(stringMessages.showOnlyRacesOfSameDay());
showOnlyRacesOfSameDayCheckBox.ensureDebugId("ShowOnlyRacesOfSameDayCheckBox");
showOnlyRacesOfSameDayCheckBox.setValue(initialSettings.isShowOnlyRacesOfSameDay());
return showOnlyRacesOfSameDayCheckBox;
}
private CheckBox getShowOnlyCurrentlyRunningRacesWidget(DataEntryDialog<?> dialog) {
showOnlyCurrentlyRunningRacesCheckBox = dialog.createCheckbox(stringMessages.showOnlyCurrentlyRunningRaces());
showOnlyCurrentlyRunningRacesCheckBox.ensureDebugId("ShowOnlyCurrentlyRunningRacesCheckBox");
showOnlyCurrentlyRunningRacesCheckBox.setValue(initialSettings.isShowOnlyCurrentlyRunningRaces());
return showOnlyCurrentlyRunningRacesCheckBox;
}
@@ -205,6 +209,7 @@ public class RegattaRaceStatesSettingsDialogComponent implements SettingsDialogC
@Override
public Widget getAdditionalWidget(DataEntryDialog<?> dialog) {
VerticalPanel verticalPanel = new VerticalPanel();
dialog.ensureDebugId("RegattaRacesStatesSettingsDialog");
verticalPanel.add(fillCourseAreaWidget(dialog));
verticalPanel.add(fillRegattaNamesWidget(dialog));
@@ -76,4 +76,8 @@ public abstract class HostPage extends PageObject {
protected interface HostPageSupplier<T extends HostPage> {
T get(WebDriver driver);
}
public String getCurrentUrl() {
return driver.getCurrentUrl();
}
}
@@ -0,0 +1,28 @@
package com.sap.sailing.selenium.pages.adminconsole.event;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.sap.sailing.selenium.core.BySeleniumId;
import com.sap.sailing.selenium.core.FindBy;
import com.sap.sailing.selenium.pages.PageArea;
import com.sap.sailing.selenium.pages.gwt.SuggestBoxPO;
public class CourseAreasTabPO extends PageArea {
@FindBy(how = BySeleniumId.class, using = "InputSuggestBox")
private WebElement newCourseInputSuggestBox;
@FindBy(how = BySeleniumId.class, using = "AddButton")
private WebElement addCourseButton;
CourseAreasTabPO(WebDriver driver, WebElement element) {
super(driver, element);
}
void addNewCourse(String name) {
SuggestBoxPO.create(driver, newCourseInputSuggestBox).appendText(name);
addCourseButton.click();
}
}
@@ -15,6 +15,7 @@ import com.sap.sailing.selenium.pages.common.ConfirmDialogPO;
import com.sap.sailing.selenium.pages.gwt.CellTablePO;
import com.sap.sailing.selenium.pages.gwt.DataEntryPO;
import com.sap.sailing.selenium.pages.gwt.GenericCellTablePO;
import com.sap.sailing.selenium.pages.regattaoverview.RegattaOverviewPage;
public class EventConfigurationPanelPO extends PageArea {
@@ -24,7 +25,8 @@ public class EventConfigurationPanelPO extends PageArea {
private static final String ID_CREATE_DEFAULT_LEADERBOARD_GROUP_CONFIRM_DIALOG = "CreateDefaultLeaderboardGroupConfirmDialog";
private static final String ID_CREATE_DEFAULT_REGATTA_CONFIRM_DIALOG = "CreateDefaultRegattaDialog";
private static final String ID_CREATE_DEFAULT_REGATTA_LEADERBOARD_CONFIRM_DIALOG = "CreateDefaultRegattaLeaderboardDialog";
private static final String ID_LINK_LEADERBORAD_TO_GROUP_DIALOG = "LinkRegattaLeaderboardToLeaderboardGroupOfEventDialog";
public static final String ID_LINK_LEADERBORAD_TO_GROUP_DIALOG = "LinkRegattaLeaderboardToLeaderboardGroupOfEventDialog";
public static final String ID_LINK_EVENT_OVERVIEW_URL_LABEL = "EventOverviewURLLabel";
public static class EventEntryPO extends DataEntryPO {
@@ -64,14 +66,18 @@ public class EventConfigurationPanelPO extends PageArea {
public void createEventWithDefaultLeaderboardGroupRegattaAndDefaultLeaderboard(String eventName, String eventDesc,
String venue, Date eventStartDate, Date eventEndDate, boolean isPublic, String regattaName, String boatClass,
Date regattaStartDate, Date regattaEndDate, boolean useOverallLeaderboard) {
createEvent(eventName, eventDesc, venue, eventStartDate, eventEndDate, isPublic).pressYes();
Date regattaStartDate, Date regattaEndDate, boolean useOverallLeaderboard, String...courseAreaNames) {
createEvent(eventName, eventDesc, venue, eventStartDate, eventEndDate, isPublic, courseAreaNames).pressYes();
LeaderboardGroupCreateDialogPO leaderboardGroupCreateDialogPO = getPO(LeaderboardGroupCreateDialogPO::new, ID_CREATE_DEFAULT_LEADERBOARD_GROUP_DIALOG);
leaderboardGroupCreateDialogPO.setUseOverallLeaderboard(useOverallLeaderboard);
leaderboardGroupCreateDialogPO.pressOk();
getPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_REGATTA_CONFIRM_DIALOG).pressYes();
createRegatta(regattaName, boatClass, regattaStartDate, regattaEndDate).pressOk();
getPO(ConfirmDialogPO::new, ID_LINK_LEADERBORAD_TO_GROUP_DIALOG).pressOk();
waitForPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_REGATTA_CONFIRM_DIALOG, 5).pressYes();
if(courseAreaNames.length > 0) {
createRegatta(regattaName, boatClass, regattaStartDate, regattaEndDate, eventName, "Default").pressOk();
} else {
createRegatta(regattaName, boatClass, regattaStartDate, regattaEndDate).pressOk();
}
waitForPO(ConfirmDialogPO::new, ID_LINK_LEADERBORAD_TO_GROUP_DIALOG, 5).pressOk();
}
public void createEventWithExistingLeaderboardGroups(String eventName, String eventDesc, String venue,
@@ -99,19 +105,45 @@ public class EventConfigurationPanelPO extends PageArea {
return new GenericCellTablePO<>(this.driver, this.eventsCellTable, EventEntryPO.class);
}
private ConfirmDialogPO createEvent(String name, String desc, String venue, Date start, Date end, boolean isPublic) {
private ConfirmDialogPO createEvent(String name, String desc, String venue, Date start, Date end, boolean isPublic, String... courseAreaNames) {
createEventButton.click();
EventCreateDialogPO createDialog = getPO(EventCreateDialogPO::new, ID_EVENT_CREATE_DIALOG);
createDialog.setValues(name, desc, venue, start, end, isPublic);
if(courseAreaNames.length > 0) {
CourseAreasTabPO courseAreasTab = createDialog.goToCourseAreasTab();
for (String courseAreaName : courseAreaNames) {
courseAreasTab.addNewCourse(courseAreaName);
}
}
createDialog.pressOk();
return waitForPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_LEADERBOARD_GROUP_CONFIRM_DIALOG, 5);
}
private ConfirmDialogPO createRegatta(String name, String boatClass, Date start, Date end) {
private ConfirmDialogPO createRegatta(String name, String boatClass, Date start, Date end, String eventToLink, String courseAreaToLink) {
RegattaCreateDialogPO createDialog = getPO(RegattaCreateDialogPO::new, ID_REGATTA_CREATE_DIALOG);
createDialog.setValues(name, boatClass, start, end);
if(eventToLink != null && courseAreaToLink != null) {
createDialog.setEventAndCourseArea(eventToLink, courseAreaToLink);
}
createDialog.pressOk();
return waitForPO(ConfirmDialogPO::new, ID_CREATE_DEFAULT_REGATTA_LEADERBOARD_CONFIRM_DIALOG, 5);
}
private ConfirmDialogPO createRegatta(String name, String boatClass, Date start, Date end) {
return createRegatta(name, boatClass, start, end, null, null);
}
public RegattaOverviewPage goToRegattaOverviewOfEvent(String eventName) {
return RegattaOverviewPage.goToPage(driver, getRegattaOverviewUrlOfEvent(eventName));
}
public String getRegattaOverviewUrlOfEvent(String eventName) {
CellTablePO<EventEntryPO> eventsTable = getEventsTable();
eventsTable.selectEntry(eventsTable.getEntry(eventName));
waitForElement(ID_LINK_EVENT_OVERVIEW_URL_LABEL);
WebElement element = findElementBySeleniumId(ID_LINK_EVENT_OVERVIEW_URL_LABEL);
String regattaOverviewLink = element.getAttribute("href");
return regattaOverviewLink;
}
}
@@ -69,8 +69,8 @@ public class EventCreateDialogPO extends DataEntryDialogPO {
return goToTab("Leaderboard groups", LEADERBOARD_GROUPS_TAB_ID);
}
WebElement goToCourseAreasTab() {
return goToTab("Course areas", COURSE_AREAS_TAB_ID);
CourseAreasTabPO goToCourseAreasTab() {
return new CourseAreasTabPO(driver, goToTab("Course areas", COURSE_AREAS_TAB_ID));
}
WebElement goToImagesTab() {
@@ -3,31 +3,36 @@ package com.sap.sailing.selenium.pages.adminconsole.leaderboard;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.sap.sailing.selenium.core.BySeleniumId;
import com.sap.sailing.selenium.core.FindBy;
import com.sap.sailing.selenium.pages.PageArea;
import com.sap.sailing.selenium.pages.gwt.CheckBoxPO;
public class LeaderboardPageConfigurationPanelPO extends PageArea {
@FindBy(how = BySeleniumId.class, using = "AllowForRaceDetailsCheckBox")
private WebElement allowForRaceDetailsCheckBox;
@FindBy(how = BySeleniumId.class, using = "ShowChartsCheckBox")
private WebElement showChartsCheckBox;
@FindBy(how = BySeleniumId.class, using = "ShowOverallLeaderboardCheckBox")
private WebElement showOverallLeaderboardCheckBox;
public LeaderboardPageConfigurationPanelPO(WebDriver driver, WebElement element) {
super(driver, element);
}
public void setAllowForRaceDetails(boolean selected) {
WebElement element = findElementBySeleniumId("AllowForRaceDetailsCheckBox");
CheckBoxPO checkbox = new CheckBoxPO(driver, element);
checkbox.setSelected(selected);
new CheckBoxPO(driver, allowForRaceDetailsCheckBox).setSelected(selected);
}
public void setShowCharts(boolean selected) {
WebElement element = findElementBySeleniumId("ShowChartsCheckBox");
CheckBoxPO checkbox = new CheckBoxPO(driver, element);
checkbox.setSelected(selected);
new CheckBoxPO(driver, showChartsCheckBox).setSelected(selected);
}
public void setShowOverallLeaderboard(boolean selected) {
WebElement element = findElementBySeleniumId("ShowOverallLeaderboardCheckBox");
CheckBoxPO checkbox = new CheckBoxPO(driver, element);
checkbox.setSelected(selected);
new CheckBoxPO(driver, showOverallLeaderboardCheckBox).setSelected(selected);
}
}
@@ -9,6 +9,7 @@ import com.sap.sailing.selenium.core.BySeleniumId;
import com.sap.sailing.selenium.core.FindBy;
import com.sap.sailing.selenium.pages.common.DataEntryDialogPO;
import com.sap.sailing.selenium.pages.gwt.BetterDateTimeBoxPO;
import com.sap.sailing.selenium.pages.gwt.ListBoxPO;
import com.sap.sailing.selenium.pages.gwt.TextBoxPO;
public class RegattaCreateDialogPO extends DataEntryDialogPO {
@@ -26,10 +27,10 @@ public class RegattaCreateDialogPO extends DataEntryDialogPO {
// @FindBy(how = BySeleniumId.class, using = "ScoringSchemeListBox")
// private WebElement scoringSystemDropDown;
// @FindBy(how = BySeleniumId.class, using = "EventListBox")
// private WebElement eventDropDown;
// @FindBy(how = BySeleniumId.class, using = "CourseAreaListBox")
// private WebElement courseAreaDropDown;
@FindBy(how = BySeleniumId.class, using = "EventListBox")
private WebElement eventDropDown;
@FindBy(how = BySeleniumId.class, using = "CourseAreaListBox")
private WebElement courseAreaDropDown;
@FindBy(how = BySeleniumId.class, using = "AddSeriesButton")
private WebElement addSeriesButton;
@@ -47,6 +48,11 @@ public class RegattaCreateDialogPO extends DataEntryDialogPO {
this.boatClassTextBox.sendKeys(boatClass);
}
public void setEventAndCourseArea(String event, String courseArea) {
ListBoxPO.create(driver, eventDropDown).selectOptionByLabel(event);
ListBoxPO.create(driver, courseAreaDropDown).selectOptionByLabel(courseArea);
}
public void setValues(String name, String boatClass, Date startDate, Date endDate) {
this.setRegattaName(name);
this.setBoatClass(boatClass);
@@ -6,7 +6,9 @@ import org.openqa.selenium.WebElement;
import com.sap.sailing.selenium.core.BySeleniumId;
import com.sap.sailing.selenium.core.FindBy;
import com.sap.sailing.selenium.pages.PageArea;
import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO;
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaListCompositePO.RegattaDescriptor;
import com.sap.sailing.selenium.pages.common.ConfirmDialogPO;
public class RegattaStructureManagementPanelPO extends PageArea {
public static final String DEFAULT_SERIES_NAME = "DefaultSelenium"; //$NON-NLS-1$
@@ -51,6 +53,16 @@ public class RegattaStructureManagementPanelPO extends PageArea {
createDefaultRegattaLeaderboardDialog.pressCancel();
}
public void createRegattaAndAddToEvent(RegattaDescriptor regatta, String event, String courseArea) {
RegattaCreateDialogPO createRegattaDialog = startRegattaCreation();
createRegattaDialog.setRegattaName(regatta.getName()+" ("+regatta.getBoatClass()+")");
createRegattaDialog.setBoatClass(regatta.getBoatClass());
createRegattaDialog.setEventAndCourseArea(event, courseArea);
createRegattaDialog.pressOk();
createDefaultRegattaLeaderboard().pressOk();
waitForPO(ConfirmDialogPO::new, EventConfigurationPanelPO.ID_LINK_LEADERBORAD_TO_GROUP_DIALOG, 5).pressOk();
}
private DefaultRegattaLeaderboardCreateDialogPO createDefaultRegattaLeaderboard() {
WebElement dialog = findElementBySeleniumId(this.driver, "CreateDefaultRegattaLeaderboardDialog"); //$NON-NLS-1$
return new DefaultRegattaLeaderboardCreateDialogPO(this.driver, dialog);
@@ -11,6 +11,9 @@ import com.sap.sailing.selenium.core.FindBy;
import com.sap.sailing.selenium.pages.PageArea;
public abstract class DataEntryDialogPO extends PageArea {
private static final String ID_MAKE_DEFAULT_BUTTON = "MakeDefaultButton";
@FindBy(how = BySeleniumId.class, using = "StatusLabel")
private WebElement statusLabel;
@@ -73,7 +76,7 @@ public abstract class DataEntryDialogPO extends PageArea {
}
public void pressMakeDefault() {
WebElement element = findElementBySeleniumId("MakeDefaultButton");
WebElement element = findElementBySeleniumId(ID_MAKE_DEFAULT_BUTTON);
element.click();
ExpectedCondition<Alert> condition = ExpectedConditions.alertIsPresent();
Alert alert = condition.apply(this.driver);
@@ -85,4 +88,8 @@ public abstract class DataEntryDialogPO extends PageArea {
}
}
public boolean isMakeDefaultButtonVisible() {
return !driver.findElements(new BySeleniumId(ID_MAKE_DEFAULT_BUTTON)).isEmpty();
}
}
@@ -13,7 +13,7 @@ import com.sap.sailing.selenium.pages.PageObject;
public class CheckBoxPO extends AbstractInputPO {
private static final String TAG_NAME = "span";
private static final String CSS_CLASS = "gwt-CheckBox";
public static final String CSS_CLASS = "gwt-CheckBox";
@FindBy(how = ByTagName.class, using = "input")
private WebElement input;
@@ -0,0 +1,63 @@
package com.sap.sailing.selenium.pages.gwt;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select;
import com.sap.sailing.selenium.pages.PageObject;
/**
* {@link PageObject} implementation for GWT list boxes.
*/
public class ListBoxPO extends AbstractInputPO {
private static final String TAG_NAME = "select";
private static final String CSS_CLASS = "gwt-ListBox";
private final Select selectBox;
/**
* Factory method to create a {@link ListBoxPO}.
*
* @param driver the web driver to use
* @param element the element representing the list box on the page
* @return a new {@link ListBoxPO} instance
*/
public static ListBoxPO create(WebDriver driver, WebElement element) {
return new ListBoxPO(driver, element);
}
/**
* @see AbstractInputPO#AbstractInputPO(WebDriver, WebElement)
*/
public ListBoxPO(WebDriver driver, WebElement element) {
super(driver, element);
selectBox = new Select(element);
}
public String getSelectedOptionLabel() {
return this.selectBox.getFirstSelectedOption().getText();
}
public String getSelectedOptionValue() {
return this.selectBox.getFirstSelectedOption().getAttribute("value");
}
public void selectOptionByLabel(String optionLabel) {
this.selectBox.selectByVisibleText(optionLabel);
}
public void selectOptionByValue(String optionValue) {
this.selectBox.selectByValue(optionValue);
}
@Override
protected String getTagName() {
return TAG_NAME;
}
@Override
protected String getCssClassName() {
return CSS_CLASS;
}
}
@@ -0,0 +1,44 @@
package com.sap.sailing.selenium.pages.gwt;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.sap.sailing.selenium.pages.PageObject;
/**
* {@link PageObject} implementation for GWT text boxes.
*/
public class SuggestBoxPO extends TextBoxBasePO {
private static final String TAG_NAME = "input";
private static final String CSS_CLASS = "gwt-SuggestBox";
/**
* Factory method to create a {@link SuggestBoxPO}.
*
* @param driver the web driver to use
* @param element the element representing the suggest box on the page
* @return a new {@link SuggestBoxPO} instance
*/
public static SuggestBoxPO create(WebDriver driver, WebElement element) {
return new SuggestBoxPO(driver, element);
}
/**
* @see TextBoxBasePO#TextBoxBasePO(WebDriver, WebElement)
*/
protected SuggestBoxPO(WebDriver driver, WebElement element) {
super(driver, element);
}
@Override
protected String getTagName() {
return TAG_NAME;
}
@Override
protected String getCssClassName() {
return CSS_CLASS;
}
}
@@ -19,8 +19,8 @@ import junit.framework.Assert;
*/
public class LeaderboardPage extends HostPage {
private static final String LEADERBOAR_PARAMTER_NAME = "name"; //$NON-NLS-1$
private static final String SHOW_RACE_DETAILS_PARAMTER_NAME = "showRaceDetails"; //$NON-NLS-1$
private static final String LEADERBOAR_PARAMETER_NAME = "name"; //$NON-NLS-1$
private static final String SHOW_RACE_DETAILS_PARAMETER_NAME = "showRaceDetails"; //$NON-NLS-1$
private static final String REFRESH_INTERVAL_MILLIS = "refreshIntervalMillis"; //$NON-NLS-1$
private static final String AUTO_REFRESH_ENABLED_STRING = "Pause automatic refresh"; //$NON-NLS-1$
@@ -61,11 +61,11 @@ public class LeaderboardPage extends HostPage {
}
private static String getLeaderboard(String leaderboard) {
return LEADERBOAR_PARAMTER_NAME + "=" + leaderboard; //$NON-NLS-1$
return LEADERBOAR_PARAMETER_NAME + "=" + leaderboard; //$NON-NLS-1$
}
private static String getShowRaceDeatails(boolean raceDetails) {
return SHOW_RACE_DETAILS_PARAMTER_NAME + "=" + raceDetails; //$NON-NLS-1$
return SHOW_RACE_DETAILS_PARAMETER_NAME + "=" + raceDetails; //$NON-NLS-1$
}
private static String getAutoRefreshIntervalMillis(long autoRefreshIntervalInMillis) {
@@ -93,7 +93,7 @@ public class LeaderboardSettingsPanelPO extends PageArea {
return Integer.valueOf(textField.getAttribute("value"));
}
public void selectDetailsAndUnselectOthers(DetailCheckboxInfo...detailsToSelect) {
public void selectDetailsAndDeselectOther(DetailCheckboxInfo...detailsToSelect) {
Arrays.sort(detailsToSelect);
for (DetailCheckboxInfo detail : DetailCheckboxInfo.values()) {
boolean selected = Arrays.binarySearch(detailsToSelect, detail) >= 0;
@@ -0,0 +1,36 @@
package com.sap.sailing.selenium.pages.regattaoverview;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.sap.sailing.selenium.core.BySeleniumId;
import com.sap.sailing.selenium.core.FindBy;
import com.sap.sailing.selenium.pages.HostPage;
/**
* <p>The page object representing the leaderboard.</p>
*
* @author
* D049941
*/
public class RegattaOverviewPage extends HostPage {
@FindBy(how = BySeleniumId.class, using = "RegattaOverviewSettingsButton")
private WebElement settingsButton;
public static RegattaOverviewPage goToPage(WebDriver driver, String href) {
driver.get(href);
return new RegattaOverviewPage(driver);
}
private RegattaOverviewPage(WebDriver driver) {
super(driver);
}
public RegattaOverviewSettingsDialogPO getRegattaOverviewSettingsDialog() {
this.settingsButton.click();
return new RegattaOverviewSettingsDialogPO(this.driver,
findElementBySeleniumId(this.driver, "RegattaRacesStatesSettingsDialog"));
}
}
@@ -0,0 +1,109 @@
package com.sap.sailing.selenium.pages.regattaoverview;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.sap.sailing.selenium.core.BySeleniumId;
import com.sap.sailing.selenium.core.FindBy;
import com.sap.sailing.selenium.pages.common.DataEntryDialogPO;
import com.sap.sailing.selenium.pages.gwt.CheckBoxPO;
public class RegattaOverviewSettingsDialogPO extends DataEntryDialogPO {
@FindBy(how = BySeleniumId.class, using = "ShowOnlyRacesOfSameDayCheckBox")
private WebElement showOnlyRacesOfSameDayCheckBox;
@FindBy(how = BySeleniumId.class, using = "ShowOnlyCurrentlyRunningRacesCheckBox")
private WebElement showOnlyCurrentlyRunningRacesCheckBox;
@FindBy(how = BySeleniumId.class, using = "CourseAreaPanel")
private WebElement courseAreaPanel;
@FindBy(how = BySeleniumId.class, using = "RegattaNamesPanel")
private WebElement regattaNamesPanel;
private final List<WebElement> courseAreaCheckBoxes;
private final List<WebElement> regattaNamesCheckBoxes;
public RegattaOverviewSettingsDialogPO(WebDriver driver, WebElement element) {
super(driver, element);
courseAreaCheckBoxes = courseAreaPanel.findElements(By.className(CheckBoxPO.CSS_CLASS));
regattaNamesCheckBoxes = regattaNamesPanel.findElements(By.className(CheckBoxPO.CSS_CLASS));
}
public void setShowOnlyRacesOfSameDay(boolean selected) {
new CheckBoxPO(driver, showOnlyRacesOfSameDayCheckBox).setSelected(selected);
}
public boolean isShowOnlyRacesOfSameDay() {
return new CheckBoxPO(driver, showOnlyRacesOfSameDayCheckBox).isSelected();
}
public void setShowOnlyCurrentlyRunningRaces(boolean selected) {
new CheckBoxPO(driver, showOnlyCurrentlyRunningRacesCheckBox).setSelected(selected);
}
public boolean isShowOnlyCurrentlyRunningRaces() {
return new CheckBoxPO(driver, showOnlyCurrentlyRunningRacesCheckBox).isSelected();
}
private List<String> getSelectedCheckBoxLabels(List<WebElement> checkBoxList) {
List<String> selectedCheckBoxLabes = new ArrayList<>();
for (WebElement element : checkBoxList) {
CheckBoxPO checkbox = CheckBoxPO.create(driver, element);
if (checkbox.isSelected()) {
selectedCheckBoxLabes.add(checkbox.getLabel());
}
}
return selectedCheckBoxLabes;
}
private List<String> getAvailableCheckBoxLabels(List<WebElement> checkBoxList) {
List<String> selectedCheckBoxLabes = new ArrayList<>();
for (WebElement element : checkBoxList) {
CheckBoxPO checkbox = CheckBoxPO.create(driver, element);
selectedCheckBoxLabes.add(checkbox.getLabel());
}
return selectedCheckBoxLabes;
}
private void selectCheckBoxLabelsAndDeselectOther(List<WebElement> checkBoxList, List<String> checkBoxLabels) {
for (WebElement element : checkBoxList) {
CheckBoxPO checkbox = CheckBoxPO.create(driver, element);
if (checkBoxLabels.contains(checkbox.getLabel())) {
checkbox.setSelected(true);
} else {
checkbox.setSelected(false);
}
}
}
public List<String> getSelectedCourseAreas() {
return getSelectedCheckBoxLabels(courseAreaCheckBoxes);
}
public List<String> getSelectedRegattaNames() {
return getSelectedCheckBoxLabels(regattaNamesCheckBoxes);
}
public List<String> getAvailableCourseAreas() {
return getAvailableCheckBoxLabels(courseAreaCheckBoxes);
}
public List<String> getAvailableRegattaNames() {
return getAvailableCheckBoxLabels(regattaNamesCheckBoxes);
}
public void selectCourseAreasAndDeselectOther(List<String> courseAreaLabelsToSelect) {
selectCheckBoxLabelsAndDeselectOther(courseAreaCheckBoxes, courseAreaLabelsToSelect);
}
public void selectRegattaNamesAndDeselectOther(List<String> courseAreaLabelsToSelect) {
selectCheckBoxLabelsAndDeselectOther(regattaNamesCheckBoxes, courseAreaLabelsToSelect);
}
}
@@ -22,6 +22,7 @@ import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardDetail
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardPageConfigurationPanelPO;
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardUrlConfigurationDialogPO;
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaListCompositePO.RegattaDescriptor;
import com.sap.sailing.selenium.pages.adminconsole.regatta.RegattaStructureManagementPanelPO;
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesListPO;
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesListPO.Status;
import com.sap.sailing.selenium.pages.adminconsole.tracking.TrackedRacesListPO.TrackedRaceDescriptor;
@@ -34,6 +35,8 @@ import com.sap.sailing.selenium.pages.leaderboard.LeaderboardSettingsPanelPO;
import com.sap.sailing.selenium.pages.leaderboard.LeaderboardTablePO;
import com.sap.sailing.selenium.pages.raceboard.MapSettingsPO;
import com.sap.sailing.selenium.pages.raceboard.RaceBoardPage;
import com.sap.sailing.selenium.pages.regattaoverview.RegattaOverviewPage;
import com.sap.sailing.selenium.pages.regattaoverview.RegattaOverviewSettingsDialogPO;
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
public class SettingsTest extends AbstractSeleniumTest {
@@ -45,7 +48,6 @@ public class SettingsTest extends AbstractSeleniumTest {
private static final String BMW_CUP_REGATTA = "BMW Cup (J80)"; //$NON-NLS-1$
private static final String AUDI_CUP_REGATTA = "Audi Business Cup (J70)"; //$NON-NLS-1$
private static final String BMW_RACE = "BMW Cup Race %d";
// private static final String AUDI_RACE = "Audi Business Cup Race %d";
private static final String BMW_CUP_EVENTS_DESC = "BMW Cup Description";
private static final String AUDI_CUP_EVENTS_DESC = "";
private static final String BMW_VENUE = "Somewhere";
@@ -60,7 +62,10 @@ public class SettingsTest extends AbstractSeleniumTest {
.getTime();
private static final String BMW_CUP_RACE_NAME = "R1";
// private static final String AUDI_CUP_RACE_NAME = "R1";
private static final String CUSTOM_COURSE_AREA = "Custom X";
private static final String URL_PARAMETER_IGNORE_LOCAL_SETTINGS = "ignoreLocalSettings=true";
private TrackableRaceDescriptor trackableRace;
@@ -175,7 +180,7 @@ public class SettingsTest extends AbstractSeleniumTest {
DetailCheckboxInfo.AVERAGE_JIBE_LOSS, DetailCheckboxInfo.PENALTY_CIRCLE
};
leaderboardSettingsPanel.selectDetailsAndUnselectOthers(detailsToSelect);
leaderboardSettingsPanel.selectDetailsAndDeselectOther(detailsToSelect);
leaderboardSettingsPanel.setRefreshInterval(2);
@@ -201,7 +206,7 @@ public class SettingsTest extends AbstractSeleniumTest {
leaderboardSettingsPanel = urlConfigurationDialog.goToLeaderboardSettings();
leaderboardSettingsPanel.setNumberOfRacesToDisplay(2);
leaderboardSettingsPanel.selectDetailsAndUnselectOthers();
leaderboardSettingsPanel.selectDetailsAndDeselectOther();
// open settings dialog of configurated leaderboard and match the set values with forwarded values
leaderboardPage = urlConfigurationDialog.openLeaderboard();
@@ -262,7 +267,7 @@ public class SettingsTest extends AbstractSeleniumTest {
leaderboardSettingsPanel.setCheckboxValue("R2CheckBox", false);
leaderboardSettingsPanel.setCheckboxValue("R3CheckBox", false);
leaderboardSettingsPanel.selectDetailsAndUnselectOthers(detailsToSelect);
leaderboardSettingsPanel.selectDetailsAndDeselectOther(detailsToSelect);
// check the displaying leaderboard table columns of a tracked race
LeaderboardPage leaderboardPage = urlConfigurationDialog.openLeaderboard();
@@ -327,7 +332,7 @@ public class SettingsTest extends AbstractSeleniumTest {
DetailCheckboxInfo.AVERAGE_JIBE_LOSS, DetailCheckboxInfo.PENALTY_CIRCLE
};
leaderboardSettingsPanel.selectDetailsAndUnselectOthers(detailsToSelect);
leaderboardSettingsPanel.selectDetailsAndDeselectOther(detailsToSelect);
LeaderboardPageConfigurationPanelPO leaderboardPageSettings = urlConfigurationDialog
.goToLeaderboardPageSettings();
@@ -352,7 +357,7 @@ public class SettingsTest extends AbstractSeleniumTest {
DetailCheckboxInfo.AVERAGE_MANEUVER_LOSS
};
leaderboardSettingsPanel.selectDetailsAndUnselectOthers(overallDetailsToSelect);
leaderboardSettingsPanel.selectDetailsAndDeselectOther(overallDetailsToSelect);
// open settings dialog of configurated leaderboard and match the set values with forwarded values
LeaderboardPage leaderboardPage = urlConfigurationDialog.openLeaderboard();
@@ -420,7 +425,7 @@ public class SettingsTest extends AbstractSeleniumTest {
DetailCheckboxInfo.AVERAGE_MANEUVER_LOSS
};
leaderboardSettingsPanel.selectDetailsAndUnselectOthers(newDetails);
leaderboardSettingsPanel.selectDetailsAndDeselectOther(newDetails);
int newRefreshInterval = 2;
leaderboardSettingsPanel.setRefreshInterval(newRefreshInterval);
@@ -481,4 +486,139 @@ public class SettingsTest extends AbstractSeleniumTest {
Assert.assertArrayEquals(newDetails, leaderboardSettingsPanel.getSelectedDetails());
Assert.assertEquals(newRefreshInterval, leaderboardSettingsPanel.getRefreshInterval());
}
@Test
public void testRegattaOverviewSettingsHandling() {
// create event
AdminConsolePage adminConsole = AdminConsolePage.goToPage(getWebDriver(), getContextRoot());
EventConfigurationPanelPO events = adminConsole.goToEvents();
events.createEventWithDefaultLeaderboardGroupRegattaAndDefaultLeaderboard(BMW_CUP_EVENT, BMW_CUP_EVENTS_DESC,
BMW_VENUE, BMW_START_EVENT_TIME, BMW_STOP_EVENT_TIME, true, BMW_CUP_REGATTA, BMW_CUP_BOAT_CLASS,
BMW_START_EVENT_TIME, BMW_STOP_EVENT_TIME, false, CUSTOM_COURSE_AREA);
//add a second regatta to the event and link its leaderboard to the event leaderboard
RegattaStructureManagementPanelPO regattas = adminConsole.goToRegattaStructure();
regattas.createRegattaAndAddToEvent(new RegattaDescriptor(AUDI_CUP_REGATTA, AUDI_CUP_BOAT_CLASS), BMW_CUP_EVENT, CUSTOM_COURSE_AREA);
//open regatta overview for the created event
events = adminConsole.goToEvents();
RegattaOverviewPage regattaOverviewPage = events.goToRegattaOverviewOfEvent(BMW_CUP_EVENT);
RegattaOverviewSettingsDialogPO regattaOverviewSettingsDialog = regattaOverviewPage.getRegattaOverviewSettingsDialog();
//assert state
String regattaOverviewUrl = regattaOverviewPage.getCurrentUrl();
Assert.assertTrue(regattaOverviewUrl.contains(URL_PARAMETER_IGNORE_LOCAL_SETTINGS));
Assert.assertFalse(regattaOverviewSettingsDialog.isMakeDefaultButtonVisible());
//per default all course areas and regatta names are selected => selectedValues equals availableValues
List<String> initiallySelectedCourseAreas = regattaOverviewSettingsDialog.getSelectedCourseAreas();
List<String> initiallySelectedRegattaNames = regattaOverviewSettingsDialog.getSelectedRegattaNames();
Assert.assertEquals(2, initiallySelectedCourseAreas.size());
Assert.assertEquals(2, initiallySelectedRegattaNames.size());
//save initial state
boolean initialShowOnlyCurrentlyRunningRaces = regattaOverviewSettingsDialog.isShowOnlyCurrentlyRunningRaces();
boolean initialShowOnlyRacesOfSameDay = regattaOverviewSettingsDialog.isShowOnlyRacesOfSameDay();
//apply new state
List<String> newSelectedCourseAreas = initiallySelectedCourseAreas.subList(1, 2);
List<String> newSelectedRegattaNames = initiallySelectedRegattaNames.subList(0, 1);
regattaOverviewSettingsDialog.selectCourseAreasAndDeselectOther(newSelectedCourseAreas);
regattaOverviewSettingsDialog.selectRegattaNamesAndDeselectOther(newSelectedRegattaNames);
regattaOverviewSettingsDialog.setShowOnlyCurrentlyRunningRaces(!initialShowOnlyCurrentlyRunningRaces);
regattaOverviewSettingsDialog.setShowOnlyRacesOfSameDay(!initialShowOnlyRacesOfSameDay);
regattaOverviewSettingsDialog.pressOk();
//ensure the regatta overview has still the initial state after reload due to ignoreLocalSettings flag
regattaOverviewPage = RegattaOverviewPage.goToPage(getWebDriver(), regattaOverviewUrl);
regattaOverviewSettingsDialog = regattaOverviewPage.getRegattaOverviewSettingsDialog();
Assert.assertEquals(initiallySelectedCourseAreas, regattaOverviewSettingsDialog.getSelectedCourseAreas());
Assert.assertEquals(initiallySelectedRegattaNames, regattaOverviewSettingsDialog.getSelectedRegattaNames());
Assert.assertEquals(initialShowOnlyCurrentlyRunningRaces, regattaOverviewSettingsDialog.isShowOnlyCurrentlyRunningRaces());
Assert.assertEquals(initialShowOnlyRacesOfSameDay, regattaOverviewSettingsDialog.isShowOnlyRacesOfSameDay());
//verify settings storage support without ignoreLocalSettingsParameter
String regattaOverviewUrlWithoutIgnoreLocalSettings = regattaOverviewUrl.replace(URL_PARAMETER_IGNORE_LOCAL_SETTINGS, "");
regattaOverviewPage = RegattaOverviewPage.goToPage(getWebDriver(), regattaOverviewUrlWithoutIgnoreLocalSettings);
regattaOverviewSettingsDialog = regattaOverviewPage.getRegattaOverviewSettingsDialog();
Assert.assertTrue(regattaOverviewSettingsDialog.isMakeDefaultButtonVisible());
regattaOverviewSettingsDialog.selectCourseAreasAndDeselectOther(newSelectedCourseAreas);
regattaOverviewSettingsDialog.selectRegattaNamesAndDeselectOther(newSelectedRegattaNames);
regattaOverviewSettingsDialog.setShowOnlyCurrentlyRunningRaces(!initialShowOnlyCurrentlyRunningRaces);
regattaOverviewSettingsDialog.setShowOnlyRacesOfSameDay(!initialShowOnlyRacesOfSameDay);
regattaOverviewSettingsDialog.pressOk();
//reload and verify the regatta overview has previous values set
regattaOverviewPage = RegattaOverviewPage.goToPage(getWebDriver(), regattaOverviewUrlWithoutIgnoreLocalSettings);
regattaOverviewSettingsDialog = regattaOverviewPage.getRegattaOverviewSettingsDialog();
Assert.assertEquals(newSelectedCourseAreas, regattaOverviewSettingsDialog.getSelectedCourseAreas());
Assert.assertEquals(newSelectedRegattaNames, regattaOverviewSettingsDialog.getSelectedRegattaNames());
Assert.assertEquals(!initialShowOnlyCurrentlyRunningRaces, regattaOverviewSettingsDialog.isShowOnlyCurrentlyRunningRaces());
Assert.assertEquals(!initialShowOnlyRacesOfSameDay, regattaOverviewSettingsDialog.isShowOnlyRacesOfSameDay());
// create second event
adminConsole = AdminConsolePage.goToPage(getWebDriver(), getContextRoot());
events = adminConsole.goToEvents();
events.createEventWithDefaultLeaderboardGroupRegattaAndDefaultLeaderboard(AUDI_CUP_EVENT, AUDI_CUP_EVENTS_DESC,
AUDI_VENUE, AUDI_START_EVENT_TIME, AUDI_STOP_EVENT_TIME, true, AUDI_CUP_REGATTA, AUDI_CUP_BOAT_CLASS,
AUDI_START_EVENT_TIME, AUDI_STOP_EVENT_TIME, false, CUSTOM_COURSE_AREA);
//add a second regatta to the event and link its leaderboard to the event leaderboard
regattas = adminConsole.goToRegattaStructure();
regattas.createRegattaAndAddToEvent(new RegattaDescriptor(BMW_CUP_REGATTA, BMW_CUP_BOAT_CLASS), AUDI_CUP_EVENT, CUSTOM_COURSE_AREA);
//open regatta overview without ignoreLocalSettings flag for the recently created event
events = adminConsole.goToEvents();
String audiCupRegattaOverviewUrl = events.getRegattaOverviewUrlOfEvent(AUDI_CUP_EVENT);
String audiCupRegattaOverviewUrlWithoutIgnoreLocalSettings = audiCupRegattaOverviewUrl.replace(URL_PARAMETER_IGNORE_LOCAL_SETTINGS, "");
regattaOverviewPage = RegattaOverviewPage.goToPage(getWebDriver(), audiCupRegattaOverviewUrlWithoutIgnoreLocalSettings);
regattaOverviewSettingsDialog = regattaOverviewPage.getRegattaOverviewSettingsDialog();
//verify the initial values are untouched
List<String> initiallySelectedCourseAreasForAudi = regattaOverviewSettingsDialog.getSelectedCourseAreas();
List<String> initiallySelectedRegattaNamesForAudi = regattaOverviewSettingsDialog.getSelectedRegattaNames();
Assert.assertEquals(2, initiallySelectedCourseAreasForAudi.size());
Assert.assertEquals(2, initiallySelectedRegattaNamesForAudi.size());
Assert.assertEquals(initialShowOnlyCurrentlyRunningRaces, regattaOverviewSettingsDialog.isShowOnlyCurrentlyRunningRaces());
Assert.assertEquals(initialShowOnlyRacesOfSameDay, regattaOverviewSettingsDialog.isShowOnlyRacesOfSameDay());
//apply new state
List<String> newSelectedCourseAreasForAudi = initiallySelectedCourseAreasForAudi.subList(0, 1);
List<String> newSelectedRegattaNamesForAudi = initiallySelectedRegattaNamesForAudi.subList(1, 2);
regattaOverviewSettingsDialog.selectCourseAreasAndDeselectOther(newSelectedCourseAreasForAudi);
regattaOverviewSettingsDialog.selectRegattaNamesAndDeselectOther(newSelectedRegattaNamesForAudi);
regattaOverviewSettingsDialog.setShowOnlyCurrentlyRunningRaces(!initialShowOnlyCurrentlyRunningRaces);
regattaOverviewSettingsDialog.setShowOnlyRacesOfSameDay(initialShowOnlyRacesOfSameDay);
regattaOverviewSettingsDialog.pressMakeDefault();
//reload first event and verify the regatta overview has previous values set
regattaOverviewPage = RegattaOverviewPage.goToPage(getWebDriver(), regattaOverviewUrlWithoutIgnoreLocalSettings);
regattaOverviewSettingsDialog = regattaOverviewPage.getRegattaOverviewSettingsDialog();
Assert.assertEquals(newSelectedCourseAreas, regattaOverviewSettingsDialog.getSelectedCourseAreas());
Assert.assertEquals(newSelectedRegattaNames, regattaOverviewSettingsDialog.getSelectedRegattaNames());
Assert.assertEquals(!initialShowOnlyCurrentlyRunningRaces, regattaOverviewSettingsDialog.isShowOnlyCurrentlyRunningRaces());
Assert.assertEquals(!initialShowOnlyRacesOfSameDay, regattaOverviewSettingsDialog.isShowOnlyRacesOfSameDay());
//verify global settings with make default button
regattaOverviewSettingsDialog.pressMakeDefault();
//open second event again and verify that the global settings of the first event have applied
regattaOverviewPage = RegattaOverviewPage.goToPage(getWebDriver(), audiCupRegattaOverviewUrlWithoutIgnoreLocalSettings);
regattaOverviewSettingsDialog = regattaOverviewPage.getRegattaOverviewSettingsDialog();
//context specific settings must stay initial
Assert.assertEquals(2, regattaOverviewSettingsDialog.getSelectedCourseAreas().size());
Assert.assertEquals(2, regattaOverviewSettingsDialog.getSelectedRegattaNames().size());
//global settings must match with the settings of the first event
Assert.assertEquals(!initialShowOnlyCurrentlyRunningRaces, regattaOverviewSettingsDialog.isShowOnlyCurrentlyRunningRaces());
Assert.assertEquals(!initialShowOnlyRacesOfSameDay, regattaOverviewSettingsDialog.isShowOnlyRacesOfSameDay());
//verify that the stored values are ignored with ignoreLocalSettings flag set
regattaOverviewPage = RegattaOverviewPage.goToPage(getWebDriver(), audiCupRegattaOverviewUrl);
regattaOverviewSettingsDialog = regattaOverviewPage.getRegattaOverviewSettingsDialog();
Assert.assertEquals(initiallySelectedCourseAreasForAudi, regattaOverviewSettingsDialog.getSelectedCourseAreas());
Assert.assertEquals(initiallySelectedRegattaNamesForAudi, regattaOverviewSettingsDialog.getSelectedRegattaNames());
Assert.assertEquals(initialShowOnlyCurrentlyRunningRaces, regattaOverviewSettingsDialog.isShowOnlyCurrentlyRunningRaces());
Assert.assertEquals(initialShowOnlyRacesOfSameDay, regattaOverviewSettingsDialog.isShowOnlyRacesOfSameDay());
}
}