diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NavigateToFile.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NavigateToFile.java index a1047d8c43e..4d7f75f63fb 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NavigateToFile.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/NavigateToFile.java @@ -10,6 +10,7 @@ */ 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; @@ -17,6 +18,7 @@ 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; @@ -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); } @@ -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 * @@ -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(); } @@ -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(); } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/NavigateToFileTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/NavigateToFileTest.java index 52a51f0df69..48044d8ff52 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/NavigateToFileTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/miscellaneous/NavigateToFileTest.java @@ -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; @@ -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 { @@ -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); @@ -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(); @@ -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 files) { loader.waitOnClosed(); menu.runCommand(