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 5 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 @@ -122,11 +122,13 @@ public void waitFileNamePopUp() {
/**
* wait expected text in the dropdawn list of the widget
*
* @param text a text that should be into list
* @param nameFragment a text that should be into list
*/
public void waitListOfFilesNames(final String text) {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until((ExpectedCondition<Boolean>) webDriver -> suggestionPanel.getText().contains(text));
public Boolean isFilenameSuggested(final String nameFragment) {
return new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(
(ExpectedCondition<Boolean>)
webDriver -> suggestionPanel.getText().contains(nameFragment));
}

public String getText() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ public void expandToFileWithRevealResource(String file, String pathToFile) {
} catch (StaleElementReferenceException ex) {
WaitUtils.sleepQuietly(1);
}
navigateToFile.waitListOfFilesNames(file);
navigateToFile.isFilenameSuggested(file);
navigateToFile.selectFileByName(file);
navigateToFile.waitFormToClose();
menu.runCommand(
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,30 @@ 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");
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 All @@ -173,7 +211,7 @@ private void selectFileFromNavigate(String symbol, String pathName, List<String>
loader.waitOnClosed();
navigateToFile.waitFileNamePopUp();
for (String listFiles : files) {
navigateToFile.waitListOfFilesNames(listFiles);
navigateToFile.isFilenameSuggested(listFiles);
}
navigateToFile.selectFileByFullName(pathName);
navigateToFile.waitFormToClose();
Expand All @@ -190,7 +228,7 @@ private void selectFileFromNavigate(String symbol, String pathName) {
loader.waitOnClosed();
navigateToFile.waitFileNamePopUp();
for (String listFiles : FILES_I_SYMBOL) {
navigateToFile.waitListOfFilesNames(listFiles);
navigateToFile.isFilenameSuggested(listFiles);
}
navigateToFile.selectFileByFullName(pathName);
navigateToFile.waitFormToClose();
Expand All @@ -205,7 +243,7 @@ private void selectFileFromNavigateLaunchByKeyboard(String symbol, String pathNa
loader.waitOnClosed();
navigateToFile.waitFileNamePopUp();
for (String listFiles : FILES_R_SYMBOL) {
navigateToFile.waitListOfFilesNames(listFiles);
navigateToFile.isFilenameSuggested(listFiles);
}
navigateToFile.selectFileByFullName(pathName);
navigateToFile.waitFormToClose();
Expand Down