Skip to content

Commit

Permalink
[Selenium] Stabilize factory java selenium tests (eclipse-che#18722)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkorikSergey authored Jan 4, 2021
1 parent 537c8a9 commit 9e3da96
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 72 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/tests/e2e/OpenshiftConnector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ suite('Openshift connector user story', async () => {
await quickOpenContainer.typeAndSelectSuggestion(OpenshiftContextMenuItems.Push, 'OpenShift: Push Component');
await quickOpenContainer.clickOnContainerItem('node-js-app');
await quickOpenContainer.clickOnContainerItem('component-node-js (s2i)');
await terminal.selectTabByPrefixAndWaitText('OpenShift: Push', 'Changes successfully pushed to component', 120_000);
await terminal.selectTabByPrefixAndWaitText('OpenShift: Push', 'Changes successfully pushed to component', 240000);
});

suite('Cleanup', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.UPDATING_PROJECT_TIMEOUT_SEC;

import com.google.inject.Inject;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.factory.TestFactory;
import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
Expand All @@ -39,8 +36,9 @@ public class DirectUrlFactoryWithKeepDirectoryTest {
private static final Logger LOG =
LoggerFactory.getLogger(DirectUrlFactoryWithKeepDirectoryTest.class);

private final String REPOSITORY_URL = "https://github.com/che-samples/console-java-simple";

@Inject private TestFactoryInitializer testFactoryInitializer;
@Inject private TestGitHubRepository testRepo;
@Inject private TheiaIde theiaIde;
@Inject private TheiaProjectTree theiaProjectTree;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
Expand All @@ -52,12 +50,8 @@ public class DirectUrlFactoryWithKeepDirectoryTest {

@BeforeClass
public void setUp() throws Exception {
// preconditions - add the project to the test repository
Path entryPath = Paths.get(getClass().getResource("/projects/java-multimodule").getPath());
testRepo.addContent(entryPath);
String repositoryUrl = testRepo.getHtmlUrl();
testFactoryWithKeepDir = testFactoryInitializer.fromUrl(REPOSITORY_URL + "/tree/master/src");

testFactoryWithKeepDir = testFactoryInitializer.fromUrl(repositoryUrl + "/tree/master/my-lib");
dashboard.open();
}

Expand All @@ -72,7 +66,7 @@ public void tearDown() throws Exception {

@Test
public void factoryWithDirectUrlWithKeepDirectory() {
String repositoryName = testRepo.getName();
String repositoryName = "console-java-simple";
testFactoryWithKeepDir.authenticateAndOpen();

theiaIde.switchToIdeFrame();
Expand All @@ -87,9 +81,8 @@ public void factoryWithDirectUrlWithKeepDirectory() {

theiaProjectTree.waitItem(repositoryName);
theiaProjectTree.expandItemWithIgnoreExceptions(repositoryName);
theiaProjectTree.waitItem(repositoryName + "/my-lib");

Assert.assertFalse(theiaProjectTree.isItemVisible(repositoryName + "/my-webapp"));
Assert.assertFalse(theiaProjectTree.isItemVisible(repositoryName + "/pom.xml"));
}

private String getWorkspaceName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.UPDATING_PROJECT_TIMEOUT_SEC;

import com.google.inject.Inject;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.factory.TestFactory;
import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
Expand All @@ -40,9 +37,9 @@
public class DirectUrlFactoryWithRootFolderTest {
private static final Logger LOG =
LoggerFactory.getLogger(DirectUrlFactoryWithRootFolderTest.class);
private final String REPOSITORY_URL = "https://github.com/che-samples/console-java-simple";

@Inject private TestFactoryInitializer testFactoryInitializer;
@Inject private TestGitHubRepository testRepo;
@Inject private TheiaIde theiaIde;
@Inject private TheiaProjectTree theiaProjectTree;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
Expand All @@ -54,12 +51,8 @@ public class DirectUrlFactoryWithRootFolderTest {

@BeforeClass
public void setUp() throws Exception {
// preconditions - add the project to the test repository
Path entryPath = Paths.get(getClass().getResource("/projects/quickstart").getPath());
testRepo.addContent(entryPath);
String repositoryUrl = testRepo.getHtmlUrl();
testFactoryWithRootFolder = testFactoryInitializer.fromUrl(REPOSITORY_URL);

testFactoryWithRootFolder = testFactoryInitializer.fromUrl(repositoryUrl);
dashboard.open();
}

Expand All @@ -74,25 +67,9 @@ public void tearDown() throws Exception {

@Test
public void factoryWithDirectUrlWithRootFolder() {
String repositoryName = testRepo.getName();
String repositoryName = "console-java-simple";
List<String> expectedItemsAfterCloning =
Arrays.asList(
"CHANGELOG.md",
"Dockerfile",
"LICENSE.txt",
"README.md",
"favicon.ico",
"index.html",
"karma-test-shim.js",
"karma.conf.js",
"package.json",
"protractor.config.js",
"styles.css",
"systemjs.config.js",
"tsconfig.json",
"tslint.json",
"typings.json",
"wallaby.js");
Arrays.asList("pom.xml", "build.gradle", "LICENSE", "README.md");

testFactoryWithRootFolder.authenticateAndOpen();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,22 @@
*/
package org.eclipse.che.selenium.factory;

import static org.eclipse.che.selenium.core.CheSeleniumSuiteModule.AUXILIARY;
import static org.eclipse.che.selenium.core.TestGroup.GITHUB;
import static org.eclipse.che.selenium.core.TestGroup.OPENSHIFT;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.UPDATING_PROJECT_TIMEOUT_SEC;
import static org.testng.AssertJUnit.assertEquals;

import com.google.inject.Inject;
import com.google.inject.name.Named;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.factory.TestFactory;
import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.theia.TheiaIde;
import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree;
import org.openqa.selenium.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
Expand All @@ -44,11 +38,8 @@ public class DirectUrlFactoryWithSpecificBranchTest {
private static final Logger LOG =
LoggerFactory.getLogger(DirectUrlFactoryWithSpecificBranchTest.class);

private static final String SECOND_BRANCH_NAME = "contrib";

@Inject
@Named(AUXILIARY)
private TestGitHubRepository testAuxiliaryRepo;
private static final String SECOND_BRANCH_NAME = "java1.11";
private final String REPOSITORY_URL = "https://github.com/che-samples/console-java-simple";

@Inject private SeleniumWebDriver seleniumWebDriver;
@Inject private TestFactoryInitializer testFactoryInitializer;
Expand All @@ -62,16 +53,9 @@ public class DirectUrlFactoryWithSpecificBranchTest {

@BeforeClass
public void setUp() throws Exception {
// preconditions - add the project to the test repository
Path entryPath = Paths.get(getClass().getResource("/projects/java-multimodule").getPath());
testAuxiliaryRepo.addContent(entryPath);
String repositoryUrl = testAuxiliaryRepo.getHtmlUrl();

// create another branch in the test repo
testAuxiliaryRepo.createBranch(SECOND_BRANCH_NAME);

testFactoryWithSpecificBranch =
testFactoryInitializer.fromUrl(repositoryUrl + "/tree/" + SECOND_BRANCH_NAME);
testFactoryInitializer.fromUrl(REPOSITORY_URL + "/tree/" + SECOND_BRANCH_NAME);

dashboard.open();
}

Expand All @@ -86,9 +70,9 @@ public void deleteTestBranch() throws Exception {

@Test
public void factoryWithDirectUrlWithSpecificBranch() {
String repositoryName = testAuxiliaryRepo.getName();
String repositoryName = "console-java-simple";
List<String> expectedItemsAfterCloning =
Arrays.asList("my-lib", "my-webapp", "my-lib/src", "pom.xml");
Arrays.asList("pom.xml", "build.gradle", "LICENSE", "README.md");

testFactoryWithSpecificBranch.authenticateAndOpen();

Expand All @@ -103,20 +87,11 @@ public void factoryWithDirectUrlWithSpecificBranch() {
theiaIde.waitNotificationDisappearance(
"Che Workspace: Finished importing projects.", UPDATING_PROJECT_TIMEOUT_SEC);
theiaIde.waitAllNotificationsClosed();

theiaProjectTree.expandItemWithIgnoreExceptions(repositoryName);
theiaProjectTree.waitItem(repositoryName + "/pom.xml");
theiaProjectTree.expandItemWithIgnoreExceptions(repositoryName + "/my-lib");
theiaProjectTree.waitItem(repositoryName + "/my-lib/src");

expectedItemsAfterCloning.forEach(
name -> {
try {
theiaProjectTree.waitItem(repositoryName + "/" + name);
} catch (TimeoutException ex) {
seleniumWebDriver.navigate().refresh();
theiaProjectTree.waitItem(repositoryName + "/" + name);
}
theiaProjectTree.waitItem(repositoryName + "/" + name);
});

// check specific branch
Expand Down

0 comments on commit 9e3da96

Please sign in to comment.