Skip to content

Commit

Permalink
Add information for clarifying reasons of failing tests from 'org.ecl…
Browse files Browse the repository at this point in the history
…ipse.che.selenium.factory' package (#8820)
  • Loading branch information
Maxim Musienko committed Feb 19, 2018
1 parent ed39ba6 commit e21ce7d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 11 deletions.
Expand Up @@ -11,7 +11,7 @@
package org.eclipse.che.selenium.core;

import static java.lang.String.format;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.APPLICATION_START_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOADER_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.utils.WaitUtils.sleepQuietly;

import com.google.inject.Inject;
Expand Down Expand Up @@ -316,7 +316,7 @@ public void switchToNoneCurrentWindow(String currentWindowHandler) {
}

public void switchFromDashboardIframeToIde() {
new WebDriverWait(this, APPLICATION_START_TIMEOUT_SEC)
new WebDriverWait(this, LOADER_TIMEOUT_SEC * 6)
.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.id("ide-application-iframe")));
}

Expand Down
Expand Up @@ -10,6 +10,7 @@
*/
package org.eclipse.che.selenium.core.factory;

import org.eclipse.che.api.core.model.workspace.WorkspaceStatus;
import org.eclipse.che.api.factory.shared.dto.FactoryDto;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestFactoryServiceClient;
Expand Down Expand Up @@ -50,15 +51,15 @@ public TestFactory(
}

/** Login to factory and open it by url. */
public void authenticateAndOpen() throws Exception {
public void authenticateAndOpen() {
seleniumWebDriver.get(dashboardUrl.get().toString());
entrance.login(owner);
seleniumWebDriver.get(factoryUrl);
seleniumWebDriver.switchFromDashboardIframeToIde();
}

/** Opens factory url. */
public void open(WebDriver driver) throws Exception {
public void open(WebDriver driver) {
driver.get(factoryUrl);
}

Expand All @@ -68,7 +69,7 @@ public void delete() throws Exception {
deleteFactory();
}

private void deleteFactory() throws Exception {
private void deleteFactory() {
if (isNamedFactory()) {
testFactoryServiceClient.deleteFactory(factoryDto.getName());
}
Expand All @@ -77,4 +78,10 @@ private void deleteFactory() throws Exception {
private boolean isNamedFactory() {
return factoryDto.getName() != null;
}

public WorkspaceStatus getWorkspaceStatusAssociatedWithFactory() throws Exception {
return workspaceServiceClient
.getByName(factoryDto.getWorkspace().getName(), owner.getName())
.getStatus();
}
}
Expand Up @@ -22,6 +22,7 @@
import org.eclipse.che.selenium.core.provider.TestIdeUrlProvider;
import org.eclipse.che.selenium.core.utils.WaitUtils;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.SeleniumWebDriverHelper;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -63,6 +64,7 @@ public enum AddAction {
}
}

private final SeleniumWebDriverHelper seleniumWebDriverHelper;
private final SeleniumWebDriver seleniumWebDriver;
private final Loader loader;
private final ActionsFactory actionsFactory;
Expand All @@ -71,11 +73,13 @@ public enum AddAction {

@Inject
public DashboardFactory(
SeleniumWebDriverHelper seleniumWebDriverHelper,
SeleniumWebDriver seleniumWebDriver,
Loader loader,
ActionsFactory actionsFactory,
Dashboard dashboard,
TestIdeUrlProvider ideUrlProvider) {
this.seleniumWebDriverHelper = seleniumWebDriverHelper;
this.seleniumWebDriver = seleniumWebDriver;
this.loader = loader;
this.actionsFactory = actionsFactory;
Expand Down Expand Up @@ -192,8 +196,11 @@ public void selectWorkspaceForCreation(String wsNama) {

/** wait any data in the json editor */
public void waitJsonFactoryIsNotEmpty() {
WebElement jsonArea =
seleniumWebDriverHelper.waitPresence(By.cssSelector(Locators.JSON_FACTORY_EDITOR_AREA_CSS));
seleniumWebDriverHelper.moveCursorTo(jsonArea);
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until((WebDriver driver) -> jsonAreaEditor.getText().length() > LOAD_PAGE_TIMEOUT_SEC);
.until((WebDriver driver) -> jsonArea.getText().length() > LOAD_PAGE_TIMEOUT_SEC);
}

/** click on 'Create factory button' */
Expand Down
Expand Up @@ -50,7 +50,7 @@ public void tearDown() throws Exception {
}

@Test
public void checkFactoryAcceptingWithPerClickPolicy() throws Exception {
public void checkFactoryAcceptingWithPerClickPolicy() {
// accept factory
dashboard.open();
testFactory.open(seleniumWebDriver);
Expand Down
Expand Up @@ -12,16 +12,21 @@

import static org.eclipse.che.dto.server.DtoFactory.newDto;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;

import com.google.inject.Inject;
import org.eclipse.che.api.factory.shared.dto.PoliciesDto;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.factory.FactoryTemplate;
import org.eclipse.che.selenium.core.factory.TestFactory;
import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
import org.eclipse.che.selenium.core.utils.BrowserLogsUtil;
import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.openqa.selenium.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
Expand All @@ -33,8 +38,9 @@ public class CheckFactoryWithPerUserCreatePolicyTest {
@Inject private NotificationsPopupPanel notificationsPopupPanel;
@Inject private TestFactoryInitializer testFactoryInitializer;
@Inject private SeleniumWebDriver seleniumWebDriver;

@Inject private BrowserLogsUtil browserLogsUtil;
private TestFactory testFactory;
private final Logger LOG = LoggerFactory.getLogger(CheckFactoryWithPerUserCreatePolicyTest.class);

@BeforeClass
public void setUp() throws Exception {
Expand Down Expand Up @@ -65,7 +71,17 @@ public void checkFactoryAcceptingWithPerUserPolicy() throws Exception {
// accept factory
testFactory.open(seleniumWebDriver);

seleniumWebDriver.switchFromDashboardIframeToIde();
try {
seleniumWebDriver.switchFromDashboardIframeToIde();
} catch (TimeoutException ex) {
browserLogsUtil.storeLogs();
LOG.info(
String.format(
CheckFactoryWithPerUserCreatePolicyTest.class.getSimpleName(),
testFactory.getWorkspaceStatusAssociatedWithFactory(),
"Current workspace status for %s is: %s"));
fail("Known issue https://github.com/eclipse/che/issues/8799");
}
projectExplorer.waitProjectExplorer();

// factory has been accepted in the same workspace
Expand Down
Expand Up @@ -64,7 +64,7 @@ public void tearDown() throws Exception {
}

@Test
public void checkFactoryAcceptingWithSincePolicy() throws Exception {
public void checkFactoryAcceptingWithSincePolicy() {
// check factory now, make sure its restricted
dashboard.open();
testFactory.open(seleniumWebDriver);
Expand Down
Expand Up @@ -63,7 +63,7 @@ public void tearDown() throws Exception {
}

@Test
public void checkFactoryAcceptingWithUntilPolicy() throws Exception {
public void checkFactoryAcceptingWithUntilPolicy() {
dashboard.open();
testFactory.open(seleniumWebDriver);
seleniumWebDriver.switchFromDashboardIframeToIde();
Expand Down

0 comments on commit e21ce7d

Please sign in to comment.