[Selenium] Adapt selenium tests to work with workspaces from Che7 stacks (#14594)

7.20.x
Sergey Skorik 2019-09-26 16:07:32 +03:00 committed by GitHub
parent dd47af60fd
commit 87611541b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 156 additions and 742 deletions

View File

@ -39,20 +39,16 @@ public class CreateWorkspaceHelper {
public TestWorkspace createWorkspaceFromDevfileWithProject(
Devfile devfile, String workspaceName, String projectName) {
return createWorkspaceFromStack(devfile, workspaceName, ImmutableList.of(projectName), null);
return createAndStartWorkspaceFromStack(
devfile, workspaceName, ImmutableList.of(projectName), null);
}
public TestWorkspace createWorkspaceFromDevfileWithoutProject(
Devfile devfile, String workspaceName) {
return createWorkspaceFromStack(devfile, workspaceName, Collections.emptyList(), null);
return createAndStartWorkspaceFromStack(devfile, workspaceName, Collections.emptyList(), null);
}
public TestWorkspace createWorkspaceFromStackWithProjects(
Devfile devfile, String workspaceName, List<String> projectNames) {
return createWorkspaceFromStack(devfile, workspaceName, projectNames, null);
}
public TestWorkspace createWorkspaceFromStack(
public TestWorkspace createAndStartWorkspaceFromStack(
Devfile devfile, String workspaceName, List<String> projectNames, Double machineRam) {
prepareWorkspace(devfile, workspaceName, machineRam);
@ -65,6 +61,19 @@ public class CreateWorkspaceHelper {
return testWorkspaceProvider.getWorkspace(workspaceName, defaultTestUser);
}
public TestWorkspace createAndEditWorkspaceFromStack(
Devfile devfile, String workspaceName, List<String> projectNames, Double machineRam) {
prepareWorkspace(devfile, workspaceName, machineRam);
projectSourcePage.clickOnAddOrImportProjectButton();
projectNames.forEach(projectSourcePage::selectSample);
projectSourcePage.clickOnAddProjectButton();
newWorkspace.clickOnCreateButtonAndEditWorkspace();
return testWorkspaceProvider.getWorkspace(workspaceName, defaultTestUser);
}
private void prepareWorkspace(Devfile devfile, String workspaceName, Double machineRam) {
dashboard.waitDashboardToolbarTitle();

View File

@ -58,10 +58,10 @@ public class WorkspaceOverview {
public interface Locators {
String NAME_WORKSPACE_INPUT = "//input[@placeholder='Name of the workspace *']";
String DELETE_WORKSPACE_BTN = "//button/span[text()='Delete']";
String DELETE_WORKSPACE_BTN = "//button[text()='Delete']";
String WORKSPACE_TITLE = "//div[contains(@class,'toolbar-info')]/span[text()='%s']";
String EXPORT_WORKSPACE_BTN =
"//button[contains(@class, 'che-button')]/span[text()='Export as a file']";
"//button[contains(@class, 'che-button')][text()='Export as a file']";
String DOWNLOAD_WORKSPACE_BTN = "//che-button-default[@che-button-title='download']";
String CLIPBOARD_JSON_WS_BTN = "//che-button-default[@che-button-title='clipboard']";
String HIDE_JSON_WS_BTN = "//span[text()='Close']";
@ -70,8 +70,7 @@ public class WorkspaceOverview {
String EXPORT_WS_FORM_XPATH = "//che-popup[@title='Export Workspace']";
String AS_FILE_CONFIG_BODY_XPATH =
"//che-popup[@title='Export Workspace']//div[@class='CodeMirror-code']";
String SAVE_BUTTON_XPATH = "//button[@name='save-button' ]";
String SAVE_BUTTON_XPATH = "//che-button-save-flat[@che-button-title='Save']";
String AS_FILE_BUTTON_XPATH = "//md-tab-item/span[text()='As a File']";
String PRIVATE_CLOUD_BUTTON_XPATH = "//md-tab-item/span[text()='To Private Cloud']";
}

View File

@ -75,6 +75,7 @@ public class Workspaces {
String SEARCH_WORKSPACE_FIELD = "//input[@ng-placeholder='Search']";
String NO_WORKSPACE_FOUND = "//span[text()='No workspaces found.']";
String WORKSPACE_ITEM_NAME = "//div[@class='workspace-name-clip' and contains(@id, '/%s')]";
String WORKSPACE_ITEM_XPATH = "//div[@id='ws-name-%s']";
String WORKSPACE_ITEM_FULL_NAME = "//div[@id='ws-full-name-%s']";
String WORKSPACE_ITEM_CHECKBOX = "//div[@id='ws-name-%s']//md-checkbox";
String WORKSPACE_ITEM_RAM = "//div[@id='ws-name-%s']//span[@name='workspace-ram-value']";
@ -132,7 +133,7 @@ public class Workspaces {
return new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
visibilityOfElementLocated(
By.xpath(format(Locators.WORKSPACE_ITEM_NAME, workspaceName))))
By.xpath(format(Locators.WORKSPACE_ITEM_XPATH, workspaceName))))
.getAttribute("data-ws-status");
}

View File

@ -14,6 +14,7 @@ package org.eclipse.che.selenium.pageobject.theia;
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOADER_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.PREPARING_WS_TIMEOUT_SEC;
import static org.eclipse.che.selenium.pageobject.theia.TheiaIde.Locators.NOTIFICATION_CLOSE_BUTTON;
@ -57,6 +58,8 @@ public class TheiaIde {
String ABOUT_DIALOG_TITLE_XPATH = ABOUT_DIALOG_XPATH + "//div[@class='dialogTitle']";
String ABOUT_DIALOG_CONTENT_XPATH = ABOUT_DIALOG_XPATH + "//div[@class='dialogContent']";
String ABOUT_DIALOG_OK_BUTTON_XPATH = ABOUT_DIALOG_XPATH + "//button";
String NOTIFICATION_ITEM_XPATH =
"//div[@class='theia-notification-list-item']//div[@class='theia-notification-message']";
String NOTIFICATION_MESSAGE_EQUALS_TO_XPATH_TEMPLATE =
"//div[@class='theia-notification-list-item']//div[@class='theia-notification-message']//span[text()='%s']";
String NOTIFICATION_MESSAGE_CONTAINS_XPATH_TEMPLATE =
@ -151,6 +154,11 @@ public class TheiaIde {
seleniumWebDriverHelper.waitInvisibility(By.className("theia-Notification"));
}
public void waitAllNotificationsClosed() {
seleniumWebDriverHelper.waitInvisibility(
By.xpath((Locators.NOTIFICATION_ITEM_XPATH)), LOADER_TIMEOUT_SEC);
}
public void waitTheiaIde() {
try {
seleniumWebDriverHelper.waitVisibility(theiaIde, PREPARING_WS_TIMEOUT_SEC);

View File

@ -1,428 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.selenium.dashboard;
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.pageobject.dashboard.ProjectSourcePage.Template.WEB_JAVA_SPRING;
import static org.eclipse.che.selenium.pageobject.dashboard.factories.CreateFactoryPage.TabNames.CONFIG_TAB_ID;
import static org.eclipse.che.selenium.pageobject.dashboard.factories.CreateFactoryPage.TabNames.GIT_TAB_ID;
import static org.eclipse.che.selenium.pageobject.dashboard.factories.CreateFactoryPage.TabNames.TEMPLATE_TAB_ID;
import static org.eclipse.che.selenium.pageobject.dashboard.factories.CreateFactoryPage.TabNames.WORKSPACE_TAB_ID;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.StateWorkspace.STOPPED;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import com.google.inject.Inject;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import org.eclipse.che.selenium.core.client.TestFactoryServiceClient;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.core.workspace.TestWorkspaceProvider;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.DashboardFactories;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Devfile;
import org.eclipse.che.selenium.pageobject.dashboard.ProjectSourcePage;
import org.eclipse.che.selenium.pageobject.dashboard.factories.CreateFactoryPage;
import org.eclipse.che.selenium.pageobject.dashboard.factories.FactoryDetails;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/** TODO rewrite to use che7 workspace */
@Test(groups = UNDER_REPAIR)
public class CreateFactoryTest {
private static final String PROJECT_WS_NAME = generate("project-ws", 4);
private static final String NO_PROJECT_WS_NAME = generate("no-project-ws", 4);
private static final String FACTORY_NAME_EXIST = generate("factoryExist", 4);
private static final String MINIMAL_TEMPLATE_FACTORY_NAME = generate("factoryMin", 4);
private static final String COMPLETE_TEMPLATE_FACTORY_NAME = generate("factoryComplete", 4);
private static final String FACTORY_CREATED_FROM_WORKSPACE_NAME = generate("factoryWs", 4);
private static final String FACTORY_CREATED_FROM_GIT_NAME = generate("factoryGit", 4);
private static final String FACTORY_CREATED_FROM_CONFIG_NAME = generate("factoryConfig", 4);
private static final String FACTORY_CREATED_FROM_USER_JSON_NAME = generate("factoryUser", 4);
private static final String MIN_FACTORY_NAME = generate("", 3);
private static final String MAX_FACTORY_NAME = generate("", 20);
private static final String RESOURCES_CONFIG_FILE =
"/org/eclipse/che/selenium/dashboard/config-ws.json";
private static final String WS_HAS_NO_PROJECT_ERROR_MESSAGE =
"Factory can't be created. The selected workspace has no projects defined. Project sources must be available from an external storage.";
private static final String TOO_SHORT_NAME_MESAAGE =
"The name has to be more than 3 characters long.";
private static final String TOO_LONG_NAME_MESSAGE =
"The name has to be less than 20 characters long.";
private static final String SPECIAL_SYMBOLS_NAME = "***";
private static final String SPECIAL_SYMBOLS_ERROR_MESSAGE =
"Factory name may contain digits, latin letters, spaces, _ , . , - and should start only with digits, latin letters or underscores";
private static final String EXIST_NAME_ERROR_MESSAGE = "This factory name is already used.";
private static final String LOAD_FILE_CONFIGURATION_MESSAGE =
"Successfully loaded file's configuration config-ws.json.";
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestFactoryServiceClient factoryServiceClient;
@Inject private DashboardFactories dashboardFactories;
@Inject private ProjectSourcePage projectSourcePage;
@Inject private WorkspaceDetails workspaceDetails;
@Inject private FactoryDetails factoryDetails;
@Inject private NewWorkspace newWorkspace;
@Inject private DefaultTestUser defaultTestUser;
@Inject private TestGitHubRepository testRepo;
@Inject private Workspaces workspaces;
@Inject private CreateFactoryPage createFactoryPage;
@Inject private Dashboard dashboard;
@Inject private Loader loader;
@Inject private TestWorkspaceProvider testWorkspaceProvider;
// it is used to read workspace logs on test failure
private TestWorkspace testWorkspace1;
private TestWorkspace testWorkspace2;
public CreateFactoryTest() {}
@BeforeClass
public void setUp() throws Exception {
dashboard.open();
// store info about created workspace to make SeleniumTestHandler.captureTestWorkspaceLogs()
// possible to read logs in case of test failure
testWorkspace1 = createWorkspaceWithProject(PROJECT_WS_NAME);
testWorkspace2 = createWorkspaceWithoutProject(NO_PROJECT_WS_NAME);
}
@AfterClass
public void tearDown() throws Exception {
workspaceServiceClient.delete(PROJECT_WS_NAME, defaultTestUser.getName());
workspaceServiceClient.delete(NO_PROJECT_WS_NAME, defaultTestUser.getName());
List<String> factoryList =
Arrays.asList(
FACTORY_NAME_EXIST,
MINIMAL_TEMPLATE_FACTORY_NAME,
COMPLETE_TEMPLATE_FACTORY_NAME,
FACTORY_CREATED_FROM_WORKSPACE_NAME,
FACTORY_CREATED_FROM_CONFIG_NAME,
FACTORY_CREATED_FROM_GIT_NAME,
FACTORY_CREATED_FROM_USER_JSON_NAME);
for (String factory : factoryList) {
factoryServiceClient.deleteFactory(factory);
}
}
@BeforeMethod
private void openNewFactoryPage() {
// open the New Factory page before starting each test method
dashboardFactories.selectFactoriesOnNavBar();
dashboardFactories.waitAllFactoriesPage();
dashboardFactories.clickOnAddFactoryBtn();
createFactoryPage.waitToolbarTitle();
}
@Test
public void checkCreateFactoryFromGitTab() throws IOException {
// create the test repository and get url
Path entryPath =
Paths.get(getClass().getResource("/projects/default-spring-project").getPath());
testRepo.addContent(entryPath);
String repositoryUrl = testRepo.getHttpsTransportUrl();
// open the 'Git' tab and fill the fields url and name
createFactoryPage.clickOnSourceTab(GIT_TAB_ID);
createFactoryPage.typeGitRepositoryUrl(repositoryUrl);
createFactoryPage.typeFactoryName(FACTORY_CREATED_FROM_GIT_NAME);
assertTrue(createFactoryPage.isCreateFactoryButtonEnabled());
// create factory
createFactoryPage.clickOnCreateFactoryButton();
factoryDetails.waitFactoryName(FACTORY_CREATED_FROM_GIT_NAME);
// check present the id url and named url of the factory
dashboardFactories.waitFactoryIdUrl();
dashboardFactories.waitFactoryNamedUrl(FACTORY_CREATED_FROM_GIT_NAME);
}
@Test
public void checkCreateFactoryFromConfigTab() throws IOException, URISyntaxException {
URL resourcesUploadFile = getClass().getResource(RESOURCES_CONFIG_FILE);
// select the 'Config' tab
createFactoryPage.clickOnSourceTab(CONFIG_TAB_ID);
createFactoryPage.typeFactoryName(FACTORY_CREATED_FROM_CONFIG_NAME);
assertTrue(createFactoryPage.isUploadFileButtonEnabled());
assertFalse(createFactoryPage.isCreateFactoryButtonEnabled());
// upload the configuration file from resources
createFactoryPage.uploadSelectedConfigFile(Paths.get(resourcesUploadFile.toURI()));
dashboard.waitNotificationMessage(LOAD_FILE_CONFIGURATION_MESSAGE);
dashboard.waitNotificationIsClosed();
assertTrue(createFactoryPage.isCreateFactoryButtonEnabled());
// create factory
createFactoryPage.clickOnCreateFactoryButton();
factoryDetails.waitFactoryName(FACTORY_CREATED_FROM_CONFIG_NAME);
// check present the id url and named url of the factory
dashboardFactories.waitFactoryNamedUrl(FACTORY_CREATED_FROM_CONFIG_NAME);
dashboardFactories.waitFactoryIdUrl();
}
@Test
public void checkHandlingOfFactoryNames() {
// create a factory from workspace with a project
createFactoryFromWorkspaceWithProject(FACTORY_NAME_EXIST);
openNewFactoryPage();
// select created workspace from list of workspaces
createFactoryPage.clickOnWorkspaceFromList(PROJECT_WS_NAME);
// enter empty factory name
createFactoryPage.typeFactoryName("");
createFactoryPage.waitErrorMessageNotVisible();
assertTrue(createFactoryPage.isCreateFactoryButtonEnabled());
// enter factory name with a less than 3 symbols
createFactoryPage.typeFactoryName(generate("", 2));
createFactoryPage.waitErrorMessage(TOO_SHORT_NAME_MESAAGE);
assertFalse(createFactoryPage.isCreateFactoryButtonEnabled());
// enter factory name with exactly 3 symbols
createFactoryPage.typeFactoryName(MIN_FACTORY_NAME);
createFactoryPage.waitErrorMessageNotVisible();
assertTrue(createFactoryPage.isCreateFactoryButtonEnabled());
// enter factory name with special symbols
createFactoryPage.typeFactoryName(SPECIAL_SYMBOLS_NAME);
createFactoryPage.waitErrorMessage(SPECIAL_SYMBOLS_ERROR_MESSAGE);
assertFalse(createFactoryPage.isCreateFactoryButtonEnabled());
// enter factory name with more than 20 symbols
createFactoryPage.typeFactoryName(generate("", 21));
createFactoryPage.waitErrorMessage(TOO_LONG_NAME_MESSAGE);
assertFalse(createFactoryPage.isCreateFactoryButtonEnabled());
// enter factory name with exactly 20 symbols
createFactoryPage.typeFactoryName(MAX_FACTORY_NAME);
createFactoryPage.waitErrorMessageNotVisible();
assertTrue(createFactoryPage.isCreateFactoryButtonEnabled());
// enter an already existing factory name
createFactoryPage.typeFactoryName(FACTORY_NAME_EXIST);
createFactoryPage.waitErrorMessage(EXIST_NAME_ERROR_MESSAGE);
assertFalse(createFactoryPage.isCreateFactoryButtonEnabled());
}
@Test
public void shouldCreateFactoryFromTemplate() {
// select the 'Template' tab
createFactoryPage.waitToolbarTitle();
createFactoryPage.clickOnSourceTab(TEMPLATE_TAB_ID);
createFactoryPage.typeFactoryName(MINIMAL_TEMPLATE_FACTORY_NAME);
createFactoryPage.waitTemplateButtons();
createFactoryPage.clickOnMinimalTemplateButton();
// create a factory from minimal template
createFactoryPage.clickOnCreateFactoryButton();
factoryDetails.waitFactoryName(MINIMAL_TEMPLATE_FACTORY_NAME);
// check present the factory url
dashboardFactories.waitFactoryNamedUrl(MINIMAL_TEMPLATE_FACTORY_NAME);
dashboardFactories.waitFactoryIdUrl();
// go to the factory list
factoryDetails.clickOnBackToFactoriesListButton();
dashboardFactories.waitAllFactoriesPage();
dashboardFactories.waitFactoryName(MINIMAL_TEMPLATE_FACTORY_NAME);
assertEquals(dashboardFactories.getFactoryRamLimit(MINIMAL_TEMPLATE_FACTORY_NAME), "2048 MB");
// go to the 'Template' tab
dashboardFactories.waitAllFactoriesPage();
dashboardFactories.clickOnAddFactoryBtn();
createFactoryPage.waitToolbarTitle();
createFactoryPage.typeFactoryName(COMPLETE_TEMPLATE_FACTORY_NAME);
createFactoryPage.clickOnSourceTab(TEMPLATE_TAB_ID);
// create a factory from complete template
createFactoryPage.waitTemplateButtons();
createFactoryPage.clickOnCompleteTemplateButton();
createFactoryPage.clickOnCreateFactoryButton();
factoryDetails.waitFactoryName(COMPLETE_TEMPLATE_FACTORY_NAME);
// check present the factory url
dashboardFactories.waitFactoryNamedUrl(COMPLETE_TEMPLATE_FACTORY_NAME);
dashboardFactories.waitFactoryIdUrl();
// go to the factory list
factoryDetails.clickOnBackToFactoriesListButton();
dashboardFactories.waitAllFactoriesPage();
dashboardFactories.waitFactoryName(COMPLETE_TEMPLATE_FACTORY_NAME);
assertEquals(dashboardFactories.getFactoryRamLimit(COMPLETE_TEMPLATE_FACTORY_NAME), "2048 MB");
}
@Test
public void checkEditorOfTemplateJson() throws Exception {
// select the minimal template
createFactoryPage.waitToolbarTitle();
createFactoryPage.clickOnSourceTab(TEMPLATE_TAB_ID);
createFactoryPage.typeFactoryName(FACTORY_CREATED_FROM_USER_JSON_NAME);
createFactoryPage.waitTemplateButtons();
createFactoryPage.clickOnMinimalTemplateButton();
// delete content of the template
createFactoryPage.setFocusInEditorTemplate();
createFactoryPage.deleteAllContentFromTemplateEditor();
assertFalse(createFactoryPage.isCreateFactoryButtonEnabled());
// type the user json workspace
createFactoryPage.typeConfigFileToTemplateEditor(RESOURCES_CONFIG_FILE);
assertTrue(createFactoryPage.isCreateFactoryButtonEnabled());
createFactoryPage.clickOnCreateFactoryButton();
factoryDetails.waitFactoryName(FACTORY_CREATED_FROM_USER_JSON_NAME);
// check present the factory url
dashboardFactories.waitFactoryNamedUrl(FACTORY_CREATED_FROM_USER_JSON_NAME);
dashboardFactories.waitFactoryIdUrl();
}
@Test
public void shouldCreateFactoryFromWorkspace() {
// check error when create factory without a project
createFactoryPage.clickOnSourceTab(WORKSPACE_TAB_ID);
createFactoryPage.clickOnWorkspaceFromList(NO_PROJECT_WS_NAME);
dashboard.waitNotificationMessage(WS_HAS_NO_PROJECT_ERROR_MESSAGE);
dashboard.waitNotificationIsClosed();
assertFalse(createFactoryPage.isCreateFactoryButtonEnabled());
// create a new factory from a workspace with a project
createFactoryFromWorkspaceWithProject(FACTORY_CREATED_FROM_WORKSPACE_NAME);
factoryDetails.waitFactoryName(FACTORY_CREATED_FROM_WORKSPACE_NAME);
// check present the id url and named url of the factory
dashboardFactories.waitFactoryIdUrl();
dashboardFactories.waitFactoryNamedUrl(FACTORY_CREATED_FROM_WORKSPACE_NAME);
factoryDetails.clickOnBackToFactoriesListButton();
// check that the created factory exists in the Factories list
dashboardFactories.waitAllFactoriesPage();
dashboardFactories.waitFactoryName(FACTORY_CREATED_FROM_WORKSPACE_NAME);
assertEquals(
dashboardFactories.getFactoryRamLimit(FACTORY_CREATED_FROM_WORKSPACE_NAME), "2048 MB");
}
@Test
public void checkWorkspaceFiltering() {
// click on the search button and wait search field visible
createFactoryPage.clickOnSearchFactoryButton();
createFactoryPage.waitSearchFactoryField();
// filter by full workspace name
createFactoryPage.typeTextToSearchFactoryField(PROJECT_WS_NAME);
createFactoryPage.waitWorkspaceNameInList(PROJECT_WS_NAME);
// filter by a part of workspace name
createFactoryPage.typeTextToSearchFactoryField(
PROJECT_WS_NAME.substring(PROJECT_WS_NAME.length() / 2));
createFactoryPage.waitWorkspaceNameInList(PROJECT_WS_NAME);
// filter by a nonexistent workspace name
createFactoryPage.typeTextToSearchFactoryField(generate("", 8));
createFactoryPage.waitWorkspacesListIsEmpty();
}
private TestWorkspace createWorkspaceWithProject(String workspaceName) {
// create a workspace from the Java stack with the web-java-spring project
dashboard.waitDashboardToolbarTitle();
dashboard.selectWorkspacesItemOnDashboard();
dashboard.waitToolbarTitleName("Workspaces");
workspaces.clickOnAddWorkspaceBtn();
newWorkspace.waitToolbar();
loader.waitOnClosed();
// we are selecting 'Java' stack from the 'All Devfile' tab for compatibility with OSIO
newWorkspace.selectDevfile(Devfile.JAVA_MAVEN);
newWorkspace.typeWorkspaceName(workspaceName);
projectSourcePage.clickOnAddOrImportProjectButton();
projectSourcePage.selectSample(WEB_JAVA_SPRING);
projectSourcePage.clickOnAddProjectButton();
projectSourcePage.waitCreatedProjectButton(WEB_JAVA_SPRING);
newWorkspace.clickOnCreateButtonAndEditWorkspace();
workspaceDetails.waitToolbarTitleName(workspaceName);
workspaceDetails.checkStateOfWorkspace(STOPPED);
return testWorkspaceProvider.getWorkspace(workspaceName, defaultTestUser);
}
private TestWorkspace createWorkspaceWithoutProject(String workspaceName) {
// create a workspace from the Java stack with the web-java-spring project
dashboard.waitDashboardToolbarTitle();
dashboard.selectWorkspacesItemOnDashboard();
dashboard.waitToolbarTitleName("Workspaces");
workspaces.clickOnAddWorkspaceBtn();
newWorkspace.waitToolbar();
loader.waitOnClosed();
// we are selecting 'Java' stack from the 'All Devfile' tab for compatibility with OSIO
newWorkspace.selectDevfile(Devfile.JAVA_MAVEN);
newWorkspace.typeWorkspaceName(workspaceName);
newWorkspace.clickOnCreateButtonAndEditWorkspace();
workspaceDetails.waitToolbarTitleName(workspaceName);
workspaceDetails.checkStateOfWorkspace(STOPPED);
return testWorkspaceProvider.getWorkspace(workspaceName, defaultTestUser);
}
private void createFactoryFromWorkspaceWithProject(String factoryName) {
createFactoryPage.clickOnSourceTab(WORKSPACE_TAB_ID);
createFactoryPage.typeFactoryName(factoryName);
createFactoryPage.clickOnWorkspaceFromList(PROJECT_WS_NAME);
// check that the Create Factory button is enabled after a workspace selecting
assertTrue(createFactoryPage.isCreateFactoryButtonEnabled());
createFactoryPage.clickOnCreateFactoryButton();
}
}

View File

@ -11,54 +11,66 @@
*/
package org.eclipse.che.selenium.dashboard;
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.pageobject.dashboard.workspaces.WorkspaceDetails.StateWorkspace.RUNNING;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.WorkspaceDetailsTab.OVERVIEW;
import com.google.inject.Inject;
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.core.workspace.TestWorkspace;
import org.eclipse.che.selenium.pageobject.Loader;
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.dashboard.workspaces.Workspaces.Status;
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)
public class DeleteRunningWorkspaceTest {
private static final String WORKSPACE_NAME =
generate(DeleteRunningWorkspaceTest.class.getSimpleName(), 5);
@Inject private Dashboard dashboard;
@Inject private WorkspaceDetails workspaceDetails;
@Inject private TestWorkspace ws;
@Inject private Loader loader;
@Inject private DefaultTestUser user;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private Workspaces workspaces;
@Inject private WorkspaceOverview workspaceOverview;
private String workspaceName;
@Inject private DefaultTestUser defaultTestUser;
@Inject private CreateWorkspaceHelper createWorkspaceHelper;
@BeforeClass
public void setUp() throws Exception {
this.workspaceName = ws.getName();
dashboard.open();
createWorkspaceHelper.createAndEditWorkspaceFromStack(
Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null);
}
@AfterClass
public void tearDown() throws Exception {
workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName());
}
@Test
public void deleteRunningWorkspaceTest() {
dashboard.selectWorkspacesItemOnDashboard();
workspaces.selectWorkspaceItemName(workspaceName);
workspaceDetails.waitToolbarTitleName(workspaceName);
dashboard.waitToolbarTitleName("Workspaces");
workspaces.clickOnWorkspaceStopStartButton(WORKSPACE_NAME);
workspaces.waitWorkspaceStatus(WORKSPACE_NAME, Status.RUNNING);
dashboard.selectWorkspacesItemOnDashboard();
workspaces.selectWorkspaceItemName(WORKSPACE_NAME);
workspaceDetails.waitToolbarTitleName(WORKSPACE_NAME);
workspaceDetails.selectTabInWorkspaceMenu(OVERVIEW);
workspaceDetails.checkStateOfWorkspace(RUNNING);
workspaceOverview.clickOnDeleteWorkspace();
workspaceDetails.clickOnDeleteButtonInDialogWindow();
dashboard.waitToolbarTitleName("Workspaces");
workspaces.waitWorkspaceIsNotPresent(workspaceName);
workspaces.waitWorkspaceIsNotPresent(WORKSPACE_NAME);
}
}

View File

@ -11,52 +11,68 @@
*/
package org.eclipse.che.selenium.dashboard;
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.pageobject.dashboard.workspaces.WorkspaceDetails.StateWorkspace.RUNNING;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.StateWorkspace.STOPPED;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.WorkspaceDetailsTab.OVERVIEW;
import com.google.inject.Inject;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
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.WorkspaceOverview;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Status;
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)
public class DeleteStoppingWorkspaceTest {
private static final String WORKSPACE_NAME =
generate(DeleteStoppingWorkspaceTest.class.getSimpleName(), 5);
@Inject private Dashboard dashboard;
@Inject private WorkspaceDetails workspaceDetails;
@Inject private TestWorkspace ws;
@Inject private Workspaces workspaces;
@Inject private WorkspaceOverview workspaceOverview;
private String workspaceName;
@Inject private DefaultTestUser defaultTestUser;
@Inject private CreateWorkspaceHelper createWorkspaceHelper;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@BeforeClass
public void setUp() throws Exception {
this.workspaceName = ws.getName();
dashboard.open();
createWorkspaceHelper.createAndEditWorkspaceFromStack(
Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null);
}
@AfterClass
public void tearDown() throws Exception {
workspaceServiceClient.delete(WORKSPACE_NAME, defaultTestUser.getName());
}
@Test
public void deleteStoppingWorkspaceTest() {
dashboard.selectWorkspacesItemOnDashboard();
dashboard.waitToolbarTitleName("Workspaces");
workspaces.selectWorkspaceItemName(workspaceName);
workspaceDetails.waitToolbarTitleName(workspaceName);
workspaces.clickOnWorkspaceStopStartButton(WORKSPACE_NAME);
workspaces.waitWorkspaceStatus(WORKSPACE_NAME, Status.RUNNING);
workspaces.selectWorkspaceItemName(WORKSPACE_NAME);
workspaceDetails.waitToolbarTitleName(WORKSPACE_NAME);
workspaceDetails.selectTabInWorkspaceMenu(OVERVIEW);
workspaceDetails.checkStateOfWorkspace(RUNNING);
workspaceDetails.clickOnStopWorkspace();
workspaceDetails.checkStateOfWorkspace(STOPPED);
workspaceOverview.clickOnDeleteWorkspace();
workspaceDetails.clickOnDeleteButtonInDialogWindow();
workspaces.waitWorkspaceIsNotPresent(workspaceName);
workspaces.waitWorkspaceIsNotPresent(WORKSPACE_NAME);
dashboard.waitToolbarTitleName("Workspaces");
}
}

View File

@ -1,120 +0,0 @@
/*
* Copyright (c) 2012-2018 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.che.selenium.dashboard;
import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.testng.Assert.assertTrue;
import com.google.inject.Inject;
import org.eclipse.che.selenium.core.client.TestFactoryServiceClient;
import org.eclipse.che.selenium.core.factory.FactoryTemplate;
import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.DashboardFactories;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class FactoriesListTest {
private static final String FACTORY1_NAME = generate("factory1", 4);
private static final String FACTORY2_NAME = generate("factory2", 4);
private static final String FACTORY3_NAME = generate("factory3", 4);
@Inject private TestFactoryServiceClient factoryServiceClient;
@Inject private TestFactoryInitializer testFactoryInitializer;
@Inject private DashboardFactories dashboardFactories;
@Inject private Dashboard dashboard;
@BeforeClass
public void setUp() throws Exception {
createFactoryByApi(FACTORY1_NAME);
createFactoryByApi(FACTORY2_NAME);
createFactoryByApi(FACTORY3_NAME);
dashboard.open();
}
@AfterClass
public void tearDown() throws Exception {
factoryServiceClient.deleteFactory(FACTORY1_NAME);
factoryServiceClient.deleteFactory(FACTORY2_NAME);
factoryServiceClient.deleteFactory(FACTORY3_NAME);
}
@Test
public void checkAllFactoriesPage() {
dashboardFactories.selectFactoriesOnNavBar();
dashboardFactories.waitAllFactoriesPage();
dashboardFactories.waitBulkCheckbox();
dashboardFactories.waitFactoryName(FACTORY1_NAME);
dashboardFactories.waitAddFactoryBtn();
// check selecting factories by Bulk
dashboardFactories.selectAllFactoriesByBulk();
assertTrue(dashboardFactories.isFactoryChecked(FACTORY1_NAME));
assertTrue(dashboardFactories.isFactoryChecked(FACTORY2_NAME));
dashboardFactories.selectAllFactoriesByBulk();
Assert.assertFalse(dashboardFactories.isFactoryChecked(FACTORY1_NAME));
Assert.assertFalse(dashboardFactories.isFactoryChecked(FACTORY2_NAME));
// check selecting factories by checkbox
dashboardFactories.selectFactoryByCheckbox(FACTORY1_NAME);
assertTrue(dashboardFactories.isFactoryChecked(FACTORY1_NAME));
dashboardFactories.selectFactoryByCheckbox(FACTORY1_NAME);
Assert.assertFalse(dashboardFactories.isFactoryChecked(FACTORY1_NAME));
}
@Test
public void checkFactoriesFiltering() {
dashboardFactories.selectFactoriesOnNavBar();
dashboardFactories.waitAllFactoriesPage();
dashboardFactories.waitSearchFactoryByNameField();
// filter the list by a full factory name
dashboardFactories.typeToSearchInput(FACTORY1_NAME);
dashboardFactories.waitFactoryName(FACTORY1_NAME);
dashboardFactories.waitFactoryNotExists(FACTORY2_NAME);
// filter the list by a part factory name
dashboardFactories.typeToSearchInput("factory");
dashboardFactories.waitFactoryName(FACTORY1_NAME);
dashboardFactories.waitFactoryName(FACTORY2_NAME);
// filter the list by a nonexistent factory name
dashboardFactories.typeToSearchInput(generate("", 20));
dashboardFactories.waitFactoryNotExists(FACTORY1_NAME);
dashboardFactories.waitFactoryNotExists(FACTORY2_NAME);
}
@Test
public void checkFactoriesDeleting() {
dashboardFactories.selectFactoriesOnNavBar();
dashboardFactories.waitAllFactoriesPage();
// delete factory selected by checkbox
dashboardFactories.selectFactoryByCheckbox(FACTORY3_NAME);
assertTrue(dashboardFactories.isFactoryChecked(FACTORY3_NAME));
dashboardFactories.clickOnDeleteFactoryBtn();
dashboardFactories.clickOnDeleteButtonInDialogWindow();
dashboardFactories.waitFactoryNotExists(FACTORY3_NAME);
}
private void createFactoryByApi(String factoryName) throws Exception {
TestFactoryInitializer.TestFactoryBuilder factoryBuilder =
testFactoryInitializer.fromTemplate(FactoryTemplate.MINIMAL);
factoryBuilder.setName(factoryName);
factoryBuilder.build();
}
}

View File

@ -12,18 +12,18 @@
package org.eclipse.che.selenium.dashboard;
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.pageobject.dashboard.workspaces.WorkspaceDetails.WorkspaceDetailsTab.OVERVIEW;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Status.STOPPED;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import com.google.inject.Inject;
import java.io.IOException;
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.core.workspace.TestWorkspace;
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;
@ -32,14 +32,14 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/** @author Andrey Chizhikov */
/** TODO rewrite to use che7 workspace */
@Test(groups = UNDER_REPAIR)
public class RenameWorkspaceTest {
private static final int MIN_WORKSPACE_NAME_SIZE = 3;
private static final int MAX_WORKSPACE_NAME_SIZE = 100;
private static final String MIN_WORKSPACE_NAME = generate("", MIN_WORKSPACE_NAME_SIZE);
private static final String MAX_WORKSPACE_NAME = generate("", MAX_WORKSPACE_NAME_SIZE);
private static final String WORKSPACE_NAME =
generate(RenameWorkspaceTest.class.getSimpleName(), 5);
private static final String WS_NAME_TOO_SHORT =
("The name has to be more than 3 characters long.");
private static final String WS_NAME_TOO_LONG =
@ -47,23 +47,22 @@ public class RenameWorkspaceTest {
@Inject private Dashboard dashboard;
@Inject private WorkspaceDetails workspaceDetails;
@Inject private TestWorkspace ws;
@Inject private DefaultTestUser user;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private Workspaces workspaces;
@Inject private WorkspaceOverview workspaceOverview;
private String workspaceName;
@Inject private CreateWorkspaceHelper createWorkspaceHelper;
@BeforeClass
public void setUp() throws Exception {
this.workspaceName = ws.getName();
dashboard.open();
createWorkspaceHelper.createAndEditWorkspaceFromStack(
Devfile.JAVA_MAVEN, WORKSPACE_NAME, Collections.emptyList(), null);
}
@AfterClass
public void tearDown() throws Exception {
workspaceServiceClient.delete(workspaceName, user.getName());
workspaceServiceClient.delete(WORKSPACE_NAME, user.getName());
workspaceServiceClient.delete(MIN_WORKSPACE_NAME, user.getName());
workspaceServiceClient.delete(MAX_WORKSPACE_NAME, user.getName());
}
@ -72,23 +71,21 @@ public class RenameWorkspaceTest {
public void renameNameWorkspaceTest() throws IOException {
dashboard.selectWorkspacesItemOnDashboard();
dashboard.waitToolbarTitleName("Workspaces");
workspaces.clickOnWorkspaceActionsButton(workspaceName);
workspaces.waitWorkspaceStatus(workspaceName, STOPPED);
workspaces.selectWorkspaceItemName(workspaceName);
workspaceDetails.waitToolbarTitleName(workspaceName);
workspaces.selectWorkspaceItemName(WORKSPACE_NAME);
workspaceDetails.waitToolbarTitleName(WORKSPACE_NAME);
workspaceDetails.selectTabInWorkspaceMenu(OVERVIEW);
// type name with 1 characters and check error message that this name is too short
workspaceOverview.enterNameWorkspace("w");
assertTrue(workspaceOverview.isWorkspaceNameErrorMessageEquals(WS_NAME_TOO_SHORT));
workspaceDetails.clickOnCancelChangesBtn();
workspaceOverview.checkNameWorkspace(workspaceName);
workspaceOverview.checkNameWorkspace(WORKSPACE_NAME);
// type name with 101 characters and check error message that this name is too long
workspaceOverview.enterNameWorkspace(MAX_WORKSPACE_NAME + "a");
assertTrue(workspaceOverview.isWorkspaceNameErrorMessageEquals(WS_NAME_TOO_LONG));
workspaceDetails.clickOnCancelChangesBtn();
workspaceOverview.checkNameWorkspace(workspaceName);
workspaceOverview.checkNameWorkspace(WORKSPACE_NAME);
// type a name with min possible size and check that the workspace renamed
renameWorkspace(MIN_WORKSPACE_NAME);

View File

@ -15,7 +15,6 @@ import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.pageobject.dashboard.NavigationBar.MenuItem.ORGANIZATIONS;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
import com.google.inject.Inject;
import org.eclipse.che.selenium.core.TestGroup;
@ -30,12 +29,11 @@ import org.eclipse.che.selenium.pageobject.dashboard.organization.OrganizationLi
import org.eclipse.che.selenium.pageobject.dashboard.organization.OrganizationPage;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails;
import org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces;
import org.openqa.selenium.TimeoutException;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = {TestGroup.MULTIUSER, TestGroup.UNDER_REPAIR, TestGroup.OPENSHIFT, TestGroup.K8S})
@Test(groups = {TestGroup.MULTIUSER, TestGroup.OPENSHIFT, TestGroup.K8S})
public class AddWorkspaceToOrganizationTest {
private static final String WORKSPACE_FOR_ADMIN_1 = generate("workspace", 4);
@ -150,14 +148,7 @@ public class AddWorkspaceToOrganizationTest {
organizationListPage.waitOrganizationInList(org2.getName());
organizationListPage.clickOnOrganization(org2.getName());
organizationPage.clickOnWorkspacesTab();
try {
workspaces.waitWorkspaceIsPresent(WORKSPACE_FOR_MEMBER_1);
} catch (TimeoutException ex) {
// remove try-catch block after issue has been resolved
fail("Known permanent failure https://github.com/eclipse/che/issues/13893");
}
workspaces.waitWorkspaceIsPresent(WORKSPACE_FOR_MEMBER_1);
workspaces.selectWorkspaceItemName(WORKSPACE_FOR_MEMBER_1);
workspaceDetails.waitToolbarTitleName(WORKSPACE_FOR_MEMBER_1);
}

View File

@ -12,28 +12,20 @@
package org.eclipse.che.selenium.dashboard.organization;
import static org.eclipse.che.commons.lang.NameGenerator.generate;
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.pageobject.dashboard.ProjectSourcePage.Template.CONSOLE_JAVA_SIMPLE;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.WorkspaceDetailsTab.OVERVIEW;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.WorkspaceDetails.WorkspaceDetailsTab.SHARE;
import static org.eclipse.che.selenium.pageobject.dashboard.workspaces.Workspaces.Status.STOPPED;
import static org.testng.Assert.assertEquals;
import com.google.inject.Inject;
import java.util.Collections;
import org.eclipse.che.selenium.core.TestGroup;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.organization.InjectTestOrganization;
import org.eclipse.che.selenium.core.organization.TestOrganization;
import org.eclipse.che.selenium.core.user.AdminTestUser;
import org.eclipse.che.selenium.core.user.TestUser;
import org.eclipse.che.selenium.pageobject.AskForValueDialog;
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.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.dashboard.CheMultiuserAdminDashboard;
import org.eclipse.che.selenium.pageobject.dashboard.CreateWorkspaceHelper;
import org.eclipse.che.selenium.pageobject.dashboard.NavigationBar;
@ -43,6 +35,9 @@ 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.WorkspaceShare;
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;
@ -54,32 +49,25 @@ public class ShareWorkspaceMemberTest {
private static final String ADMIN_PERMISSIONS =
"read, use, run, configure, setPermissions, delete";
private static final String MEMBER_PERMISSIONS = "read, use, run, configure";
private static final String PROJECT_NAME = "web-java-spring";
private static final String FILE_NAME = "readme.txt";
private static final String FILE_CONTENT = generate("", 10);
private String systemAdminName;
private String memberName;
@InjectTestOrganization private TestOrganization org;
@Inject private Ide ide;
@Inject private Menu menu;
@Inject private TestUser testUser;
@Inject private Consoles consoles;
@Inject private CodenvyEditor editor;
@Inject private Workspaces workspaces;
@Inject private NavigationBar navigationBar;
@Inject private AdminTestUser adminTestUser;
@Inject private WorkspaceShare workspaceShare;
@Inject private ProjectExplorer projectExplorer;
@Inject private WorkspaceDetails workspaceDetails;
@Inject private AskForValueDialog askForValueDialog;
@Inject private TheiaProjectTree theiaProjectTree;
@Inject private WorkspaceOverview workspaceOverview;
@Inject private CheMultiuserAdminDashboard dashboard;
@Inject private CreateWorkspaceHelper createWorkspaceHelper;
@Inject private NotificationsPopupPanel notificationsPopupPanel;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TheiaIde theiaIde;
@Inject private TheiaEditor theiaEditor;
@BeforeClass
public void setUp() throws Exception {
@ -89,7 +77,6 @@ public class ShareWorkspaceMemberTest {
memberName = testUser.getEmail();
dashboard.open(adminTestUser.getName(), adminTestUser.getPassword());
createWorkspace(WORKSPACE_NAME);
}
@AfterClass
@ -100,7 +87,8 @@ public class ShareWorkspaceMemberTest {
@Test
public void checkSharingByWorkspaceOwner() {
dashboard.open();
createWorkspace(WORKSPACE_NAME);
dashboard.open(adminTestUser.getName(), adminTestUser.getPassword());
dashboard.waitDashboardToolbarTitle();
dashboard.selectWorkspacesItemOnDashboard();
workspaces.selectWorkspaceItemName(WORKSPACE_NAME);
@ -146,14 +134,11 @@ public class ShareWorkspaceMemberTest {
// open workspace and check
workspaceDetails.clickOpenInIdeWsBtn();
ide.switchToIdeAndWaitWorkspaceIsReadyToUse();
notificationsPopupPanel.waitPopupPanelsAreClosed();
projectExplorer.waitAndSelectItem(PROJECT_NAME);
projectExplorer.openItemByPath(PROJECT_NAME);
projectExplorer.openItemByPath(PROJECT_NAME + "/" + FILE_NAME);
editor.waitActive();
editor.selectTabByName(FILE_NAME);
editor.waitTextIntoEditor(FILE_CONTENT);
theiaIde.switchToIdeFrame();
theiaIde.waitTheiaIde();
theiaIde.waitLoaderInvisibility();
theiaIde.waitTheiaIdeTopPanel();
theiaEditor.waitEditorTab("README.md");
// try to delete the workspace
dashboard.open();
@ -179,22 +164,20 @@ public class ShareWorkspaceMemberTest {
}
private void createWorkspace(String workspaceName) {
createWorkspaceHelper.createWorkspaceFromDevfileWithProject(
Devfile.JAVA_MAVEN, workspaceName, PROJECT_NAME);
createWorkspaceHelper.createAndStartWorkspaceFromStack(
Devfile.JAVA_MAVEN, workspaceName, Collections.emptyList(), null);
ide.switchToIdeAndWaitWorkspaceIsReadyToUse();
theiaIde.switchToIdeFrame();
theiaIde.waitTheiaIde();
theiaIde.waitLoaderInvisibility();
theiaIde.waitTheiaIdeTopPanel();
projectExplorer.waitProjectInitialization(PROJECT_NAME);
consoles.waitJDTLSProjectResolveFinishedMessage(PROJECT_NAME);
projectExplorer.waitAndSelectItem(PROJECT_NAME);
projectExplorer.openItemByPath(PROJECT_NAME);
menu.runCommand(PROJECT, NEW, FILE);
askForValueDialog.createNotJavaFileByName(FILE_NAME);
editor.waitActive();
editor.selectTabByName(FILE_NAME);
editor.typeTextIntoEditor(FILE_CONTENT);
editor.waitTabFileWithSavedStatus(FILE_NAME);
theiaProjectTree.waitFilesTab();
theiaProjectTree.clickOnFilesTab();
theiaIde.waitAllNotificationsClosed();
theiaProjectTree.waitItem(CONSOLE_JAVA_SIMPLE);
theiaProjectTree.expandItem(CONSOLE_JAVA_SIMPLE);
theiaProjectTree.openItem(CONSOLE_JAVA_SIMPLE + "/README.md");
theiaEditor.waitEditorTab("README.md");
}
}

View File

@ -12,28 +12,24 @@
package org.eclipse.che.selenium.dashboard.workspaces.details;
import static java.util.Arrays.asList;
import static org.eclipse.che.selenium.core.TestGroup.UNDER_REPAIR;
import static org.openqa.selenium.Keys.ESCAPE;
import com.google.inject.Inject;
import java.util.List;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.selenium.core.webdriver.SeleniumWebDriverHelper;
import org.eclipse.che.selenium.pageobject.dashboard.AddOrImportForm;
import org.eclipse.che.selenium.pageobject.dashboard.Dashboard;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace;
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.testng.annotations.Test;
/** TODO rewrite to use che7 workspace */
@Test(groups = UNDER_REPAIR)
public class WorkspaceDetailsOverviewTest {
private static final String WORKSPACE_NAME = NameGenerator.generate("test-workspace", 4);
private static final String CHANGED_WORKSPACE_NAME = NameGenerator.generate(WORKSPACE_NAME, 4);
private static final String MACHINE_NAME = "dev-machine";
private static final String SAMPLE_NAME = "console-java-simple";
private static final String TOO_SHORT_NAME = "wk";
private static final String MAX_LONG_NAME = NameGenerator.generate("wksp-", 95);
private static final String TOO_LONG_NAME = NameGenerator.generate(MAX_LONG_NAME, 1);
@ -49,61 +45,14 @@ public class WorkspaceDetailsOverviewTest {
private static final List<String> NOT_VALID_NAMES =
asList("wksp-", "-wksp", "wk sp", "wk_sp", "wksp@", "wksp$", "wksp&", "wksp*");
private static final String EXPECTED_ATTRIBUTES_CONFIG =
" \"default\": {\n"
+ " \"machines\": {\n"
+ " \"dev-machine\": {\n"
+ " \"attributes\": {\n"
+ " \"memoryLimitBytes\": \"2147483648\"\n"
+ " },\n"
+ " \"servers\": {\n"
+ " \"tomcat8-debug\": {\n"
+ " \"attributes\": {},\n"
+ " \"port\": \"8000\",\n"
+ " \"protocol\": \"http\"\n"
+ " },\n"
+ " \"codeserver\": {\n"
+ " \"attributes\": {},\n"
+ " \"port\": \"9876\",\n"
+ " \"protocol\": \"http\"\n"
+ " },\n"
+ " \"tomcat8\": {\n"
+ " \"attributes\": {},\n"
+ " \"port\": \"8080\",\n"
+ " \"protocol\": \"http\"\n"
+ " }\n"
+ " },\n"
+ " \"volumes\": {},\n"
+ " \"installers\": [\n"
+ " \"org.eclipse.che.exec\",\n"
+ " \"org.eclipse.che.terminal\",\n"
+ " \"org.eclipse.che.ws-agent\"\n"
+ " ],\n";
private static final String EXPECTED_IMAGE_CONFIG =
" \"recipe\": {\n"
+ " \"type\": \"dockerimage\",\n"
+ " \"content\": \"eclipse/ubuntu_jdk8\"\n"
+ " }\n";
private static final String EXPECTED_COMMAND_LINE_CONFIG =
" \"commands\": [\n"
+ " {\n"
+ " \"commandLine\": \"mvn clean install -f ${current.project.path}\",\n"
+ " \"name\": \"build\",\n"
+ " \"attributes\": {\n"
+ " \"goal\": \"Build\",\n"
+ " \"previewUrl\": \"\"\n"
+ " },\n"
+ " \"type\": \"mvn\"\n";
@Inject private Dashboard dashboard;
@Inject private NewWorkspace newWorkspace;
@Inject private Workspaces workspaces;
@Inject private AddOrImportForm addOrImportForm;
@Inject private WorkspaceOverview workspaceOverview;
@Inject private SeleniumWebDriverHelper seleniumWebDriverHelper;
@Inject private WorkspaceDetails workspaceDetails;
@Test
public void shouldCreateWorkspaceAndOpenOverviewPage() {
// prepare
@ -115,38 +64,15 @@ public class WorkspaceDetailsOverviewTest {
newWorkspace.waitPageLoad();
newWorkspace.typeWorkspaceName(WORKSPACE_NAME);
selectDevfileAndCheckWorkspaceName(Devfile.APACHE_CAMEL);
selectDevfileAndCheckWorkspaceName(Devfile.JAVA_MAVEN);
selectDevfileAndCheckWorkspaceName(Devfile.JAVA_GRADLE);
// create workspace
addOrImportForm.clickOnAddOrImportProjectButton();
addOrImportForm.addSampleToWorkspace(SAMPLE_NAME);
newWorkspace.clickOnCreateButtonAndEditWorkspace();
workspaceOverview.checkNameWorkspace(WORKSPACE_NAME);
}
@Test(priority = 2)
public void shouldCheckNameField() {
workspaceOverview.waitNameFieldValue(WORKSPACE_NAME);
// check of empty name
workspaceOverview.enterNameWorkspace("");
workspaceOverview.waitErrorBorderOfNameField();
workspaceOverview.waitDisabledSaveButton();
// check too short name
nameShouldBeValid(CHANGED_WORKSPACE_NAME);
nameShouldBeInvalid(TOO_SHORT_NAME, SHORT_NAME_ERROR_MESSAGE);
// check too long name
nameShouldBeValid(MIN_SHORT_NAME);
nameShouldBeInvalid(TOO_LONG_NAME, LONG_NAME_ERROR_MESSAGE);
nameShouldBeValid(MAX_LONG_NAME);
namesShouldBeValid();
}
@Test(priority = 1)
public void shouldCheckExportAsFile() {
workspaceOverview.checkNameWorkspace(WORKSPACE_NAME);
@ -168,14 +94,33 @@ public class WorkspaceDetailsOverviewTest {
// check config
openExportWorkspaceForm();
workspaceOverview.waitConfiguration(
EXPECTED_ATTRIBUTES_CONFIG, EXPECTED_COMMAND_LINE_CONFIG, EXPECTED_IMAGE_CONFIG);
workspaceOverview.clickOnToPrivateCloudButton();
workspaceOverview.waitToPrivateCloudTabOpened();
seleniumWebDriverHelper.sendKeys(ESCAPE.toString());
workspaceOverview.waitExportWorkspaceFormClosed();
}
@Test(priority = 2)
public void shouldCheckNameField() {
workspaceOverview.waitNameFieldValue(WORKSPACE_NAME);
// check of empty name
workspaceOverview.enterNameWorkspace("");
workspaceOverview.waitErrorBorderOfNameField();
workspaceOverview.waitDisabledSaveButton();
// check too short name
nameShouldBeValid(CHANGED_WORKSPACE_NAME);
nameShouldBeInvalid(TOO_SHORT_NAME, SHORT_NAME_ERROR_MESSAGE);
// check too long name
nameShouldBeValid(MIN_SHORT_NAME);
nameShouldBeInvalid(TOO_LONG_NAME, LONG_NAME_ERROR_MESSAGE);
nameShouldBeValid(MAX_LONG_NAME);
namesShouldBeValid();
}
private void selectDevfileAndCheckWorkspaceName(Devfile devfile) {
newWorkspace.selectDevfile(devfile);
newWorkspace.waitDevfileSelected(devfile);

View File

@ -77,6 +77,7 @@ public class DirectUrlFactoryWithKeepDirectoryTest {
theiaProjectTree.waitFilesTab();
theiaProjectTree.clickOnFilesTab();
theiaProjectTree.waitProjectsRootItem();
theiaIde.waitAllNotificationsClosed();
theiaProjectTree.waitItem(repositoryName);
theiaProjectTree.openItem(repositoryName + "/my-lib");

View File

@ -96,6 +96,7 @@ public class DirectUrlFactoryWithRootFolderTest {
theiaProjectTree.waitFilesTab();
theiaProjectTree.clickOnFilesTab();
theiaProjectTree.waitItem(repositoryName);
theiaIde.waitAllNotificationsClosed();
theiaProjectTree.expandItem(repositoryName);
expectedItemsAfterCloning.forEach(

View File

@ -95,8 +95,8 @@ public class DirectUrlFactoryWithSpecificBranchTest {
theiaProjectTree.waitFilesTab();
theiaProjectTree.clickOnFilesTab();
theiaProjectTree.waitItem(repositoryName);
theiaIde.waitAllNotificationsClosed();
theiaProjectTree.expandItem(repositoryName);
theiaProjectTree.expandItem(repositoryName + "/my-lib");
theiaProjectTree.waitItem(repositoryName + "/my-lib/src");

View File

@ -30,6 +30,7 @@
<class name="org.eclipse.che.selenium.dashboard.organization.OrganizationMembersTest"/>
<class name="org.eclipse.che.selenium.dashboard.organization.RenameOrganizationTest"/>
<class name="org.eclipse.che.selenium.dashboard.organization.ShareWorkspaceOwnerTest"/>
<class name="org.eclipse.che.selenium.dashboard.organization.ShareWorkspaceMemberTest"/>
<class name="org.eclipse.che.selenium.dashboard.organization.SystemAdminOrganizationTest"/>
<class name="org.eclipse.che.selenium.git.AuthorizeOnGithubFromDashboardTest"/>
<class name="org.eclipse.che.selenium.dashboard.ImportProjectFromGitHubTest"/>

View File

@ -27,8 +27,6 @@
<class name="org.eclipse.che.selenium.dashboard.workspaces.details.WorkspaceDetailsProjectsTest"/>
<class name="org.eclipse.che.selenium.dashboard.RenameWorkspaceTest"/>
<class name="org.eclipse.che.selenium.dashboard.CreateWorkspaceTest"/>
<class name="org.eclipse.che.selenium.dashboard.CreateFactoryTest"/>
<class name="org.eclipse.che.selenium.dashboard.FactoriesListTest"/>
<class name="org.eclipse.che.selenium.dashboard.workspaces.NewWorkspacePageTest"/>
<class name="org.eclipse.che.selenium.dashboard.organization.UserEmptyOrganizationTest"/>
<class name="org.eclipse.che.selenium.factory.DirectUrlFactoryWithRootFolderTest"/>