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
Adapt the CSharpFileEditingTest after latest changes in Csharp language server #10166
Changes from 1 commit
9f49ca7
ef6ac5f
9578f1d
cf7b6dc
297de73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,16 @@ | |
*/ | ||
package org.eclipse.che.selenium.languageserver; | ||
|
||
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.MINIMUM_SEC; | ||
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.MarkerLocator.*; | ||
import static org.eclipse.che.selenium.pageobject.CodenvyEditor.MarkerLocator.ERROR; | ||
import static org.testng.Assert.fail; | ||
|
||
import com.google.inject.Inject; | ||
import java.util.List; | ||
import org.eclipse.che.api.core.model.workspace.WorkspaceStatus; | ||
import org.eclipse.che.commons.lang.NameGenerator; | ||
import org.eclipse.che.selenium.core.SeleniumWebDriver; | ||
import org.eclipse.che.selenium.core.client.TestCommandServiceClient; | ||
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; | ||
import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants; | ||
import org.eclipse.che.selenium.core.workspace.InjectTestWorkspace; | ||
import org.eclipse.che.selenium.core.workspace.TestWorkspace; | ||
|
@@ -30,11 +32,9 @@ | |
import org.eclipse.che.selenium.pageobject.ProjectExplorer; | ||
import org.eclipse.che.selenium.pageobject.Wizard; | ||
import org.eclipse.che.selenium.pageobject.intelligent.CommandsPalette; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Keys; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
import org.openqa.selenium.TimeoutException; | ||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
|
@@ -56,69 +56,80 @@ public class CSharpFileEditingTest { | |
@Inject private SeleniumWebDriver seleniumWebDriver; | ||
@Inject private TestCommandServiceClient testCommandServiceClient; | ||
@Inject private CommandsPalette commandsPalette; | ||
|
||
@Inject TestWorkspaceServiceClient testWorkspaceServiceClient; | ||
@Inject private Consoles consoles; | ||
|
||
@BeforeClass | ||
public void setUp() throws Exception { | ||
ide.open(workspace); | ||
createDotNetAppFromWizard(); | ||
restoreLanguageServer(); | ||
projectExplorer.quickRevealToItemWithJavaScript(PROJECT_NAME + "/Program.cs"); | ||
} | ||
|
||
@AfterMethod | ||
public void restartWorkspace() throws Exception { | ||
if (testWorkspaceServiceClient.getStatus(workspace.getId()).equals(WorkspaceStatus.RUNNING)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if workspace is not running at the moment? It doesn't mean that workspace is restarting at the moment, or language server will be restarted as well, do it? |
||
editor.closeAllTabs(); | ||
testWorkspaceServiceClient.stop(workspace.getName(), workspace.getOwner().getName()); | ||
ide.open(workspace); | ||
ide.waitOpenedWorkspaceIsReadyToUse(); | ||
restoreLanguageServer(); | ||
projectExplorer.quickRevealToItemWithJavaScript(PROJECT_NAME + "/Program.cs"); | ||
} | ||
} | ||
|
||
@Test | ||
public void checkLaunchingCodeserver() { | ||
projectExplorer.waitProjectExplorer(); | ||
menu.runCommand( | ||
TestMenuCommandsConstants.Workspace.WORKSPACE, | ||
TestMenuCommandsConstants.Workspace.CREATE_PROJECT); | ||
wizard.selectSample(Wizard.SamplesName.ASP_DOT_NET_WEB_SIMPLE); | ||
wizard.typeProjectNameOnWizard(PROJECT_NAME); | ||
wizard.clickCreateButton(); | ||
wizard.waitCloseProjectConfigForm(); | ||
projectExplorer.openItemByPath(PROJECT_NAME); | ||
projectExplorer.waitItem(PROJECT_NAME + "/Program.cs", 240); | ||
public void checkCodeEditing() { | ||
projectExplorer.openItemByPath(PROJECT_NAME + "/Program.cs"); | ||
loader.waitOnClosed(); | ||
checkLanguageServerInitStateAndLaunch(); | ||
checkCodeValidation(); | ||
} | ||
|
||
@Test(priority = 1) | ||
public void checkInitializingAfterFirstStarting() { | ||
projectExplorer.openItemByPath(PROJECT_NAME + "/Program.cs"); | ||
try { | ||
editor.waitMarkerInPosition(INFO, 1); | ||
editor.waitMarkerInPosition(INFO, 2); | ||
} catch (TimeoutException ex) { | ||
// remove try-catch block after issue has been resolved | ||
fail("https://github.com/eclipse/che/issues/10151"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Error message is unclear. |
||
} | ||
} | ||
|
||
public void checkCodeValidation() { | ||
editor.goToCursorPositionVisible(24, 12); | ||
for (int i = 0; i < 9; i++) { | ||
editor.typeTextIntoEditor(Keys.BACK_SPACE.toString()); | ||
} | ||
editor.waitMarkerInPosition(ERROR, 23); | ||
editor.waitMarkerInPosition(ERROR, 21); | ||
checkAutocompletion(); | ||
} | ||
|
||
private void checkAutocompletion() { | ||
editor.goToCursorPositionVisible(23, 49); | ||
editor.typeTextIntoEditor("."); | ||
editor.launchAutocomplete(); | ||
editor.enterAutocompleteProposal("Build() "); | ||
editor.typeTextIntoEditor(";"); | ||
editor.enterAutocompleteProposal("Build "); | ||
editor.typeTextIntoEditor("();"); | ||
editor.waitAllMarkersInvisibility(ERROR); | ||
} | ||
|
||
private void checkLanguageServerInitStateAndLaunch() { | ||
if (isLanguageServerInitFailed()) { | ||
reInitLanguageServer(); | ||
} | ||
private void createDotNetAppFromWizard() { | ||
projectExplorer.waitProjectExplorer(); | ||
menu.runCommand( | ||
TestMenuCommandsConstants.Workspace.WORKSPACE, | ||
TestMenuCommandsConstants.Workspace.CREATE_PROJECT); | ||
wizard.selectSample(Wizard.SamplesName.ASP_DOT_NET_WEB_SIMPLE); | ||
wizard.typeProjectNameOnWizard(PROJECT_NAME); | ||
wizard.clickCreateButton(); | ||
wizard.waitCloseProjectConfigForm(); | ||
} | ||
|
||
private void reInitLanguageServer() { | ||
private void restoreLanguageServer() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are not restoring language server directly here, aren't we? |
||
commandsPalette.openCommandPalette(); | ||
commandsPalette.startCommandByDoubleClick(COMMAND_NAME_FOR_RESTORE_LS); | ||
consoles.waitExpectedTextIntoConsole("Restore completed"); | ||
editor.closeAllTabs(); | ||
projectExplorer.openItemByPath(PROJECT_NAME + "/Program.cs"); | ||
loader.waitOnClosed(); | ||
} | ||
|
||
private boolean isLanguageServerInitFailed() { | ||
String xpathLocatorForEventMessages = | ||
"//div[contains(@id,'gwt-debug-notification-wrappergwt-uid')]"; | ||
List<WebElement> textMessages = | ||
new WebDriverWait(seleniumWebDriver, MINIMUM_SEC) | ||
.until( | ||
ExpectedConditions.presenceOfAllElementsLocatedBy( | ||
By.xpath(xpathLocatorForEventMessages))); | ||
return textMessages | ||
.stream() | ||
.anyMatch( | ||
message -> message.getAttribute("textContent").contains("Timeout initializing error")); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grouping of imports is not good practice.