diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/theia/TheiaIde.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/theia/TheiaIde.java index ed01c4b23f0..5bee109c8f0 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/theia/TheiaIde.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/theia/TheiaIde.java @@ -234,6 +234,15 @@ public void pressKeyCombination(CharSequence... combination) { seleniumWebDriverHelper.sendKeys(keyCombination); } + public void waitOpenedWorkspaceIsReadyToUse() { + // switch to the IDE and wait for workspace is ready to use + switchToIdeFrame(); + waitTheiaIde(); + waitLoaderInvisibility(); + waitTheiaIdeTopPanel(); + waitAllNotificationsClosed(); + } + @PreDestroy public void close() { seleniumWebDriver.quit(); diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/theia/TheiaProjectTree.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/theia/TheiaProjectTree.java index 9a7ce592619..299d0254905 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/theia/TheiaProjectTree.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/theia/TheiaProjectTree.java @@ -12,6 +12,7 @@ package org.eclipse.che.selenium.pageobject.theia; import static java.lang.String.format; +import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_SEC; import static org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree.Locators.EXPAND_ITEM_ICON_XPATH_TEMPLATE; import static org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree.Locators.FILES_TAB_ID; import static org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree.Locators.OPEN_WORKSPACE_BUTTON_XPATH; @@ -98,7 +99,7 @@ private String getExpandItemIconXpath(String itemPath) { public void waitItem(String itemPath) { String itemId = getProjectItemId(itemPath); - seleniumWebDriverHelper.waitVisibility(By.id(itemId)); + seleniumWebDriverHelper.waitVisibility(By.id(itemId), ELEMENT_TIMEOUT_SEC); } public void waitItemDisappearance(String itemPath) { diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStoppingWsByTimeoutTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStoppingWsByTimeoutTest.java index ef5ceaf7387..35d35d5769e 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStoppingWsByTimeoutTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/CheckStoppingWsByTimeoutTest.java @@ -13,36 +13,37 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.eclipse.che.api.core.model.workspace.WorkspaceStatus.STOPPED; -import static org.eclipse.che.selenium.core.TestGroup.UNDER_REPAIR; +import static org.eclipse.che.commons.lang.NameGenerator.generate; import static org.eclipse.che.selenium.core.utils.WaitUtils.sleepQuietly; import static org.testng.Assert.assertEquals; import com.google.inject.Inject; import com.google.inject.name.Named; +import java.util.Collections; import org.eclipse.che.api.core.model.workspace.Workspace; import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; -import org.eclipse.che.selenium.core.requestfactory.TestUserHttpJsonRequestFactory; import org.eclipse.che.selenium.core.user.DefaultTestUser; -import org.eclipse.che.selenium.core.workspace.TestWorkspace; -import org.eclipse.che.selenium.pageobject.Events; -import org.eclipse.che.selenium.pageobject.Ide; -import org.eclipse.che.selenium.pageobject.ProjectExplorer; -import org.eclipse.che.selenium.pageobject.ToastLoader; +import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper; +import org.eclipse.che.selenium.pageobject.dashboard.CreateWorkspaceHelper; +import org.eclipse.che.selenium.pageobject.dashboard.Dashboard; +import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Devfile; +import org.eclipse.che.selenium.pageobject.theia.TheiaIde; +import org.openqa.selenium.By; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -/** TODO rewrite to use che7 workspace */ -@Test(groups = UNDER_REPAIR) public class CheckStoppingWsByTimeoutTest { - private static int TOASTLOADER_WIDGET_LATENCY_TIMEOUT_IN_MILLISEC = 20000; - @Inject private Ide ide; - @Inject private ProjectExplorer projectExplorer; - @Inject private ToastLoader toastLoader; + private static final String WORKSPACE_NAME = + generate(CheckStoppingWsByTimeoutTest.class.getSimpleName(), 5); + + @Inject private Dashboard dashboard; @Inject private TestWorkspaceServiceClient workspaceServiceClient; - @Inject private TestWorkspace testWorkspace; - @Inject private DefaultTestUser testUser; - @Inject private Events eventsPanel; + @Inject private DefaultTestUser defaultTestUser; + @Inject private CreateWorkspaceHelper createWorkspaceHelper; + @Inject private TheiaIde theiaIde; + @Inject private SeleniumWebDriverHelper seleniumWebDriverHelper; @Inject @Named("che.workspace_agent_dev_inactive_stop_timeout_ms") @@ -52,38 +53,36 @@ public class CheckStoppingWsByTimeoutTest { @Named("che.workspace.activity_check_scheduler_period_s") private int cheWorkspaceActivityCheckSchedulerPeriodInSeconds; - @Inject TestUserHttpJsonRequestFactory testUserHttpJsonRequestFactory; - @BeforeClass public void setUp() throws Exception { - ide.open(testWorkspace); - projectExplorer.waitProjectExplorer(); - // We should invoke delay without any action for triggering workspace activity checker - sleepQuietly(getCommonTimeoutInMilliSec(), MILLISECONDS); + dashboard.open(); + createWorkspaceHelper.createAndStartWorkspaceFromStack( + Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null); + } + + @AfterClass + public void tearDown() throws Exception { + workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName()); } @Test public void checkStoppingByApi() throws Exception { - Workspace workspace = - workspaceServiceClient.getByName(testWorkspace.getName(), testUser.getName()); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); + sleepQuietly(getCommonTimeoutInMilliSec(), MILLISECONDS); + Workspace workspace = + workspaceServiceClient.getByName(WORKSPACE_NAME, defaultTestUser.getName()); assertEquals(workspace.getStatus(), STOPPED); } @Test(priority = 1) - public void checkLoadToasterAfterStopping() { - toastLoader.waitToastLoaderButton("Start"); - } - - @Test(priority = 2) - public void checkStopReasonNotification() { - eventsPanel.clickEventLogBtn(); - eventsPanel.waitExpectedMessage("Workspace idle timeout exceeded"); + public void checkIdeStatusAfterStopping() { + seleniumWebDriverHelper.waitVisibility( + By.xpath("//div[@id='theia-statusBar']//div[@title='Cannot connect to backend.']")); } private int getCommonTimeoutInMilliSec() { return cheWorkspaceAgentDevInactiveStopTimeoutMilliseconds - + TOASTLOADER_WIDGET_LATENCY_TIMEOUT_IN_MILLISEC + cheWorkspaceActivityCheckSchedulerPeriodInSeconds * 1000; } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterRefreshTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterRefreshTest.java index ab3b55c944f..1d16e2a6b87 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterRefreshTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterRefreshTest.java @@ -11,112 +11,82 @@ */ package org.eclipse.che.selenium.workspaces; -import static org.eclipse.che.selenium.core.TestGroup.UNDER_REPAIR; -import static org.eclipse.che.selenium.core.project.ProjectTemplates.MAVEN_SPRING; +import static org.eclipse.che.commons.lang.NameGenerator.generate; +import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE; import com.google.inject.Inject; -import java.net.URL; -import java.nio.file.Paths; -import org.eclipse.che.commons.lang.NameGenerator; +import java.util.Collections; import org.eclipse.che.selenium.core.SeleniumWebDriver; -import org.eclipse.che.selenium.core.client.TestProjectServiceClient; -import org.eclipse.che.selenium.core.workspace.TestWorkspace; -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.ProjectExplorer; +import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; +import org.eclipse.che.selenium.core.user.DefaultTestUser; +import org.eclipse.che.selenium.pageobject.dashboard.CreateWorkspaceHelper; +import org.eclipse.che.selenium.pageobject.dashboard.Dashboard; +import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Devfile; +import org.eclipse.che.selenium.pageobject.theia.TheiaEditor; +import org.eclipse.che.selenium.pageobject.theia.TheiaIde; +import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -/** @author Andrey chizhikov TODO rewrite to use che7 workspace */ -@Test(groups = UNDER_REPAIR) +/** @author Andrey chizhikov */ public class ProjectStateAfterRefreshTest { - private static final String PROJECT_NAME = NameGenerator.generate("project", 5); - - @Inject private TestWorkspace workspace; - @Inject private Ide ide; - @Inject private ProjectExplorer projectExplorer; - @Inject private Consoles consoles; - @Inject private CodenvyEditor editor; - @Inject private TestProjectServiceClient testProjectServiceClient; + private static final String WORKSPACE_NAME = + generate(ProjectStateAfterRefreshTest.class.getSimpleName(), 5); + private static final String PATH_TO_POM_FILE = CONSOLE_JAVA_SIMPLE + "/" + "pom.xml"; + private static final String PATH_TO_README_FILE = CONSOLE_JAVA_SIMPLE + "/" + "README.md"; + + @Inject private Dashboard dashboard; + @Inject private TestWorkspaceServiceClient workspaceServiceClient; + @Inject private DefaultTestUser defaultTestUser; + @Inject private CreateWorkspaceHelper createWorkspaceHelper; + @Inject private TheiaIde theiaIde; + @Inject private TheiaProjectTree theiaProjectTree; @Inject private SeleniumWebDriver seleniumWebDriver; + @Inject private TheiaEditor theiaEditor; @BeforeClass public void setUp() throws Exception { - URL resource = - ProjectStateAfterRefreshTest.this.getClass().getResource("/projects/guess-project"); - testProjectServiceClient.importProject( - workspace.getId(), Paths.get(resource.toURI()), PROJECT_NAME, MAVEN_SPRING); - ide.open(workspace); + dashboard.open(); + createWorkspaceHelper.createAndStartWorkspaceFromStack( + Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null); + } + + @AfterClass + public void tearDown() throws Exception { + workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName()); } @Test public void checkRestoreStateOfProjectAfterRefreshTest() { - ide.waitOpenedWorkspaceIsReadyToUse(); - projectExplorer.waitItem(PROJECT_NAME); - projectExplorer.quickExpandWithJavaScript(); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); + + theiaProjectTree.waitFilesTab(); + theiaProjectTree.clickOnFilesTab(); + theiaProjectTree.waitProjectAreaOpened(); + theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE); + theiaIde.waitAllNotificationsClosed(); openFilesInEditor(); checkFilesAreOpened(); seleniumWebDriver.navigate().refresh(); - ide.waitOpenedWorkspaceIsReadyToUse(); - projectExplorer.waitItem(PROJECT_NAME); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); checkFilesAreOpened(); - - editor.closeAllTabsByContextMenu(); } - @Test - public void checkRestoreStateOfProjectIfPomXmlFileOpened() { - ide.waitOpenedWorkspaceIsReadyToUse(); - projectExplorer.waitItem(PROJECT_NAME); - projectExplorer.waitAndSelectItem(PROJECT_NAME); - projectExplorer.quickExpandWithJavaScript(); - - projectExplorer.waitItem(PROJECT_NAME + "/pom.xml"); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/WEB-INF"); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/WEB-INF/jsp"); - projectExplorer.openItemByPath(PROJECT_NAME + "/pom.xml"); - editor.waitActive(); - - seleniumWebDriver.navigate().refresh(); - ide.waitOpenedWorkspaceIsReadyToUse(); - projectExplorer.waitItem(PROJECT_NAME); - editor.waitTabIsPresent("qa-spring-sample"); - projectExplorer.waitItem(PROJECT_NAME + "/pom.xml"); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/WEB-INF"); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/WEB-INF/jsp"); + private void openFilesInEditor() { + theiaProjectTree.expandItem(CONSOLE_JAVA_SIMPLE); + theiaProjectTree.waitItem(PATH_TO_POM_FILE); + theiaProjectTree.waitItem(PATH_TO_README_FILE); - editor.closeAllTabsByContextMenu(); + theiaProjectTree.openItem(PATH_TO_POM_FILE); + theiaProjectTree.openItem(PATH_TO_README_FILE); } private void checkFilesAreOpened() { - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/WEB-INF"); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/WEB-INF/jsp"); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/index.jsp"); - projectExplorer.waitItem( - PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java"); - editor.waitTabIsPresent("index.jsp"); - editor.waitTabIsPresent("AppController"); - editor.waitTabIsPresent("guess_num.jsp"); - editor.waitTabIsPresent("web.xml"); - editor.waitTabIsPresent("qa-spring-sample"); - } - - private void openFilesInEditor() { - projectExplorer.openItemByPath(PROJECT_NAME + "/src/main/webapp/index.jsp"); - editor.waitActive(); - projectExplorer.openItemByPath( - PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java"); - editor.waitActive(); - projectExplorer.openItemByPath(PROJECT_NAME + "/pom.xml"); - editor.waitActive(); - projectExplorer.openItemByPath( - PROJECT_NAME + "/src/main/webapp/WEB-INF/jsp" + "/guess_num.jsp"); - editor.waitActive(); - projectExplorer.openItemByPath(PROJECT_NAME + "/src/main/webapp/WEB-INF" + "/web.xml"); - editor.waitActive(); + theiaEditor.waitEditorTab("pom.xml"); + theiaEditor.waitEditorTab("README.md"); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterRenameWorkspaceTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterRenameWorkspaceTest.java index 149a2244abd..274229e24e5 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterRenameWorkspaceTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterRenameWorkspaceTest.java @@ -11,100 +11,102 @@ */ package org.eclipse.che.selenium.workspaces; -import static org.eclipse.che.selenium.core.TestGroup.UNDER_REPAIR; -import static org.eclipse.che.selenium.core.project.ProjectTemplates.MAVEN_SPRING; +import static org.eclipse.che.commons.lang.NameGenerator.generate; +import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE; import com.google.inject.Inject; -import java.net.URL; -import java.nio.file.Paths; -import org.eclipse.che.commons.lang.NameGenerator; -import org.eclipse.che.selenium.core.client.TestProjectServiceClient; +import java.util.Collections; import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; -import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper; -import org.eclipse.che.selenium.core.workspace.TestWorkspace; -import org.eclipse.che.selenium.pageobject.CodenvyEditor; -import org.eclipse.che.selenium.pageobject.Ide; -import org.eclipse.che.selenium.pageobject.ProjectExplorer; +import org.eclipse.che.selenium.core.user.DefaultTestUser; +import org.eclipse.che.selenium.pageobject.dashboard.CreateWorkspaceHelper; import org.eclipse.che.selenium.pageobject.dashboard.Dashboard; +import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Devfile; import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails; import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceOverview; import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces; +import org.eclipse.che.selenium.pageobject.theia.TheiaEditor; +import org.eclipse.che.selenium.pageobject.theia.TheiaIde; +import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @author Aleksandr Shmaraev */ -/** TODO rewrite to use che7 workspace */ -@Test(groups = UNDER_REPAIR) public class ProjectStateAfterRenameWorkspaceTest { - private static final String PROJECT_NAME = NameGenerator.generate("project", 4); - private static final String WORKSPACE_NEW_NAME = NameGenerator.generate("rename_ws", 4); + private static final String WORKSPACE_NAME = + generate(ProjectStateAfterRenameWorkspaceTest.class.getSimpleName(), 5); + private static final String WORKSPACE_NEW_NAME = generate("rename_ws", 4); + private static final String PATH_TO_POM_FILE = CONSOLE_JAVA_SIMPLE + "/" + "pom.xml"; + private static final String PATH_TO_README_FILE = CONSOLE_JAVA_SIMPLE + "/" + "README.md"; - @Inject private TestWorkspace testWorkspace; - @Inject private Ide ide; - @Inject private ProjectExplorer projectExplorer; - @Inject private CodenvyEditor editor; @Inject private Dashboard dashboard; + @Inject private TestWorkspaceServiceClient workspaceServiceClient; + @Inject private DefaultTestUser defaultTestUser; + @Inject private CreateWorkspaceHelper createWorkspaceHelper; + @Inject private TheiaIde theiaIde; + @Inject private TheiaProjectTree theiaProjectTree; + @Inject private TheiaEditor theiaEditor; @Inject private WorkspaceDetails workspaceDetails; - @Inject private SeleniumWebDriverHelper seleniumWebDriverHelper; - @Inject private TestProjectServiceClient testProjectServiceClient; - @Inject private TestWorkspaceServiceClient testWorkspaceServiceClient; @Inject private Workspaces workspaces; @Inject private WorkspaceOverview workspaceOverview; @BeforeClass public void setUp() throws Exception { - URL resource = - ProjectStateAfterRenameWorkspaceTest.this.getClass().getResource("/projects/guess-project"); - testProjectServiceClient.importProject( - testWorkspace.getId(), Paths.get(resource.toURI()), PROJECT_NAME, MAVEN_SPRING); - ide.open(testWorkspace); + dashboard.open(); + createWorkspaceHelper.createAndStartWorkspaceFromStack( + Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null); } @AfterClass public void tearDown() throws Exception { - testWorkspaceServiceClient.delete(WORKSPACE_NEW_NAME, testWorkspace.getOwner().getName()); + workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName()); + workspaceServiceClient.delete(WORKSPACE_NEW_NAME, defaultTestUser.getName()); } @Test - public void checkProjectAfterRenameWs() throws Exception { - ide.waitOpenedWorkspaceIsReadyToUse(); - projectExplorer.waitItem(PROJECT_NAME); - projectExplorer.waitAndSelectItem(PROJECT_NAME); - projectExplorer.quickExpandWithJavaScript(); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/index.jsp"); - projectExplorer.waitItem( - PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java"); - projectExplorer.openItemByPath(PROJECT_NAME + "/src/main/webapp/index.jsp"); - projectExplorer.openItemByPath( - PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java"); - editor.waitActive(); + public void checkProjectAfterRenameWs() { + theiaIde.waitOpenedWorkspaceIsReadyToUse(); + + theiaProjectTree.waitFilesTab(); + theiaProjectTree.clickOnFilesTab(); + theiaProjectTree.waitProjectAreaOpened(); + theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE); + theiaIde.waitAllNotificationsClosed(); + + openFilesInEditor(); + checkFilesAreOpened(); // go to dashboard and rename ws dashboard.open(); dashboard.waitDashboardToolbarTitle(); dashboard.selectWorkspacesItemOnDashboard(); dashboard.waitToolbarTitleName("Workspaces"); - - workspaces.selectWorkspaceItemName(testWorkspace.getName()); + workspaces.selectWorkspaceItemName(WORKSPACE_NAME); workspaceOverview.enterNameWorkspace(WORKSPACE_NEW_NAME); workspaceDetails.clickOnSaveChangesBtn(); dashboard.waitNotificationMessage("Workspace updated"); dashboard.waitNotificationIsClosed(); workspaceOverview.checkNameWorkspace(WORKSPACE_NEW_NAME); - - // open the IDE, check state of the project workspaceDetails.clickOpenInIdeWsBtn(); - seleniumWebDriverHelper.switchToIdeFrameAndWaitAvailability(); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); + + checkFilesAreOpened(); + } + + private void openFilesInEditor() { + theiaProjectTree.expandItem(CONSOLE_JAVA_SIMPLE); + theiaProjectTree.waitItem(PATH_TO_POM_FILE); + theiaProjectTree.waitItem(PATH_TO_README_FILE); + + theiaProjectTree.openItem(PATH_TO_POM_FILE); + theiaProjectTree.openItem(PATH_TO_README_FILE); + theiaEditor.waitEditorTab("pom.xml"); + theiaEditor.waitEditorTab("README.md"); + } - ide.waitOpenedWorkspaceIsReadyToUse(); - projectExplorer.waitItem(PROJECT_NAME); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/index.jsp"); - projectExplorer.waitItem( - PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java"); - editor.waitTabIsPresent("index.jsp"); - editor.waitTabIsPresent("AppController"); - editor.waitActive(); + private void checkFilesAreOpened() { + theiaEditor.waitEditorTab("pom.xml"); + theiaEditor.waitEditorTab("README.md"); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterWorkspaceRestartTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterWorkspaceRestartTest.java index dabcce93807..ecb51aa49e5 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterWorkspaceRestartTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/workspaces/ProjectStateAfterWorkspaceRestartTest.java @@ -11,110 +11,110 @@ */ package org.eclipse.che.selenium.workspaces; +import static org.eclipse.che.commons.lang.NameGenerator.generate; import static org.eclipse.che.selenium.core.TestGroup.UNDER_REPAIR; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Workspace.STOP_WORKSPACE; -import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Workspace.WORKSPACE; -import static org.eclipse.che.selenium.core.project.ProjectTemplates.MAVEN_SPRING; +import static org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE; import static org.testng.Assert.fail; import com.google.inject.Inject; -import java.net.URL; -import java.nio.file.Paths; -import org.eclipse.che.commons.lang.NameGenerator; -import org.eclipse.che.selenium.core.client.TestProjectServiceClient; -import org.eclipse.che.selenium.core.workspace.TestWorkspace; -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.ProjectExplorer; -import org.eclipse.che.selenium.pageobject.ToastLoader; +import java.util.Collections; +import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient; +import org.eclipse.che.selenium.core.user.DefaultTestUser; +import org.eclipse.che.selenium.pageobject.dashboard.CreateWorkspaceHelper; +import org.eclipse.che.selenium.pageobject.dashboard.Dashboard; +import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Devfile; +import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails; +import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces; +import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Status; +import org.eclipse.che.selenium.pageobject.theia.TheiaEditor; +import org.eclipse.che.selenium.pageobject.theia.TheiaIde; +import org.eclipse.che.selenium.pageobject.theia.TheiaProjectTree; import org.openqa.selenium.TimeoutException; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; /** @author Aleksandr Shmaraev on 10.03.16 * */ -/** TODO rewrite to use che7 workspace */ -@Test(groups = UNDER_REPAIR) +@Test(groups = {UNDER_REPAIR}) public class ProjectStateAfterWorkspaceRestartTest { - private static final String PROJECT_NAME = NameGenerator.generate("project", 4); - private static final String EXP_TEXT_NOT_PRESENT = - "@Override\n" + " public ModelAndView handleRequest"; - - @Inject private TestWorkspace workspace; - @Inject private Ide ide; - @Inject private ProjectExplorer projectExplorer; - @Inject private Consoles consoles; - @Inject private ToastLoader toastLoader; - @Inject private Menu menu; - @Inject private CodenvyEditor editor; - @Inject private TestProjectServiceClient testProjectServiceClient; + + private static final String WORKSPACE_NAME = + generate(ProjectStateAfterWorkspaceRestartTest.class.getSimpleName(), 5); + private static final String PATH_TO_POM_FILE = CONSOLE_JAVA_SIMPLE + "/" + "pom.xml"; + private static final String PATH_TO_README_FILE = CONSOLE_JAVA_SIMPLE + "/" + "README.md"; + + @Inject private Dashboard dashboard; + @Inject private TestWorkspaceServiceClient workspaceServiceClient; + @Inject private DefaultTestUser defaultTestUser; + @Inject private CreateWorkspaceHelper createWorkspaceHelper; + @Inject private TheiaIde theiaIde; + @Inject private TheiaProjectTree theiaProjectTree; + @Inject private TheiaEditor theiaEditor; + @Inject private WorkspaceDetails workspaceDetails; + @Inject private Workspaces workspaces; @BeforeClass public void setUp() throws Exception { - URL resource = - ProjectStateAfterWorkspaceRestartTest.this - .getClass() - .getResource("/projects/guess-project"); - testProjectServiceClient.importProject( - workspace.getId(), Paths.get(resource.toURI()), PROJECT_NAME, MAVEN_SPRING); - ide.open(workspace); - consoles.waitJDTLSProjectResolveFinishedMessage(PROJECT_NAME); + dashboard.open(); + createWorkspaceHelper.createAndStartWorkspaceFromStack( + Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null); + } + + @AfterClass + public void tearDown() throws Exception { + workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName()); } @Test public void checkProjectAfterStopStartWs() { - ide.waitOpenedWorkspaceIsReadyToUse(); - projectExplorer.quickExpandWithJavaScript(); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); + + theiaProjectTree.waitFilesTab(); + theiaProjectTree.clickOnFilesTab(); + theiaProjectTree.waitProjectAreaOpened(); + theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE); + theiaIde.waitAllNotificationsClosed(); openFilesInEditor(); + checkFilesAreOpened(); // stop and start workspace - menu.runCommand(WORKSPACE, STOP_WORKSPACE); - toastLoader.waitToastLoaderIsOpen(); - toastLoader.waitExpectedTextInToastLoader("Workspace is not running"); - consoles.closeProcessesArea(); - editor.waitTabIsNotPresent("AppController"); - editor.waitTabIsNotPresent("index.jsp"); - projectExplorer.waitDisappearItemByPath(PROJECT_NAME); - - toastLoader.clickOnToastLoaderButton("Start"); - ide.waitOpenedWorkspaceIsReadyToUse(); - consoles.waitJDTLSStartedMessage(); + dashboard.open(); + dashboard.waitDashboardToolbarTitle(); + dashboard.selectWorkspacesItemOnDashboard(); + dashboard.waitToolbarTitleName("Workspaces"); + workspaces.clickOnWorkspaceStopStartButton(WORKSPACE_NAME); + workspaces.waitWorkspaceStatus(WORKSPACE_NAME, Status.STOPPED); + workspaces.clickOnWorkspaceStopStartButton(WORKSPACE_NAME); + workspaces.waitWorkspaceStatus(WORKSPACE_NAME, Status.RUNNING); + workspaces.selectWorkspaceItemName(WORKSPACE_NAME); + workspaceDetails.waitToolbarTitleName(WORKSPACE_NAME); + workspaceDetails.clickOpenInIdeWsBtn(); - // check state of the project - checkFilesAreOpened(); + theiaIde.waitOpenedWorkspaceIsReadyToUse(); - projectExplorer.openItemByPath(PROJECT_NAME + "/README.md"); - editor.waitActive(); - editor.waitTextNotPresentIntoEditor(EXP_TEXT_NOT_PRESENT); - editor.waitTextIntoEditor("Developer Workspace"); + // check state of the project + try { + checkFilesAreOpened(); + } catch (TimeoutException ex) { + // remove try-catch block after issue has been resolved + fail("Known permanent failure https://github.com/eclipse/che/issues/14717"); + } } private void openFilesInEditor() { - projectExplorer.openItemByPath(PROJECT_NAME + "/src/main/webapp/index.jsp"); - editor.waitActive(); - projectExplorer.openItemByPath( - PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java"); - editor.waitActive(); - projectExplorer.openItemByPath(PROJECT_NAME + "/pom.xml"); - editor.waitActive(); + theiaProjectTree.expandItem(CONSOLE_JAVA_SIMPLE); + theiaProjectTree.waitItem(PATH_TO_POM_FILE); + theiaProjectTree.waitItem(PATH_TO_README_FILE); + + theiaProjectTree.openItem(PATH_TO_POM_FILE); + theiaProjectTree.openItem(PATH_TO_README_FILE); + theiaEditor.waitEditorTab("pom.xml"); + theiaEditor.waitEditorTab("README.md"); } private void checkFilesAreOpened() { - try { - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/WEB-INF"); - } catch (TimeoutException ex) { - // remove try-catch block after issue has been resolved - fail("Known random failure https://github.com/eclipse/che/issues/11000"); - } - - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/WEB-INF/jsp"); - projectExplorer.waitItem(PROJECT_NAME + "/src/main/webapp/index.jsp"); - projectExplorer.waitItem( - PROJECT_NAME + "/src/main/java/org/eclipse/qa/examples/AppController.java"); - editor.waitTabIsPresent("index.jsp"); - editor.waitTabIsPresent("AppController"); - editor.waitTabIsPresent("qa-spring-sample"); + theiaEditor.waitEditorTab("pom.xml"); + theiaEditor.waitEditorTab("README.md"); } }