diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/regattaoverview/client/RegattaOverviewPanel.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/regattaoverview/client/RegattaOverviewPanel.java index 4ba8cb2ab88..29b936663a4 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/regattaoverview/client/RegattaOverviewPanel.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/regattaoverview/client/RegattaOverviewPanel.java @@ -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()); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/regattaoverview/client/RegattaRaceStatesSettingsDialogComponent.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/regattaoverview/client/RegattaRaceStatesSettingsDialogComponent.java index 421acd32742..5531cde7450 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/regattaoverview/client/RegattaRaceStatesSettingsDialogComponent.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/regattaoverview/client/RegattaRaceStatesSettingsDialogComponent.java @@ -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)); diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java index 9450061cfe8..d1a33fb04fc 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/HostPage.java @@ -76,4 +76,8 @@ public abstract class HostPage extends PageObject { protected interface HostPageSupplier { T get(WebDriver driver); } + + public String getCurrentUrl() { + return driver.getCurrentUrl(); + } } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/CourseAreasTabPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/CourseAreasTabPO.java new file mode 100644 index 00000000000..359c3b22663 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/CourseAreasTabPO.java @@ -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(); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java index 0a730017899..05f0eecbe8b 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventConfigurationPanelPO.java @@ -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 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; + } + } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java index 8a345a3c2a9..af22c31ff14 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/event/EventCreateDialogPO.java @@ -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() { diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardPageConfigurationPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardPageConfigurationPanelPO.java index 0412f6d5960..8fc5974b9e4 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardPageConfigurationPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/leaderboard/LeaderboardPageConfigurationPanelPO.java @@ -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); } } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaCreateDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaCreateDialogPO.java index bbd768e87e5..faae30a507a 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaCreateDialogPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaCreateDialogPO.java @@ -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); diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaStructureManagementPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaStructureManagementPanelPO.java index 82978dafb79..10683cc2646 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaStructureManagementPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/adminconsole/regatta/RegattaStructureManagementPanelPO.java @@ -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); diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DataEntryDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DataEntryDialogPO.java index b02ed77e90a..2fa9d9ec354 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DataEntryDialogPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/common/DataEntryDialogPO.java @@ -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 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(); + } } diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CheckBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CheckBoxPO.java index 28c00b5c4ed..b2fd6892183 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CheckBoxPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/CheckBoxPO.java @@ -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; diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/ListBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/ListBoxPO.java new file mode 100644 index 00000000000..c51e0180f85 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/ListBoxPO.java @@ -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; + } +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/SuggestBoxPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/SuggestBoxPO.java new file mode 100644 index 00000000000..c10b2cce4ca --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/gwt/SuggestBoxPO.java @@ -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; + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardPage.java index de779b884a4..3d0ce8d1d63 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardPage.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardPage.java @@ -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) { diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardSettingsPanelPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardSettingsPanelPO.java index b1832f3b780..bec8f5f768a 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardSettingsPanelPO.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/leaderboard/LeaderboardSettingsPanelPO.java @@ -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; diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/regattaoverview/RegattaOverviewPage.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/regattaoverview/RegattaOverviewPage.java new file mode 100644 index 00000000000..5a0c4827de1 --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/regattaoverview/RegattaOverviewPage.java @@ -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; + +/** + *

The page object representing the leaderboard.

+ * + * @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")); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/regattaoverview/RegattaOverviewSettingsDialogPO.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/regattaoverview/RegattaOverviewSettingsDialogPO.java new file mode 100644 index 00000000000..efd38d3b4dc --- /dev/null +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/pages/regattaoverview/RegattaOverviewSettingsDialogPO.java @@ -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 courseAreaCheckBoxes; + private final List 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 getSelectedCheckBoxLabels(List checkBoxList) { + List selectedCheckBoxLabes = new ArrayList<>(); + for (WebElement element : checkBoxList) { + CheckBoxPO checkbox = CheckBoxPO.create(driver, element); + if (checkbox.isSelected()) { + selectedCheckBoxLabes.add(checkbox.getLabel()); + } + } + return selectedCheckBoxLabes; + } + + private List getAvailableCheckBoxLabels(List checkBoxList) { + List selectedCheckBoxLabes = new ArrayList<>(); + for (WebElement element : checkBoxList) { + CheckBoxPO checkbox = CheckBoxPO.create(driver, element); + selectedCheckBoxLabes.add(checkbox.getLabel()); + } + return selectedCheckBoxLabes; + } + + private void selectCheckBoxLabelsAndDeselectOther(List checkBoxList, List 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 getSelectedCourseAreas() { + return getSelectedCheckBoxLabels(courseAreaCheckBoxes); + } + + public List getSelectedRegattaNames() { + return getSelectedCheckBoxLabels(regattaNamesCheckBoxes); + } + + public List getAvailableCourseAreas() { + return getAvailableCheckBoxLabels(courseAreaCheckBoxes); + } + + public List getAvailableRegattaNames() { + return getAvailableCheckBoxLabels(regattaNamesCheckBoxes); + } + + public void selectCourseAreasAndDeselectOther(List courseAreaLabelsToSelect) { + selectCheckBoxLabelsAndDeselectOther(courseAreaCheckBoxes, courseAreaLabelsToSelect); + } + + public void selectRegattaNamesAndDeselectOther(List courseAreaLabelsToSelect) { + selectCheckBoxLabelsAndDeselectOther(regattaNamesCheckBoxes, courseAreaLabelsToSelect); + } + +} diff --git a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/raceboard/SettingsTest.java b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/raceboard/SettingsTest.java index c11aef57102..c65cbeeb331 100644 --- a/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/raceboard/SettingsTest.java +++ b/java/com.sap.sailing.selenium.test/src/com/sap/sailing/selenium/test/raceboard/SettingsTest.java @@ -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 initiallySelectedCourseAreas = regattaOverviewSettingsDialog.getSelectedCourseAreas(); + List 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 newSelectedCourseAreas = initiallySelectedCourseAreas.subList(1, 2); + List 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 initiallySelectedCourseAreasForAudi = regattaOverviewSettingsDialog.getSelectedCourseAreas(); + List 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 newSelectedCourseAreasForAudi = initiallySelectedCourseAreasForAudi.subList(0, 1); + List 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()); + + } + }