Skip to content

Commit

Permalink
Update RenameProjectTest selenium test (#7291)
Browse files Browse the repository at this point in the history
* added testing that the rename project dialog opened by menu and hot keys, check that after renaming folder type is project
  • Loading branch information
Sergey Skorik committed Nov 10, 2017
1 parent 703f8ed commit 70a24a9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.action.ActionsFactory;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
Expand Down Expand Up @@ -46,6 +48,8 @@ public class AskForValueDialog {
private static final String ENUM_ITEM =
"//*[@id='gwt-debug-newJavaSourceFileView-typeField' ]//option[@value='Enum']";

private final ActionsFactory actionsFactory;

public enum JavaFiles {
CLASS,
INTERFACE,
Expand Down Expand Up @@ -95,9 +99,11 @@ public enum JavaFiles {
private final Loader loader;

@Inject
public AskForValueDialog(SeleniumWebDriver seleniumWebDriver, Loader loader) {
public AskForValueDialog(
SeleniumWebDriver seleniumWebDriver, Loader loader, ActionsFactory actionsFactory) {
this.seleniumWebDriver = seleniumWebDriver;
this.loader = loader;
this.actionsFactory = actionsFactory;
PageFactory.initElements(seleniumWebDriver, this);
}

Expand Down Expand Up @@ -231,4 +237,9 @@ public boolean isWidgetNewJavaClassIsOpened() {
return false;
}
}

/** launch the 'Rename project' form by keyboard */
public void launchFindFormByKeyboard() {
actionsFactory.createAction(seleniumWebDriver).sendKeys(Keys.SHIFT, Keys.F6).perform();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,35 @@
*/
package org.eclipse.che.selenium.projectexplorer;

import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants.RENAME;
import static org.eclipse.che.selenium.pageobject.ProjectExplorer.FolderTypes.PROJECT_FOLDER;

import com.google.inject.Inject;
import java.net.URL;
import java.nio.file.Paths;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
import org.eclipse.che.selenium.core.constant.TestProjectExplorerContextMenuConstants;
import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Edit;
import org.eclipse.che.selenium.core.project.ProjectTemplates;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.AskForValueDialog;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.Menu;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

/** @author Andrey Chizhikov */
public class RenameProjectTest {
private static final String PROJECT_NAME = RenameProjectTest.class.getSimpleName();
private static final String NEW_PROJECT_NAME = "new-name-project";
private static final String PROJECT_NAME = generate("project", 5);
private static final String NEW_PROJECT_NAME = generate("new-project", 5);

@Inject private TestProjectServiceClient testProjectServiceClient;
@Inject private AskForValueDialog askForValueDialog;
@Inject private ProjectExplorer projectExplorer;
@Inject private TestWorkspace testWorkspace;
@Inject private Menu menu;
@Inject private Ide ide;
@Inject private ProjectExplorer projectExplorer;
@Inject private AskForValueDialog askForValueDialog;
@Inject private Loader loader;
@Inject private TestProjectServiceClient testProjectServiceClient;

@BeforeClass
public void setUp() throws Exception {
Expand All @@ -50,18 +54,35 @@ public void setUp() throws Exception {
@Test
public void renameProjectTest() {
projectExplorer.waitProjectExplorer();
loader.waitOnClosed();
projectExplorer.waitItem(PROJECT_NAME);

// Rename project from context menu
projectExplorer.selectItem(PROJECT_NAME);
projectExplorer.openContextMenuByPathSelectedItem(PROJECT_NAME);
projectExplorer.clickOnItemInContextMenu(TestProjectExplorerContextMenuConstants.RENAME);
projectExplorer.clickOnItemInContextMenu(RENAME);
askForValueDialog.waitFormToOpen();
askForValueDialog.clearInput();
askForValueDialog.typeAndWaitText(NEW_PROJECT_NAME);
askForValueDialog.clickOkBtn();
askForValueDialog.waitFormToClose();

// Wait that project renamed and folder has project type
projectExplorer.waitItem(NEW_PROJECT_NAME);
projectExplorer.waitItemIsDisappeared(PROJECT_NAME);
projectExplorer.waitFolderDefinedTypeOfFolderByPath(NEW_PROJECT_NAME, PROJECT_FOLDER);

// Test that the Rename project dialog is started from menu
projectExplorer.selectItem(NEW_PROJECT_NAME);
menu.runCommand(Edit.EDIT, Edit.RENAME);
askForValueDialog.waitFormToOpen();
askForValueDialog.clickCancelBtn();
askForValueDialog.waitFormToClose();

// Test that the Rename project dialog is started by SHIFT + F6 keys
projectExplorer.selectItem(NEW_PROJECT_NAME);
askForValueDialog.launchFindFormByKeyboard();
askForValueDialog.waitFormToOpen();
askForValueDialog.clickCancelBtn();
askForValueDialog.waitFormToClose();
}
}

0 comments on commit 70a24a9

Please sign in to comment.