Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update RenameProjectTest selenium test #7291

Merged
merged 4 commits into from
Nov 10, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use "new-" prefix here in new project name to have more information on screenshot in case of failure.

private static final String PROJECT_NAME = generate("project", 5);
private static final String NEW_PROJECT_NAME = generate("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();
}
}