Skip to content

Commit

Permalink
Selenium: update "YamlFileEditingTest" selenium test according to lan…
Browse files Browse the repository at this point in the history
…guage servers test plan (#11336)
  • Loading branch information
Sergey Skorik authored Sep 25, 2018
1 parent 0620797 commit 566918c
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ protected interface Locators {
"gwt-debug-preferences-git-contribute-activateByProjectSelection-input";
String ADD_SCHEMA_URL_BUTTON_ID = "gwt-debug-preferences-addUrl";
String ADD_SCHEMA_URL_INPUT_ID = "gwt-debug-askValueDialog-textBox";
String DELETE_SCHEMA_BUTTON_XPATH =
"//table[@id='gwt-debug-preferences-cellTable-keys']//button";
}

public interface DropDownListsHeaders {
Expand Down Expand Up @@ -229,6 +231,9 @@ public enum FlagForEditorWidget {
@FindBy(id = Locators.ADD_SCHEMA_URL_INPUT_ID)
private WebElement addSchemaUrlInput;

@FindBy(xpath = Locators.DELETE_SCHEMA_BUTTON_XPATH)
private WebElement deleteSchemaButton;

/** wait preferences form */
public void waitPreferencesForm() {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
Expand Down Expand Up @@ -334,6 +339,12 @@ public void addSchemaUrl(String schemaName) {
webDriverHelper.waitAndClick(By.id("askValue-dialog-ok"));
}

public void deleteSchema() {
webDriverHelper.waitAndClick(deleteSchemaButton);
askDialog.clickOkBtn();
askDialog.waitFormToClose();
}

public void clickOnGenerateAndUploadToGitHub() {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(visibilityOf(generateAndUploadBtn))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@

import static java.lang.String.format;
import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Assistant.ASSISTANT;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Assistant.GO_TO_SYMBOL;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Profile.PREFERENCES;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Profile.PROFILE_MENU;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Project.New.FILE;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Project.New.NEW;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Project.PROJECT;
import static org.eclipse.che.selenium.core.project.ProjectTemplates.NODE_JS;
import static org.eclipse.che.selenium.core.workspace.WorkspaceTemplate.ECLIPSE_NODEJS_YAML;
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.MarkerLocator.ERROR;
Expand All @@ -25,18 +30,21 @@
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.constant.TestMenuCommandsConstants.Project;
import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Project.New;
import org.eclipse.che.selenium.core.workspace.InjectTestWorkspace;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.AskForValueDialog;
import org.eclipse.che.selenium.pageobject.AssistantFindPanel;
import org.eclipse.che.selenium.pageobject.CodenvyEditor;
import org.eclipse.che.selenium.pageobject.Consoles;
import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.Menu;
import org.eclipse.che.selenium.pageobject.Preferences;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.openqa.selenium.Keys;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

Expand All @@ -47,6 +55,8 @@ public class YamlFileEditingTest {
private static final String PATH_TO_YAML_FILE = PROJECT_NAME + "/" + YAML_FILE_NAME;
private static final String LS_INIT_MESSAGE =
format("Finished language servers initialization, file path '/%s'", PATH_TO_YAML_FILE);
private static final List<String> EXPECTED_GO_TO_SYMBOL_ALTERNATIVES =
Arrays.asList("apiVersionsymbols (194)", "kind", "metadata");

private static final String COMMENTED_CODE =
"# generation: 4\n"
Expand All @@ -71,6 +81,7 @@ public class YamlFileEditingTest {
@Inject private Preferences preferences;
@Inject private ProjectExplorer projectExplorer;
@Inject private AskForValueDialog askForValueDialog;
@Inject private AssistantFindPanel assistantFindPanel;
@Inject private TestProjectServiceClient testProjectServiceClient;

@BeforeClass
Expand All @@ -85,11 +96,16 @@ public void setUp() throws Exception {
addYamlSchema();
}

@AfterClass
public void tearDown() {
deleteSchema();
}

@Test
public void checkLanguageServerInitialized() {
projectExplorer.waitAndSelectItem(PROJECT_NAME);

menu.runCommand(Project.PROJECT, New.NEW, New.FILE);
menu.runCommand(PROJECT, NEW, FILE);
askForValueDialog.createNotJavaFileByName(YAML_FILE_NAME);
editor.waitTabIsPresent(YAML_FILE_NAME);

Expand Down Expand Up @@ -166,8 +182,11 @@ public void checkHoverFeature() {
"Kind is a string value representing the REST resource this object represents.");

editor.moveCursorToText("apiVersion:");
editor.waitTextInHoverPopup(
"APIVersion defines the versioned schema of this representation of an object.");
editor.waitTextInHoverPopUpEqualsTo(
"APIVersion defines the versioned schema of this representation of an object. "
+ "Servers should convert recognized schemas to the latest internal value, "
+ "and may reject unrecognized values. More info: "
+ "http://releases\\.k8s\\.io/HEAD/docs/devel/api\\-conventions\\.md\\#resources");
}

@Test(priority = 1)
Expand Down Expand Up @@ -212,6 +231,44 @@ public void checkCommentCodeFeature() {
editor.waitTextIntoEditor(UNCOMMENTED_CODE);
}

@Test(priority = 1)
public void checkGoToSymbolFeature() {
editor.selectTabByName("deployment.yaml");

// check list for expected items
menu.runCommand(ASSISTANT, GO_TO_SYMBOL);
assistantFindPanel.waitForm();
assistantFindPanel.waitAllNodes(EXPECTED_GO_TO_SYMBOL_ALTERNATIVES);

// open item by mouse click
assistantFindPanel.clickOnActionNodeWithText("apiVersion");
editor.waitCursorPosition(13, 1);

// find and open item from Go To Symbol panel
menu.runCommand(ASSISTANT, GO_TO_SYMBOL);
assistantFindPanel.waitForm();
assistantFindPanel.typeToInputField("kin");
assistantFindPanel.waitNode("kind");
assistantFindPanel.clickOnActionNodeWithText("kind");
editor.waitCursorPosition(14, 1);

// select items by DOWN and UP buttons
menu.runCommand(ASSISTANT, GO_TO_SYMBOL);
assistantFindPanel.waitForm();
editor.typeTextIntoEditor(Keys.DOWN.toString());
editor.waitCursorPosition(13, 15);
editor.typeTextIntoEditor(Keys.DOWN.toString());
editor.waitCursorPosition(14, 23);
editor.typeTextIntoEditor(Keys.DOWN.toString());
editor.waitCursorPosition(27, 44);
editor.typeTextIntoEditor(Keys.UP.toString());
editor.waitCursorPosition(14, 23);

// open item by pressing ENTER key
editor.typeTextIntoEditor(Keys.ENTER.toString());
editor.waitCursorPosition(14, 1);
}

private void addYamlSchema() {
menu.runCommand(PROFILE_MENU, PREFERENCES);
preferences.waitPreferencesForm();
Expand All @@ -225,4 +282,17 @@ private void addYamlSchema() {

preferences.closeForm();
}

private void deleteSchema() {
menu.runCommand(PROFILE_MENU, PREFERENCES);
preferences.waitPreferencesForm();

preferences.waitMenuInCollapsedDropdown(YAML);
preferences.selectDroppedMenuByName(YAML);

preferences.deleteSchema();
preferences.clickOnOkBtn();

preferences.closeForm();
}
}

0 comments on commit 566918c

Please sign in to comment.