[ Selenium ] Fix of unexpected fail of "CheckErrorsWarningsTabTest" selenium test (#11995)
parent
493f5d15f9
commit
7fdf4da70d
|
|
@ -86,6 +86,7 @@ import java.util.function.Supplier;
|
|||
import org.eclipse.che.commons.lang.Pair;
|
||||
import org.eclipse.che.selenium.core.SeleniumWebDriver;
|
||||
import org.eclipse.che.selenium.core.action.ActionsFactory;
|
||||
import org.eclipse.che.selenium.core.constant.TestTimeoutsConstants;
|
||||
import org.eclipse.che.selenium.core.utils.WaitUtils;
|
||||
import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper;
|
||||
import org.eclipse.che.selenium.core.webdriver.WebDriverWaitFactory;
|
||||
|
|
@ -1967,6 +1968,61 @@ public class CodenvyEditor {
|
|||
.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits {@code quantity} of specified {@code markerLocator} during {@code timeout}.
|
||||
*
|
||||
* @param markerLocator type of the expected markers
|
||||
* @param quantity expected quantity of the markers
|
||||
* @param timeout time in seconds for waiting expected quantity of the markers
|
||||
*/
|
||||
public void waitMarkersQuantity(MarkerLocator markerLocator, int quantity, int timeout) {
|
||||
seleniumWebDriverHelper.waitSuccessCondition(
|
||||
driver -> quantity == getMarkersQuantity(markerLocator), timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits {@code quantity} of specified {@code markerLocator}.
|
||||
*
|
||||
* @param markerLocator type of the expected markers
|
||||
* @param quantity expected quantity of the markers
|
||||
*/
|
||||
public void waitMarkersQuantity(MarkerLocator markerLocator, int quantity) {
|
||||
waitMarkersQuantity(markerLocator, quantity, LOAD_PAGE_TIMEOUT_SEC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits quantity of specified {@code markerLocator} between {@code lowerBound} and {@code
|
||||
* upperBound} values during {@code timeout}.
|
||||
*
|
||||
* @param markerLocator type of the expected markers
|
||||
* @param lowerBound the lower bound of the markers quantity (including specified value)
|
||||
* @param upperBound the upper bound of the markers quantity (including specified value)
|
||||
* @param timeout time in seconds for waiting expected quantity of the markers
|
||||
*/
|
||||
public void waitMarkersQuantityBetween(
|
||||
MarkerLocator markerLocator, int lowerBound, int upperBound, int timeout) {
|
||||
seleniumWebDriverHelper.waitSuccessCondition(
|
||||
driver -> {
|
||||
final int markersQuantity = getMarkersQuantity(markerLocator);
|
||||
|
||||
return lowerBound <= markersQuantity && upperBound >= markersQuantity;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits quantity of specified {@code markerLocator} between {@code lowerBound} and {@code
|
||||
* upperBound} values.
|
||||
*
|
||||
* @param markerLocator type of the expected markers
|
||||
* @param lowerBound the lower bound of the markers quantity
|
||||
* @param upperBound the upper bound of the markers quantity
|
||||
*/
|
||||
public void waitMarkersQuantityBetween(
|
||||
MarkerLocator markerLocator, int lowerBound, int upperBound) {
|
||||
waitMarkersQuantityBetween(
|
||||
markerLocator, lowerBound, upperBound, TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits until annotations with specified {@code markerLocator} visible
|
||||
*
|
||||
|
|
@ -2151,6 +2207,10 @@ public class CodenvyEditor {
|
|||
seleniumWebDriverHelper.waitSuccessCondition(driver -> isTabSelected(editorIndex, tabTitle));
|
||||
}
|
||||
|
||||
public void waitTabSelection(String tabTitle) {
|
||||
waitTabSelection(0, tabTitle);
|
||||
}
|
||||
|
||||
public void waitTabFocusing(int editorIndex, String tabTitle) {
|
||||
seleniumWebDriverHelper.waitSuccessCondition(driver -> isTabFocused(editorIndex, tabTitle));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import static org.eclipse.che.selenium.pageobject.CodenvyEditor.MarkerLocator.ER
|
|||
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.MarkerLocator.WARNING;
|
||||
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.MarkerLocator.WARNING_OVERVIEW;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import java.net.URL;
|
||||
|
|
@ -62,13 +61,29 @@ public class CheckErrorsWarningsTabTest {
|
|||
|
||||
@BeforeClass
|
||||
public void setUp() throws Exception {
|
||||
URL resource = getClass().getResource("/projects/prefs-spring-project");
|
||||
final URL resource = getClass().getResource("/projects/prefs-spring-project");
|
||||
final URL embedCodeFilePath = getClass().getResource("embed-code");
|
||||
final String embedCode = readFileToString(embedCodeFilePath);
|
||||
|
||||
// import project
|
||||
testProjectServiceClient.importProject(
|
||||
workspace.getId(),
|
||||
Paths.get(resource.toURI()),
|
||||
PROJECT_NAME,
|
||||
ProjectTemplates.MAVEN_SPRING);
|
||||
|
||||
// open workspace
|
||||
ide.open(workspace);
|
||||
projectExplorer.waitItem(PROJECT_NAME);
|
||||
notificationsPopupPanel.waitProgressPopupPanelClose();
|
||||
|
||||
// prepare file for testing
|
||||
testProjectServiceClient.updateFile(
|
||||
workspace.getId(), PATH_TO_CLASS_IN_SPRING_PACKAGE, embedCode);
|
||||
|
||||
// expand project explorer tree and wait LS init
|
||||
projectExplorer.quickExpandWithJavaScript();
|
||||
loader.waitOnClosed();
|
||||
consoles.waitJDTLSProjectResolveFinishedMessage(PROJECT_NAME);
|
||||
}
|
||||
|
||||
|
|
@ -76,53 +91,57 @@ public class CheckErrorsWarningsTabTest {
|
|||
public void errorsWarningTest() throws Exception {
|
||||
final String expectedTabTitle = "AppController";
|
||||
final URL errorsWarningFilePath = getClass().getResource("errors-warnings");
|
||||
final URL embedCodeFilePath = getClass().getResource("embed-code");
|
||||
final List<String> expectedErrorsWarningsList = readFile(errorsWarningFilePath);
|
||||
|
||||
List<String> expectedErrorsWarningsList = readFile(errorsWarningFilePath);
|
||||
String embedCode = readFileToString(embedCodeFilePath);
|
||||
projectExplorer.waitItem(PROJECT_NAME);
|
||||
notificationsPopupPanel.waitProgressPopupPanelClose();
|
||||
|
||||
testProjectServiceClient.updateFile(
|
||||
workspace.getId(), PATH_TO_CLASS_IN_SPRING_PACKAGE, embedCode);
|
||||
|
||||
projectExplorer.quickExpandWithJavaScript();
|
||||
loader.waitOnClosed();
|
||||
// open file
|
||||
projectExplorer.openItemByVisibleNameInExplorer(expectedTabTitle + ".java");
|
||||
editor.waitTabIsPresent(expectedTabTitle);
|
||||
editor.waitTabSelection(0, expectedTabTitle);
|
||||
editor.waitActive();
|
||||
|
||||
// check markers default settings
|
||||
menu.runCommand(TestMenuCommandsConstants.Profile.PROFILE_MENU, PREFERENCES);
|
||||
preferences.waitPreferencesForm();
|
||||
preferences.waitMenuInCollapsedDropdown(Preferences.DropDownJavaCompilerMenu.ERRORS_WARNINGS);
|
||||
preferences.selectDroppedMenuByName(Preferences.DropDownJavaCompilerMenu.ERRORS_WARNINGS);
|
||||
preferences.getItemsFromErrorWarningsWidget();
|
||||
assertEquals(preferences.getItemsFromErrorWarningsWidget(), expectedErrorsWarningsList);
|
||||
|
||||
preferences.close();
|
||||
consoles.closeProcessesArea();
|
||||
|
||||
// change and check markers settings for displaying warnings
|
||||
menu.runCommand(TestMenuCommandsConstants.Profile.PROFILE_MENU, PREFERENCES);
|
||||
changeAllSettingsInErrorsWarningsTab(Preferences.DropDownValueForErrorWaitingWidget.WARNING);
|
||||
editor.waitAnnotationsAreNotPresent(ERROR_OVERVIEW);
|
||||
assertTrue(editor.getMarkersQuantity(WARNING_OVERVIEW) >= 12);
|
||||
assertEquals(editor.getMarkersQuantity(WARNING), 22);
|
||||
waitWarningMarkersQuantity();
|
||||
|
||||
// change and check markers settings for displaying errors
|
||||
editor.waitAnnotationsAreNotPresent(ERROR_OVERVIEW);
|
||||
menu.runCommand(TestMenuCommandsConstants.Profile.PROFILE_MENU, PREFERENCES);
|
||||
changeAllSettingsInErrorsWarningsTab(Preferences.DropDownValueForErrorWaitingWidget.ERROR);
|
||||
assertEquals(editor.getMarkersQuantity(ERROR_OVERVIEW), 12);
|
||||
assertEquals(editor.getMarkersQuantity(ERROR), 22);
|
||||
editor.waitAnnotationsAreNotPresent(WARNING_OVERVIEW);
|
||||
assertTrue(editor.getMarkersQuantity(ERROR_OVERVIEW) >= 12);
|
||||
assertEquals(editor.getMarkersQuantity(ERROR), 22);
|
||||
waitErrorMarkersQuantity();
|
||||
|
||||
// change and check markers settings for ignoring all markers
|
||||
editor.waitAnnotationsAreNotPresent(WARNING_OVERVIEW);
|
||||
menu.runCommand(TestMenuCommandsConstants.Profile.PROFILE_MENU, PREFERENCES);
|
||||
changeAllSettingsInErrorsWarningsTab(Preferences.DropDownValueForErrorWaitingWidget.IGNORE);
|
||||
editor.waitAnnotationsAreNotPresent(ERROR_OVERVIEW);
|
||||
editor.waitAnnotationsAreNotPresent(WARNING_OVERVIEW);
|
||||
}
|
||||
|
||||
private void waitWarningMarkersQuantity() {
|
||||
// browser window resolution a bit different on local mode and on CI
|
||||
// according to this different count of markers are displayed
|
||||
editor.waitMarkersQuantityBetween(WARNING_OVERVIEW, 12, 13);
|
||||
editor.waitMarkersQuantityBetween(WARNING, 22, 24);
|
||||
}
|
||||
|
||||
private void waitErrorMarkersQuantity() {
|
||||
// browser window resolution a bit different on local mode and on CI
|
||||
// according to this different count of markers are displayed
|
||||
editor.waitMarkersQuantityBetween(ERROR_OVERVIEW, 12, 13);
|
||||
editor.waitMarkersQuantityBetween(ERROR, 22, 24);
|
||||
}
|
||||
|
||||
private void changeAllSettingsInErrorsWarningsTab(
|
||||
Preferences.DropDownValueForErrorWaitingWidget valueOfRadioButton) {
|
||||
preferences.waitPreferencesForm();
|
||||
|
|
|
|||
Loading…
Reference in New Issue