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

Extend NavigateToFile selenium test #6889

Merged
merged 7 commits into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -10,13 +10,15 @@
*/
package org.eclipse.che.selenium.pageobject;

import static java.lang.String.format;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC;

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.eclipse.che.selenium.core.utils.WaitUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
Expand Down Expand Up @@ -99,6 +101,7 @@ public void typeSymbolInFileNameField(String symbol) {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(ExpectedConditions.visibilityOf(fileNameInput));
fileNameInput.clear();
WaitUtils.sleepQuietly(1); // timeout for waiting that input field is cleared
fileNameInput.sendKeys(symbol);
}

Expand All @@ -119,6 +122,10 @@ public void waitFileNamePopUp() {
.until(ExpectedConditions.visibilityOf(suggestionPanel));
}

public Boolean isFilenameSuggested(final String nameFragment) {
return suggestionPanel.getText().contains(nameFragment);
}

/**
* wait expected text in the dropdawn list of the widget
*
Expand All @@ -142,7 +149,7 @@ public void selectFileByFullName(String pathName) {
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
ExpectedConditions.visibilityOfElementLocated(
By.xpath(String.format(Locators.FILE_NAME_LIST_SELECT_WITH_PATH, pathName))))
By.xpath(format(Locators.FILE_NAME_LIST_SELECT_WITH_PATH, pathName))))
.click();
actionsFactory.createAction(seleniumWebDriver).doubleClick().perform();
}
Expand All @@ -156,7 +163,7 @@ public void selectFileByName(String nameOfFile) {
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
ExpectedConditions.visibilityOfElementLocated(
By.xpath(String.format(Locators.FILE_NAME_LIST_SELECT, nameOfFile))))
By.xpath(format(Locators.FILE_NAME_LIST_SELECT, nameOfFile))))
.click();
actionsFactory.createAction(seleniumWebDriver).doubleClick().perform();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@
*/
package org.eclipse.che.selenium.miscellaneous;

import static org.testng.AssertJUnit.assertFalse;

import com.google.inject.Inject;
import java.net.URL;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.constant.TestGitConstants;
import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants;
import org.eclipse.che.selenium.core.project.ProjectTemplates;
import org.eclipse.che.selenium.core.utils.WaitUtils;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.AskDialog;
import org.eclipse.che.selenium.pageobject.CodenvyEditor;
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.NavigateToFile;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.git.Git;
import org.eclipse.che.selenium.pageobject.machineperspective.MachineTerminal;
import org.openqa.selenium.Keys;
import org.testng.annotations.BeforeClass;
Expand Down Expand Up @@ -76,8 +80,9 @@ public class NavigateToFileTest {
@Inject private CodenvyEditor editor;
@Inject private NavigateToFile navigateToFile;
@Inject private Menu menu;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestProjectServiceClient testProjectServiceClient;
@Inject private Git git;
@Inject private AskDialog askDialog;

@BeforeClass
public void setUp() throws Exception {
Expand All @@ -97,7 +102,7 @@ public void setUp() throws Exception {
}

@Test
public void checkFunctionNavigateFile() {
public void checkNavigateToFileFunction() {
// Open the project one and check function 'Navigate To File'
projectExplorer.waitProjectExplorer();
projectExplorer.waitItem(PROJECT_NAME);
Expand Down Expand Up @@ -139,10 +144,19 @@ public void checkFunctionNavigateFile() {
selectFileFromNavigateLaunchByKeyboard("R", FILE_README + PATH_2_TO_README_FILE);
editor.waitTabIsPresent("README.md");
editor.waitActiveEditor();
editor.closeAllTabsByContextMenu();

// Check that form is closed by pressing ESC button
menu.runCommand(
TestMenuCommandsConstants.Assistant.ASSISTANT,
TestMenuCommandsConstants.Assistant.NAVIGATE_TO_FILE);
navigateToFile.waitFormToOpen();
navigateToFile.closeNavigateToFileForm();
navigateToFile.waitFormToClose();
}

@Test
public void checkNavigateFileFunctionWithJustCreatedFiles() throws Exception {
public void checkNavigateToFileFunctionWithJustCreatedFiles() throws Exception {
String content = "NavigateToFileTest";

projectExplorer.waitProjectExplorer();
Expand All @@ -162,6 +176,31 @@ public void checkNavigateFileFunctionWithJustCreatedFiles() throws Exception {
editor.closeFileByNameWithSaving(FILE_CREATED_FROM_CONSOLE);
}

@Test
public void checkNavigateToFileFunctionWithFilesFromHiddenFolders() {
projectExplorer.waitProjectExplorer();
projectExplorer.waitItem(PROJECT_NAME);
projectExplorer.selectItem(PROJECT_NAME);
menu.runCommand(
TestMenuCommandsConstants.Git.GIT, TestMenuCommandsConstants.Git.INITIALIZE_REPOSITORY);
askDialog.acceptDialogWithText(
"Do you want to initialize the local repository " + PROJECT_NAME + "?");
loader.waitOnClosed();
git.waitGitStatusBarWithMess(TestGitConstants.GIT_INITIALIZED_SUCCESS);

// check that HEAD file from .git folder is not appear in list of found files
menu.runCommand(
TestMenuCommandsConstants.Assistant.ASSISTANT,
TestMenuCommandsConstants.Assistant.NAVIGATE_TO_FILE);
navigateToFile.waitFormToOpen();
navigateToFile.typeSymbolInFileNameField("H");
loader.waitOnClosed();
navigateToFile.waitFileNamePopUp();
assertFalse(navigateToFile.isFilenameSuggested("HEAD (/NavigateFile/.git)"));
navigateToFile.closeNavigateToFileForm();
navigateToFile.waitFormToClose();
}

private void selectFileFromNavigate(String symbol, String pathName, List<String> files) {
loader.waitOnClosed();
menu.runCommand(
Expand Down