mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-25 05:23:51 +00:00
Basic Selenium for Raceboard Settings Test
This commit is contained in:
1 parent
d8df970587
commit
de5be339d4
10 files changed
+251
-3
No files matched your search
+2
@@ -250,6 +250,7 @@ public class AdminConsoleEntryPoint extends AbstractSailingEntryPoint implements
|
||||
/* ADVANCED */
|
||||
|
||||
final HorizontalTabLayoutPanel advancedTabPanel = panel.addVerticalTab(getStringMessages().advanced(), "AdvancedPanel");
|
||||
advancedTabPanel.ensureDebugId("AdvancedTab");
|
||||
final ReplicationPanel replicationPanel = new ReplicationPanel(sailingService, this, getStringMessages());
|
||||
panel.addToTabPanel(advancedTabPanel, new DefaultRefreshableAdminConsolePanel<ReplicationPanel>(replicationPanel) {
|
||||
@Override
|
||||
@@ -260,6 +261,7 @@ public class AdminConsoleEntryPoint extends AbstractSailingEntryPoint implements
|
||||
|
||||
final MasterDataImportPanel masterDataImportPanel = new MasterDataImportPanel(getStringMessages(), sailingService,
|
||||
this, eventManagementPanel, this, this);
|
||||
masterDataImportPanel.ensureDebugId("MasterDataImport");
|
||||
panel.addToTabPanel(advancedTabPanel, new DefaultRefreshableAdminConsolePanel<MasterDataImportPanel>(masterDataImportPanel),
|
||||
getStringMessages().masterDataImportPanel(), Permission.MANAGE_MASTERDATA_IMPORT);
|
||||
|
||||
|
||||
+4
-1
@@ -724,11 +724,14 @@ public class RaceMap extends AbstractCompositeComponent<RaceMapSettings> impleme
|
||||
final Component<RaceMapSettings> component = this;
|
||||
Button settingsButton = new Button();
|
||||
settingsButton.setStyleName("gwt-MapSettingsButton");
|
||||
settingsButton.ensureDebugId("raceMapSettingsButton");
|
||||
settingsButton.setTitle(stringMessages.settings());
|
||||
settingsButton.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
new SettingsDialog<RaceMapSettings>(component, stringMessages).show();
|
||||
SettingsDialog<RaceMapSettings> dialog = new SettingsDialog<RaceMapSettings>(component, stringMessages);
|
||||
dialog.ensureDebugId("raceMapSettings");
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
map.setControls(ControlPosition.RIGHT_TOP, settingsButton);
|
||||
|
||||
+2
-1
@@ -67,12 +67,13 @@ public class RaceMapSettingsDialogComponent implements SettingsDialogComponent<R
|
||||
@Override
|
||||
public Widget getAdditionalWidget(DataEntryDialog<?> dialog) {
|
||||
VerticalPanel vp = new VerticalPanel();
|
||||
|
||||
Label generalLabel = dialog.createHeadlineLabel(stringMessages.general());
|
||||
vp.add(generalLabel);
|
||||
|
||||
windUpCheckbox = dialog.createCheckbox(stringMessages.windUp());
|
||||
windUpCheckbox.setValue(initialSettings.isWindUp());
|
||||
windUpCheckbox.getElement().setAttribute("selenium_checkbox", String.valueOf(initialSettings.isWindUp()));
|
||||
windUpCheckbox.ensureDebugId("raceMapSettingsWindChart");
|
||||
vp.add(windUpCheckbox);
|
||||
|
||||
showWindStreamletOverlayCheckbox = dialog.createCheckbox(stringMessages.showWindStreamletOverlay());
|
||||
|
||||
+6
@@ -75,6 +75,7 @@ public class MasterDataImportPanel extends VerticalPanel {
|
||||
hostBox.setWidth("300px");
|
||||
serverAddressPanel.add(hostBox);
|
||||
fetchIdsButton = new Button(stringMessages.importFetchRemoteLgs());
|
||||
fetchIdsButton.ensureDebugId("fetchLeaderboardGroupList");
|
||||
serverAddressPanel.add(fetchIdsButton);
|
||||
this.add(serverAddressPanel);
|
||||
|
||||
@@ -122,6 +123,7 @@ public class MasterDataImportPanel extends VerticalPanel {
|
||||
final Label overallName = new Label(stringMessages.overallProgress() + ":");
|
||||
this.add(overallName);
|
||||
final ProgressBar overallProgressBar = new ProgressBar(Style.ANIMATED);
|
||||
overallProgressBar.ensureDebugId("overallProgressBar");
|
||||
this.add(overallProgressBar);
|
||||
final Label subProgressName = new Label();
|
||||
this.add(subProgressName);
|
||||
@@ -326,12 +328,14 @@ public class MasterDataImportPanel extends VerticalPanel {
|
||||
contentPanel.add(filterPanel);
|
||||
|
||||
leaderboardgroupListBox = new ListBox();
|
||||
leaderboardgroupListBox.ensureDebugId("LeaderBoardGroupListBox");
|
||||
leaderboardgroupListBox.setMultipleSelect(true);
|
||||
|
||||
addSelectionChangedListener();
|
||||
contentPanel.add(leaderboardgroupListBox);
|
||||
|
||||
overrideSwitch = new CheckBox(stringMessages.importOverrideSwitchLabel());
|
||||
overrideSwitch.ensureDebugId("overrideExisting");
|
||||
overrideSwitch.setValue(false);
|
||||
contentPanel.add(overrideSwitch);
|
||||
|
||||
@@ -343,6 +347,7 @@ public class MasterDataImportPanel extends VerticalPanel {
|
||||
exportWindSwitch = new CheckBox(stringMessages.importWind());
|
||||
exportWindSwitch.setTitle(stringMessages.importWindTooltip());
|
||||
exportWindSwitch.setValue(true);
|
||||
exportWindSwitch.ensureDebugId("wind");
|
||||
contentPanel.add(exportWindSwitch);
|
||||
|
||||
exportDeviceConfigsSwitch = new CheckBox(stringMessages.importDeviceConfigurations());
|
||||
@@ -351,6 +356,7 @@ public class MasterDataImportPanel extends VerticalPanel {
|
||||
contentPanel.add(exportDeviceConfigsSwitch);
|
||||
|
||||
importLeaderboardGroupsButton = new Button(stringMessages.importSelectedLeaderboardGroups());
|
||||
importLeaderboardGroupsButton.ensureDebugId("import");
|
||||
importLeaderboardGroupsButton.setEnabled(false);
|
||||
contentPanel.add(importLeaderboardGroupsButton);
|
||||
}
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@ import com.google.gwt.user.client.ui.DockLayoutPanel;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.MenuBar;
|
||||
import com.google.gwt.user.client.ui.MenuItem;
|
||||
import com.google.gwt.user.client.ui.RequiresResize;
|
||||
import com.google.gwt.user.client.ui.UIObject;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
@@ -438,7 +439,7 @@ public class RaceBoardPanel extends AbstractPerspectiveComposite<RaceBoardPerspe
|
||||
@SuppressWarnings("unused")
|
||||
private <SettingsType extends AbstractSettings> void addSettingsMenuItem(MenuBar settingsMenu, final Component<SettingsType> component) {
|
||||
if (component.hasSettings()) {
|
||||
settingsMenu.addItem(component.getLocalizedShortName(), new Command() {
|
||||
MenuItem settingsMenuItem = settingsMenu.addItem(component.getLocalizedShortName(), new Command() {
|
||||
public void execute() {
|
||||
new SettingsDialog<SettingsType>(component, stringMessages).show();
|
||||
}
|
||||
|
||||
+12
@@ -10,6 +10,7 @@ import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
import com.sap.sailing.selenium.pages.HostPage;
|
||||
import com.sap.sailing.selenium.pages.HostPageWithAuthentication;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.advanced.MasterDataImportPO;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.connectors.SmartphoneTrackingEventManagementPanelPO;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.event.EventConfigurationPanelPO;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.leaderboard.LeaderboardConfigurationPanelPO;
|
||||
@@ -62,6 +63,11 @@ public class AdminConsolePage extends HostPageWithAuthentication {
|
||||
|
||||
private static final String SMARTPHONETRACKINGPANEL_PANEL_TAB_LABEL = "Smartphone Tracking"; //$NON-NLS-1$
|
||||
private static final String SMARTPHONETRACKINGPANEL_PANEL_TAB_IDENTIFIER = "SmartphoneTrackingPanel"; //$NON-NLS-1$
|
||||
|
||||
private static final String ADVANCED_PARENT_LABEL = "Advanced";
|
||||
private static final String ADVANCED_TAB_PARENT_IDENTIFIER = "AdvancedTab";
|
||||
private static final String ADVANCED_MASTERDATA_LABEL = "Master Data Import";
|
||||
private static final String ADVANCED_MASTERDATA_IDENTIFIER = "MasterDataImport";
|
||||
/**
|
||||
* <p>Goes to the administration console and returns the representing page object.</p>
|
||||
*
|
||||
@@ -129,6 +135,12 @@ public class AdminConsolePage extends HostPageWithAuthentication {
|
||||
COMPETITOR_PANEL_TAB_IDENTIFIER, false));
|
||||
}
|
||||
|
||||
public MasterDataImportPO goToMasterDateImport() {
|
||||
goToTab(ADVANCED_PARENT_LABEL, ADVANCED_TAB_PARENT_IDENTIFIER, true);
|
||||
return new MasterDataImportPO(this.driver,
|
||||
goToTab(ADVANCED_MASTERDATA_LABEL, ADVANCED_MASTERDATA_IDENTIFIER, false));
|
||||
}
|
||||
|
||||
public SmartphoneTrackingEventManagementPanelPO goToSmartphoneTrackingPanel() {
|
||||
goToTab(TRACTRAC_EVENTS_TAB_PARENT_LABEL, TRACTRAC_EVENTS_TAB_PARENT_IDENTIFIER, true);
|
||||
return new SmartphoneTrackingEventManagementPanelPO(this.driver, goToTab(SMARTPHONETRACKINGPANEL_PANEL_TAB_LABEL,
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.sap.sailing.selenium.pages.adminconsole.advanced;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
import org.openqa.selenium.Alert;
|
||||
import org.openqa.selenium.NoAlertPresentException;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.openqa.selenium.support.ui.Select;
|
||||
|
||||
import com.sap.sailing.selenium.core.BySeleniumId;
|
||||
import com.sap.sailing.selenium.core.FindBy;
|
||||
import com.sap.sailing.selenium.pages.PageArea;
|
||||
|
||||
public class MasterDataImportPO extends PageArea {
|
||||
public MasterDataImportPO(WebDriver driver, WebElement element) {
|
||||
super(driver, element);
|
||||
}
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "fetchLeaderboardGroupList")
|
||||
private WebElement fetchbutton;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "overrideExisting")
|
||||
private WebElement override;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "wind")
|
||||
private WebElement wind;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "import")
|
||||
private WebElement importBtn;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "LeaderBoardGroupListBox")
|
||||
private WebElement leaderBoardGroupListBox;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "overallProgressBar")
|
||||
private WebElement overallProgressBar;
|
||||
|
||||
public void fetchLeaderBoards() {
|
||||
fetchbutton.click();
|
||||
waitUntil(new BooleanSupplier() {
|
||||
|
||||
@Override
|
||||
public boolean getAsBoolean() {
|
||||
// some result is loaded
|
||||
return leaderBoardGroupListBox.getSize().getHeight() > 100;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void importData(String eventName, boolean override, boolean wind) throws InterruptedException {
|
||||
if (override) {
|
||||
this.override.click();
|
||||
}
|
||||
if (!wind) {
|
||||
this.wind.click();
|
||||
}
|
||||
new Select(leaderBoardGroupListBox).selectByValue(eventName);
|
||||
importBtn.click();
|
||||
waitForAlertAndDispose(driver);
|
||||
}
|
||||
|
||||
void waitForAlertAndDispose(WebDriver driver) throws InterruptedException {
|
||||
while (true) {
|
||||
try {
|
||||
Alert alert = driver.switchTo().alert();
|
||||
alert.dismiss();
|
||||
break;
|
||||
} catch (NoAlertPresentException e) {
|
||||
Thread.sleep(1000);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package com.sap.sailing.selenium.pages.raceboard;
|
||||
|
||||
import org.openqa.selenium.Alert;
|
||||
import org.openqa.selenium.NoAlertPresentException;
|
||||
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;
|
||||
|
||||
public class MapSettingsPO extends PageArea {
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "raceMapSettingsWindChart")
|
||||
private WebElement raceMapSettingsWindChart;
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "SaveButton")
|
||||
private WebElement saveButton;
|
||||
|
||||
public MapSettingsPO(WebDriver driver, WebElement element) {
|
||||
super(driver, element);
|
||||
}
|
||||
|
||||
|
||||
public void setWindChart(boolean b) {
|
||||
if (isWindChartSelected() != b) {
|
||||
raceMapSettingsWindChart.click();
|
||||
}
|
||||
}
|
||||
|
||||
public void makeDefault() throws InterruptedException {
|
||||
saveButton.click();
|
||||
waitForAlertAndDispose(driver);
|
||||
}
|
||||
|
||||
void waitForAlertAndDispose(WebDriver driver) throws InterruptedException {
|
||||
while (true) {
|
||||
try {
|
||||
Alert alert = driver.switchTo().alert();
|
||||
alert.dismiss();
|
||||
break;
|
||||
} catch (NoAlertPresentException e) {
|
||||
Thread.sleep(1000);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isWindChartSelected() {
|
||||
String checked = raceMapSettingsWindChart.getAttribute("selenium_checkbox");
|
||||
return String.valueOf(Boolean.TRUE).equals(checked);
|
||||
}
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package com.sap.sailing.selenium.pages.raceboard;
|
||||
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
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.HostPageWithAuthentication;
|
||||
import com.sap.sailing.selenium.pages.PageObject;
|
||||
|
||||
/**
|
||||
* {@link PageObject} representing the SAP Sailing home page.
|
||||
*/
|
||||
public class RaceBoardPage extends HostPageWithAuthentication {
|
||||
|
||||
@FindBy(how = BySeleniumId.class, using = "raceMapSettingsButton")
|
||||
private WebElement raceMapSettingsButton;
|
||||
|
||||
/**
|
||||
* Navigates to the given home URL and provides the corresponding {@link PageObject}.
|
||||
*
|
||||
* @param driver the {@link WebDriver} to use
|
||||
* @param url the desired destination URL
|
||||
* @return the {@link PageObject} for the home page
|
||||
*/
|
||||
public static RaceBoardPage goToRaceboardUrl(WebDriver driver, String url) {
|
||||
// workaround for hostpage removing query from url, required for evenntid in this case
|
||||
driver.get(url);
|
||||
return new RaceBoardPage(driver);
|
||||
}
|
||||
|
||||
private RaceBoardPage(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
public MapSettingsPO openMapSettings() {
|
||||
raceMapSettingsButton.click();
|
||||
waitUntil(new BooleanSupplier() {
|
||||
|
||||
@Override
|
||||
public boolean getAsBoolean() {
|
||||
return context.findElement(new BySeleniumId("raceMapSettings")) != null;
|
||||
}
|
||||
});
|
||||
return new MapSettingsPO(driver, context.findElement(new BySeleniumId("raceMapSettings")));
|
||||
}
|
||||
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package com.sap.sailing.selenium.test.raceboard;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.selenium.pages.adminconsole.AdminConsolePage;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.advanced.MasterDataImportPO;
|
||||
import com.sap.sailing.selenium.pages.adminconsole.tractrac.TracTracEventManagementPanelPO;
|
||||
import com.sap.sailing.selenium.pages.raceboard.MapSettingsPO;
|
||||
import com.sap.sailing.selenium.pages.raceboard.RaceBoardPage;
|
||||
import com.sap.sailing.selenium.test.AbstractSeleniumTest;
|
||||
|
||||
public class SettingsTest extends AbstractSeleniumTest {
|
||||
private static final String TRAC_LINK = "http://skitrac.traclive.dk/events/event_20150204_ESSSingapo/jsonservice.php";
|
||||
private static final String EVENT_LINK = "gwt/RaceBoard.html?eventId=ed3cf78d-45b4-416c-99a1-3df88608f629&leaderboardName=ESS+2015+Singapore&leaderboardGroupName=Extreme+Sailing+Series+2015&raceName=Race+1&showMapControls=true&viewShowNavigationPanel=true®attaName=ESS+2015+Singapore&mode=PLAYER";
|
||||
private static final String EVENT_NAME = "Extreme Sailing Series 2015";
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
clearState(getContextRoot());
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createRaceAsAdminSetWindSettingToTrue() throws InterruptedException {
|
||||
AdminConsolePage adminpage = AdminConsolePage.goToPage(getWebDriver(), getContextRoot());
|
||||
MasterDataImportPO masterDataImportPO = adminpage.goToMasterDateImport();
|
||||
masterDataImportPO.fetchLeaderBoards();
|
||||
masterDataImportPO.importData(EVENT_NAME, true, false);
|
||||
TracTracEventManagementPanelPO tracking = adminpage.goToTracTracEvents();
|
||||
tracking.listTrackableRaces(TRAC_LINK);
|
||||
tracking.setReggataForTracking("ESS 2015 Singapore");
|
||||
tracking.startTrackingForRaces(tracking.getTrackableRaces());
|
||||
RaceBoardPage raceboard = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot()+EVENT_LINK);
|
||||
MapSettingsPO mapSettings = raceboard.openMapSettings();
|
||||
mapSettings.setWindChart(true);
|
||||
mapSettings.makeDefault();
|
||||
// reload
|
||||
RaceBoardPage raceboard2 = RaceBoardPage.goToRaceboardUrl(getWebDriver(), getContextRoot() + EVENT_LINK);
|
||||
MapSettingsPO mapSettings2 = raceboard2.openMapSettings();
|
||||
boolean stillSelected = mapSettings2.isWindChartSelected();
|
||||
Assert.assertTrue(stillSelected);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user