Selenium: Add new test method to the 'PullRequestPluginTest' (#11128)

* Add new test method 'createPullRequestToNonDefaultBranch' to the 'PullRequestPlaginTest'
* Add the method 'clickRefreshContributionBranchButton()' to the 'PullRequestPanel'
* Add the id selector to the web element in the 'ContributePartViewImpl'
* Delete the 'try/catch' from the 'PullRequestPluginWithForkTest' related to close the issue
* Read test pull request info by using kohsuke library
* Ensure 'Git Contribute' preference is set to default value after the test execution

Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
6.19.x
Aleksandr Shmaraiev 2018-10-01 16:21:33 +00:00 committed by Dmytro Nochevnov
parent 89041db8d1
commit e5ca2e8298
19 changed files with 387 additions and 247 deletions

View File

@ -142,6 +142,7 @@ public class ContributePartViewImpl extends BaseView<ContributePartView.ActionDe
.getStyle()
.setProperty("fill", "#dbdbdb");
this.refreshContributionBranchNameListButton.ensureDebugId("refreshContributionBranchButton");
this.statusSection.setVisible(false);
this.newContributionSection.setVisible(false);
this.contributionTitle

View File

@ -430,4 +430,24 @@ public class TestGitHubRepository {
ghRepo.createContent(submoduleConfig, "Add " + gitmodulesFileName, gitmodulesFileName);
}
public String getPullRequestTitle(int requestNumber) throws IOException {
return ghRepo.getPullRequest(requestNumber).getTitle();
}
public String getPullRequestBaseBranchName(int requestNumber) throws IOException {
return ghRepo.getPullRequest(requestNumber).getBase().getRef();
}
public String getPullRequestHeadBranchName(int requestNumber) throws IOException {
return ghRepo.getPullRequest(requestNumber).getHead().getRef();
}
public String getPullRequestBody(int requestNumber) throws IOException {
return ghRepo.getPullRequest(requestNumber).getBody();
}
public String getPullRequestUserName(int requestNumber) throws IOException {
return ghRepo.getPullRequest(requestNumber).getUser().getLogin();
}
}

View File

@ -11,9 +11,17 @@
*/
package org.eclipse.che.selenium.core.client;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import org.eclipse.che.api.core.BadRequestException;
import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.UnauthorizedException;
import org.eclipse.che.api.core.rest.HttpJsonRequestFactory;
import org.eclipse.che.selenium.core.provider.TestApiEndpointUrlProvider;
@ -21,6 +29,8 @@ import org.eclipse.che.selenium.core.provider.TestApiEndpointUrlProvider;
@Singleton
public class TestUserPreferencesServiceClient {
private static final String ACTIVATE_CONTRIBUTION_TAB_BY_PROJECT_SELECTION_PROPERTY =
"git.contribute.activate.projectSelection";
private final String apiEndpoint;
private final HttpJsonRequestFactory httpRequestFactory;
@ -49,4 +59,14 @@ public class TestUserPreferencesServiceClient {
.request()
.asString();
}
public void restoreDefaultContributionTabPreference()
throws ForbiddenException, BadRequestException, IOException, ConflictException,
NotFoundException, ServerException, UnauthorizedException {
httpRequestFactory
.fromUrl(apiEndpoint + "preferences")
.useDeleteMethod()
.setBody(ImmutableList.of(ACTIVATE_CONTRIBUTION_TAB_BY_PROJECT_SELECTION_PROPERTY))
.request();
}
}

View File

@ -13,11 +13,13 @@ package org.eclipse.che.selenium.pageobject;
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Profile.PREFERENCES;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Profile.PROFILE_MENU;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ATTACHING_ELEM_TO_DOM_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.ELEMENT_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.WIDGET_TIMEOUT_SEC;
import static org.eclipse.che.selenium.pageobject.Preferences.DropDownGitInformationMenu.CONTRIBUTE_PREFERENCES;
import static org.eclipse.che.selenium.pageobject.Preferences.Locators.EDITOR_CHECKBOX_SPAN_XPATH;
import static org.eclipse.che.selenium.pageobject.Preferences.Locators.EDITOR_INPUT;
import static org.eclipse.che.selenium.pageobject.Preferences.Locators.ERRORS_WARNINGS_RADIO_BUTTON;
@ -27,12 +29,7 @@ import static org.eclipse.che.selenium.pageobject.Preferences.Locators.SSH_DELET
import static org.openqa.selenium.Keys.ALT;
import static org.openqa.selenium.Keys.COMMAND;
import static org.openqa.selenium.Keys.CONTROL;
import static org.openqa.selenium.support.ui.ExpectedConditions.invisibilityOfElementLocated;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfAllElementsLocatedBy;
import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOf;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfAllElementsLocatedBy;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@ -49,10 +46,8 @@ import org.openqa.selenium.Keys;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -67,8 +62,9 @@ public class Preferences {
private final AskDialog askDialog;
private final AskForValueDialog askForValueDialog;
private final GitHub gitHub;
private final Menu menu;
private final SeleniumWebDriver seleniumWebDriver;
private final SeleniumWebDriverHelper webDriverHelper;
private final SeleniumWebDriverHelper seleniumWebDriverHelper;
@Inject
public Preferences(
@ -78,14 +74,16 @@ public class Preferences {
AskDialog askDialog,
AskForValueDialog askForValueDialog,
GitHub github,
SeleniumWebDriverHelper webDriverHelper) {
Menu menu,
SeleniumWebDriverHelper seleniumWebDriverHelper) {
this.seleniumWebDriver = seleniumWebDriver;
this.loader = loader;
this.actionsFactory = actionsFactory;
this.askDialog = askDialog;
this.askForValueDialog = askForValueDialog;
this.gitHub = github;
this.webDriverHelper = webDriverHelper;
this.menu = menu;
this.seleniumWebDriverHelper = seleniumWebDriverHelper;
PageFactory.initElements(seleniumWebDriver, this);
}
@ -236,26 +234,23 @@ public class Preferences {
/** wait preferences form */
public void waitPreferencesForm() {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(visibilityOf(preferencesForm));
seleniumWebDriverHelper.waitVisibility(preferencesForm);
}
/** wait closing of the preferences form */
public void waitPreferencesFormIsClosed() {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(invisibilityOfElementLocated(By.id(Locators.PREFERENCES_FORM_ID)));
seleniumWebDriverHelper.waitInvisibility(By.id(Locators.PREFERENCES_FORM_ID));
}
/**
* wait appears dropdawn-header with specified mame
* wait appears dropdown-header with specified mame
*
* @param nameMenu name of header (all names describe in public interface )
*/
public void waitDropDownHeaderMenu(String nameMenu) {
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(
visibilityOfAllElementsLocatedBy(
By.xpath(format(Locators.DROP_DOWN_HEADER_XPATH_WITH_PARAM, nameMenu))));
seleniumWebDriverHelper.waitVisibilityOfAllElements(
By.xpath(format(Locators.DROP_DOWN_HEADER_XPATH_WITH_PARAM, nameMenu)),
ELEMENT_TIMEOUT_SEC);
}
/**
@ -264,10 +259,8 @@ public class Preferences {
* @param menu (all menus describe in public interface )
*/
public void waitMenuInCollapsedDropdown(String menu) {
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(
visibilityOfAllElementsLocatedBy(
By.xpath(format(MENU_IN_EXPANDED_DROPDOWN_XPATH_WITH_PARAM, menu))));
seleniumWebDriverHelper.waitVisibilityOfAllElements(
By.xpath(format(MENU_IN_EXPANDED_DROPDOWN_XPATH_WITH_PARAM, menu)), ELEMENT_TIMEOUT_SEC);
}
/**
@ -278,14 +271,13 @@ public class Preferences {
public void selectDroppedMenuByName(String nameMenu) {
loader.waitOnClosed();
waitMenuInCollapsedDropdown(nameMenu);
seleniumWebDriver
.findElement(By.xpath(format(MENU_IN_EXPANDED_DROPDOWN_XPATH_WITH_PARAM, nameMenu)))
.click();
seleniumWebDriverHelper.waitAndClick(
By.xpath(format(MENU_IN_EXPANDED_DROPDOWN_XPATH_WITH_PARAM, nameMenu)));
}
/** wait ok button click and wait closing the form */
public void clickOnOkBtn() {
webDriverHelper.waitAndClick(saveBtn);
seleniumWebDriverHelper.waitAndClick(saveBtn);
loader.waitOnClosed();
}
@ -295,7 +287,7 @@ public class Preferences {
* @return true if the form is opened
*/
public boolean isPreferencesFormOpened() {
return webDriverHelper.isVisible(closeBtn);
return seleniumWebDriverHelper.isVisible(closeBtn);
}
/**
@ -304,57 +296,69 @@ public class Preferences {
* @return true if the button is enabled
*/
public boolean isSaveButtonIsEnabled() {
return webDriverHelper.waitVisibilityAndGetEnableState(saveBtn);
return seleniumWebDriverHelper.waitVisibilityAndGetEnableState(saveBtn);
}
/** wait and click on the 'Refresh' button */
public void clickRefreshButton() {
webDriverHelper.waitAndClick(refreshBtn);
seleniumWebDriverHelper.waitAndClick(refreshBtn);
}
/** click on the 'Close' button */
public void clickOnCloseButton() {
webDriverHelper.waitAndClick(closeBtn);
seleniumWebDriverHelper.waitAndClick(closeBtn);
}
/** click on the 'Close' button and wait closing the form */
public void closeForm() {
webDriverHelper.waitAndClick(closeBtn);
public void close() {
seleniumWebDriverHelper.waitAndClick(closeBtn);
waitPreferencesFormIsClosed();
}
public void clickOnGenerateKeyButton() {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(visibilityOf(generateKeyBtn))
.click();
seleniumWebDriverHelper.waitAndClick(generateKeyBtn);
}
public void clickOnAddSchemaUrlButton() {
webDriverHelper.waitAndClick(addSchemaUrlButton);
seleniumWebDriverHelper.waitAndClick(addSchemaUrlButton);
}
public void addSchemaUrl(String schemaName) {
webDriverHelper.waitVisibility(addSchemaUrlInput);
seleniumWebDriverHelper.waitVisibility(addSchemaUrlInput);
addSchemaUrlInput.sendKeys(schemaName);
webDriverHelper.waitAndClick(By.id("askValue-dialog-ok"));
seleniumWebDriverHelper.waitAndClick(By.id("askValue-dialog-ok"));
}
public void deleteSchema() {
webDriverHelper.waitAndClick(deleteSchemaButton);
seleniumWebDriverHelper.waitAndClick(deleteSchemaButton);
askDialog.clickOkBtn();
askDialog.waitFormToClose();
}
public void setStateContributeChecboxAndCloseForm(boolean state) {
setContributeCheckbox(state);
clickOnOkBtn();
close();
}
public void openContributeTab() {
open();
waitMenuInCollapsedDropdown(CONTRIBUTE_PREFERENCES);
selectDroppedMenuByName(CONTRIBUTE_PREFERENCES);
}
public void open() {
menu.runCommand(PROFILE_MENU, PREFERENCES);
waitPreferencesForm();
}
public void clickOnGenerateAndUploadToGitHub() {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(visibilityOf(generateAndUploadBtn))
.click();
seleniumWebDriverHelper.waitAndClick(generateAndUploadBtn);
}
public boolean isSshKeyIsPresent(String host) {
try {
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(presenceOfElementLocated(By.xpath(Locators.SSH_KEYS_TABLE)));
seleniumWebDriverHelper.waitPresence(By.xpath(Locators.SSH_KEYS_TABLE), ELEMENT_TIMEOUT_SEC);
return sshKeysTable.getText().contains(host);
} catch (TimeoutException e) {
return false;
@ -363,24 +367,16 @@ public class Preferences {
// timeout is changed to 40 sec, is related to running tests on ocp platform
public void waitSshKeyIsPresent(final String host) {
new WebDriverWait(seleniumWebDriver, WIDGET_TIMEOUT_SEC)
.until((ExpectedCondition<Boolean>) driver -> isSshKeyIsPresent(host));
seleniumWebDriverHelper.waitSuccessCondition(
driver -> isSshKeyIsPresent(host), WIDGET_TIMEOUT_SEC);
}
public void deleteSshKeyByHost(String host) {
WebElement element =
seleniumWebDriver.findElement(
By.xpath("//div[text()='" + host + "']" + SSH_DELETE_BUTTON_FOR_HOST));
try {
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(visibilityOf(element))
.click();
} catch (StaleElementReferenceException e) {
WaitUtils.sleepQuietly(2);
new WebDriverWait(seleniumWebDriver, ELEMENT_TIMEOUT_SEC)
.until(visibilityOf(element))
.click();
}
String deleteButtonXPath = "//div[text()='" + host + "']" + SSH_DELETE_BUTTON_FOR_HOST;
seleniumWebDriverHelper.waitNoExceptions(
() -> seleniumWebDriverHelper.waitAndClick(By.xpath(deleteButtonXPath)),
WIDGET_TIMEOUT_SEC,
StaleElementReferenceException.class);
askDialog.clickOkBtn();
askDialog.waitFormToClose();
@ -402,10 +398,9 @@ public class Preferences {
* @param nameCommitter is a name of the committer
*/
public void waitInputNameCommitter(final String nameCommitter) {
new WebDriverWait(seleniumWebDriver, ATTACHING_ELEM_TO_DOM_SEC)
.until(
(ExpectedCondition<Boolean>)
webDriver -> nameCommitterInput.getAttribute("value").contains(nameCommitter));
seleniumWebDriverHelper.waitSuccessCondition(
webDriver -> nameCommitterInput.getAttribute("value").contains(nameCommitter),
ATTACHING_ELEM_TO_DOM_SEC);
}
/**
@ -434,10 +429,9 @@ public class Preferences {
* @param emailCommitter is an email of the committer
*/
public void waitInputEmailCommitter(final String emailCommitter) {
new WebDriverWait(seleniumWebDriver, ATTACHING_ELEM_TO_DOM_SEC)
.until(
(ExpectedCondition<Boolean>)
webDriver -> emailCommitterInput.getAttribute("value").contains(emailCommitter));
seleniumWebDriverHelper.waitSuccessCondition(
webDriver -> emailCommitterInput.getAttribute("value").contains(emailCommitter),
ATTACHING_ELEM_TO_DOM_SEC);
}
/**
@ -452,22 +446,23 @@ public class Preferences {
/** clicks on the 'Contribute' checkbox */
public void clickOnContributeCheckbox() {
webDriverHelper.waitAndClick(setContributeCheckbox);
seleniumWebDriverHelper.waitAndClick(setContributeCheckbox);
}
/** call the 'Contribute' by hot key */
public void callContributeActionByHotKey() {
webDriverHelper.sendKeys(Keys.chord(CONTROL, PlatformUtils.isMac() ? COMMAND : ALT, "6"));
seleniumWebDriverHelper.sendKeys(
Keys.chord(CONTROL, PlatformUtils.isMac() ? COMMAND : ALT, "6"));
}
/** wait the 'Contribute' checkbox is selected */
public void waitContributeCheckboxIsSelected() {
webDriverHelper.waitElementIsSelected(showContributeCheckbox);
seleniumWebDriverHelper.waitElementIsSelected(showContributeCheckbox);
}
/** wait the 'Contribute' checkbox is not selected */
public void waitContributeCheckboxIsNotSelected() {
webDriverHelper.waitElementIsNotSelected(showContributeCheckbox);
seleniumWebDriverHelper.waitElementIsNotSelected(showContributeCheckbox);
}
/**
@ -476,7 +471,8 @@ public class Preferences {
* @param state state of checkbox (true if checkbox must be selected)
*/
public void setContributeCheckbox(boolean state) {
webDriverHelper.waitAndSetCheckbox(showContributeCheckbox, setContributeCheckbox, state);
seleniumWebDriverHelper.waitAndSetCheckbox(
showContributeCheckbox, setContributeCheckbox, state);
}
/**
@ -485,12 +481,12 @@ public class Preferences {
* @return list of items
*/
public List<String> getItemsFromErrorWarningsWidget() {
String errorWarnings =
seleniumWebDriverHelper.waitVisibilityAndGetText(
errorsWarningsTab, REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
List<String> itemList =
asList(
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOf(errorsWarningsTab))
.getText()
.split("((\n)(warning|ignore|error)(\n))|((\n)(warning|ignore|error))"));
errorWarnings.split("((\n)(warning|ignore|error)(\n))|((\n)(warning|ignore|error))"));
return itemList;
}
@ -504,26 +500,23 @@ public class Preferences {
for (String settingsText : getItemsFromErrorWarningsWidget()) {
List<WebElement> dropDownList =
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
presenceOfAllElementsLocatedBy(
By.xpath(format(ERRORS_WARNINGS_RADIO_BUTTON, settingsText))));
seleniumWebDriverHelper.waitPresenceOfAllElements(
By.xpath(format(ERRORS_WARNINGS_RADIO_BUTTON, settingsText)),
REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
visibilityOfElementLocated(
By.xpath(format(ERRORS_WARNINGS_RADIO_BUTTON_BLOCK, settingsText))))
.click();
seleniumWebDriverHelper.waitAndClick(
By.xpath(format(ERRORS_WARNINGS_RADIO_BUTTON_BLOCK, settingsText)),
REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
switch (valueOfDropDown) {
case IGNORE:
webDriverHelper.waitAndClick(dropDownList.get(0));
seleniumWebDriverHelper.waitAndClick(dropDownList.get(0));
break;
case WARNING:
webDriverHelper.waitAndClick(dropDownList.get(1));
seleniumWebDriverHelper.waitAndClick(dropDownList.get(1));
break;
default:
webDriverHelper.waitAndClick(dropDownList.get(2));
seleniumWebDriverHelper.waitAndClick(dropDownList.get(2));
break;
}
}
@ -539,9 +532,8 @@ public class Preferences {
List<String> settingList =
new ArrayList<>(
asList(
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOf(editorProperties))
.getText()
seleniumWebDriverHelper
.waitVisibilityAndGetText(editorProperties, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.split("\n")));
settingList.removeAll(asList(headerSettings));
return settingList;
@ -556,18 +548,16 @@ public class Preferences {
public void setAllCheckboxSettingsInEditorWidget(
FlagForEditorWidget valueOfFlag, List<String> settingsList) {
for (String settingsItem : settingsList) {
if (new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(presenceOfElementLocated(By.xpath(format(EDITOR_INPUT, settingsItem))))
.getAttribute("type")
if (seleniumWebDriverHelper
.waitVisibilityAndGetAttribute(
By.xpath(format(EDITOR_INPUT, settingsItem)), "type", REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.equals("checkbox")) {
WebElement checkbox =
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(presenceOfElementLocated(By.xpath(format(EDITOR_INPUT, settingsItem))));
seleniumWebDriverHelper.waitPresence(By.xpath(format(EDITOR_INPUT, settingsItem)));
WebElement spanCheckbox =
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
presenceOfElementLocated(
By.xpath(format(EDITOR_CHECKBOX_SPAN_XPATH, settingsItem))));
seleniumWebDriverHelper.waitPresence(
By.xpath(format(EDITOR_CHECKBOX_SPAN_XPATH, settingsItem)),
REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
switch (valueOfFlag) {
case CHECK:
if (!checkbox.isSelected()) {
@ -595,27 +585,22 @@ public class Preferences {
public void uploadPrivateSshKey(String host, String filePath) {
File file = new File(filePath);
LOG.info("Absolute path to private SSH key: {}", file.getAbsolutePath());
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(Locators.SSH_UPLOAD_KEY)))
.click();
seleniumWebDriverHelper.waitAndClick(By.xpath(Locators.SSH_UPLOAD_KEY));
WebElement hostInput =
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(UploadSSHKey.HOST_INPUT)));
seleniumWebDriverHelper.waitVisibility(
By.xpath(UploadSSHKey.HOST_INPUT), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
hostInput.clear();
hostInput.sendKeys(host);
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(UploadSSHKey.FILE_INPUT)))
.sendKeys(file.getAbsolutePath());
seleniumWebDriverHelper.waitAndSendKeysTo(
By.xpath(UploadSSHKey.FILE_INPUT), file.getAbsolutePath(), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
WaitUtils.sleepQuietly(3);
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(UploadSSHKey.UPLOAD_BUTTON)))
.click();
seleniumWebDriverHelper.waitAndClick(
By.xpath(UploadSSHKey.UPLOAD_BUTTON), REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
}
/** wait appearance of the Generate SSH key widget */
public void waitGenerateSshWidget() {
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOf(genrateSShKeyWidget));
seleniumWebDriverHelper.waitVisibility(genrateSShKeyWidget, REDRAW_UI_ELEMENTS_TIMEOUT_SEC);
}
/**
@ -651,8 +636,7 @@ public class Preferences {
waitSshKeyIsPresent(titleOfKey);
}
public void generateAndUploadSshKeyOnGithub(String githubUsername, String githubPassword)
throws Exception {
public void generateAndUploadSshKeyOnGithub(String githubUsername, String githubPassword) {
waitMenuInCollapsedDropdown(Preferences.DropDownSshKeysMenu.VCS);
selectDroppedMenuByName(Preferences.DropDownSshKeysMenu.VCS);
@ -672,7 +656,7 @@ public class Preferences {
// check if github key has been uploaded without authorization on github.com
if (isSshKeyIsPresent(GITHUB_COM)) {
closeForm();
close();
waitPreferencesFormIsClosed();
return;
}
@ -681,7 +665,7 @@ public class Preferences {
askDialog.waitFormToOpen(25);
askDialog.clickOkBtn();
askDialog.waitFormToClose();
webDriverHelper.switchToNextWindow(ideWin);
seleniumWebDriverHelper.switchToNextWindow(ideWin);
gitHub.waitAuthorizationPageOpened();
gitHub.typeLogin(githubUsername);
@ -702,12 +686,11 @@ public class Preferences {
loader.waitOnClosed();
waitSshKeyIsPresent(GITHUB_COM);
loader.waitOnClosed();
closeForm();
close();
waitPreferencesFormIsClosed();
}
public void clickOnShowArtifactCheckBox() {
Actions actions = new Actions(seleniumWebDriver);
actions.click(showArtifactCheckBox).build().perform();
seleniumWebDriverHelper.getAction().click(showArtifactCheckBox).perform();
}
}

View File

@ -64,6 +64,7 @@ public class PullRequestPanel {
static final String PULL_REQUEST_BTN = "gwt-debug-partButton-Pull Request";
static final String BRANCH_NAME =
"//div[text()='Branch name:']/following-sibling::div//span/label[text()='%s']";
static final String REFRESH_BRANCH_BUTTON = "gwt-debug-refreshContributionBranchButton";
static final String OK_COMMIT_BTN = "commit-dialog-ok";
static final String STATUS_OK = "//div[text()='%s']/parent::div//i[@class='fa fa-check']";
static final String MESSAGE = "gwt-debug-statusSectionMessage";
@ -132,6 +133,9 @@ public class PullRequestPanel {
@FindBy(id = PullRequestLocators.CONTEXT_HIDE_BUTTON_ID)
WebElement contextHideButton;
@FindBy(id = PullRequestLocators.REFRESH_BRANCH_BUTTON)
WebElement refreshBranchListButton;
/** Wait that 'Pull Request' panel is open */
public void waitOpenPanel() {
seleniumWebDriverHelper.waitVisibility(panel);
@ -195,6 +199,11 @@ public class PullRequestPanel {
By.xpath(String.format(PullRequestLocators.BRANCH_NAME, branchName)));
}
/** Click 'refresh branch list' button on the 'Pull Request' panel */
public void clickRefreshBranchListButton() {
seleniumWebDriverHelper.waitAndClick(refreshBranchListButton);
}
/** Click 'Ok' button in the 'Commit your changes' window */
public void clickOkCommitBtn() {
seleniumWebDriverHelper.waitAndClick(okCommitBtn);

View File

@ -22,6 +22,7 @@ import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestUserPreferencesServiceClient;
import org.eclipse.che.selenium.core.factory.FactoryTemplate;
import org.eclipse.che.selenium.core.factory.TestFactory;
import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
@ -47,6 +48,7 @@ public class CheckFactoryWithMultiModuleTest {
@Inject private TestGitHubRepository testRepo;
@Inject private SeleniumWebDriver seleniumWebDriver;
@Inject private SeleniumWebDriverHelper seleniumWebDriverHelper;
@Inject private TestUserPreferencesServiceClient testUserPreferencesServiceClient;
private TestFactory testFactory;
@ -68,10 +70,15 @@ public class CheckFactoryWithMultiModuleTest {
}
@AfterClass
public void tearDown() throws Exception {
public void deleteTestFactory() throws Exception {
testFactory.delete();
}
@AfterClass
public void restoreContributionTabPreference() throws Exception {
testUserPreferencesServiceClient.restoreDefaultContributionTabPreference();
}
@Test
public void checkFactoryProcessing() {
dashboard.open();

View File

@ -18,6 +18,7 @@ import java.nio.file.Paths;
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
import org.eclipse.che.selenium.core.TestGroup;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestUserPreferencesServiceClient;
import org.eclipse.che.selenium.core.factory.FactoryTemplate;
import org.eclipse.che.selenium.core.factory.TestFactory;
import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
@ -38,6 +39,7 @@ public class CheckFactoryWithSparseCheckoutTest {
@Inject private PullRequestPanel pullRequestPanel;
@Inject private TestGitHubRepository testRepo;
@Inject private TestFactoryInitializer testFactoryInitializer;
@Inject private TestUserPreferencesServiceClient testUserPreferencesServiceClient;
private TestFactory testFactory;
@ -60,10 +62,15 @@ public class CheckFactoryWithSparseCheckoutTest {
}
@AfterClass
public void tearDown() throws Exception {
public void deleteTestFactory() throws Exception {
testFactory.delete();
}
@AfterClass
public void restoreContributionTabPreference() throws Exception {
testUserPreferencesServiceClient.restoreDefaultContributionTabPreference();
}
@Test
public void acceptFactoryWithSparseCheckout() {
testFactory.authenticateAndOpen();

View File

@ -26,6 +26,7 @@ import java.io.IOException;
import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestFactoryServiceClient;
import org.eclipse.che.selenium.core.client.TestUserPreferencesServiceClient;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.provider.TestIdeUrlProvider;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
@ -84,6 +85,7 @@ public class CreateFactoryFromUiWithKeepDirTest {
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestFactoryServiceClient factoryServiceClient;
@Inject private PullRequestPanel pullRequestPanel;
@Inject private TestUserPreferencesServiceClient testUserPreferencesServiceClient;
@BeforeClass
public void setUp() throws Exception {
@ -91,11 +93,16 @@ public class CreateFactoryFromUiWithKeepDirTest {
}
@AfterClass
public void tearDown() throws Exception {
public void deleteFactoryRelatedStaff() throws Exception {
workspaceServiceClient.deleteFactoryWorkspaces(testWorkspace.getName(), user.getName());
factoryServiceClient.deleteFactory(FACTORY_NAME);
}
@AfterClass
public void restoreContributionTabPreference() throws Exception {
testUserPreferencesServiceClient.restoreDefaultContributionTabPreference();
}
@Test
public void createFactoryFromUiWithKeepDirTest() throws Exception {
projectExplorer.waitProjectExplorer();

View File

@ -19,6 +19,7 @@ import org.eclipse.che.commons.lang.NameGenerator;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.client.TestFactoryServiceClient;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
import org.eclipse.che.selenium.core.client.TestUserPreferencesServiceClient;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
@ -63,6 +64,7 @@ public class CreateNamedFactoryFromDashboardTest {
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestFactoryServiceClient factoryServiceClient;
@Inject private PullRequestPanel pullRequestPanel;
@Inject private TestUserPreferencesServiceClient testUserPreferencesServiceClient;
@BeforeClass
public void setUp() throws Exception {
@ -74,11 +76,16 @@ public class CreateNamedFactoryFromDashboardTest {
}
@AfterClass
public void tearDown() throws Exception {
public void deleteFactoryRelatedStaff() throws Exception {
workspaceServiceClient.deleteFactoryWorkspaces(testWorkspace.getName(), user.getName());
factoryServiceClient.deleteFactory(FACTORY_NAME);
}
@AfterClass
public void restoreContributionTabPreference() throws Exception {
testUserPreferencesServiceClient.restoreDefaultContributionTabPreference();
}
@Test
public void createFactoryFromDashBoard() throws ExecutionException, InterruptedException {
String currentWin = seleniumWebDriver.getWindowHandle();

View File

@ -26,6 +26,7 @@ import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.TestGroup;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
import org.eclipse.che.selenium.core.client.TestUserPreferencesServiceClient;
import org.eclipse.che.selenium.core.client.TestWorkspaceServiceClient;
import org.eclipse.che.selenium.core.factory.TestFactory;
import org.eclipse.che.selenium.core.factory.TestFactoryInitializer;
@ -60,6 +61,7 @@ public class DirectUrlFactoryWithSpecificBranchTest {
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestProjectServiceClient testProjectServiceClient;
@Inject private PullRequestPanel pullRequestPanel;
@Inject private TestUserPreferencesServiceClient testUserPreferencesServiceClient;
private TestFactory testFactoryWithSpecificBranch;
@ -78,12 +80,17 @@ public class DirectUrlFactoryWithSpecificBranchTest {
}
@AfterClass
public void tearDown() throws Exception {
public void deleteTestBranch() throws Exception {
if (workspaceServiceClient.exists(gitHubAuxiliaryUserName, testUser.getName())) {
testFactoryWithSpecificBranch.delete();
}
}
@AfterClass
public void restoreContributionTabPreference() throws Exception {
testUserPreferencesServiceClient.restoreDefaultContributionTabPreference();
}
@Test
public void factoryWithDirectUrlWithSpecificBranch() throws Exception {
String repositoryName = testAuxiliaryRepo.getName();

View File

@ -108,7 +108,7 @@ public class AuthorizeOnGithubFromPreferencesTest {
preferences.deleteSshKeyByHost(GITHUB_COM);
}
preferences.closeForm();
preferences.close();
}
@Test

View File

@ -139,7 +139,7 @@ public class ImportWizardFormTest {
preferences.deleteSshKeyByHost(GITHUB_COM);
}
preferences.closeForm();
preferences.close();
}
@AfterMethod

View File

@ -12,21 +12,30 @@
package org.eclipse.che.selenium.git;
import static java.lang.String.format;
import static java.util.regex.Pattern.compile;
import static org.eclipse.che.commons.lang.NameGenerator.generate;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Git.BRANCHES;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Git.GIT;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Profile.PREFERENCES;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Profile.PROFILE_MENU;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Workspace.IMPORT_PROJECT;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Workspace.WORKSPACE;
import static org.eclipse.che.selenium.pageobject.PanelSelector.PanelTypes.LEFT_RIGHT_BOTTOM_ID;
import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.BRANCH_PUSHED_ON_YOUR_ORIGIN;
import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.NEW_COMMITS_PUSHED;
import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.PULL_REQUEST_ISSUED;
import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.PULL_REQUEST_UPDATED;
import static org.eclipse.che.selenium.pageobject.Wizard.TypeProject.BLANK;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.core.TestGroup;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
@ -43,12 +52,15 @@ import org.eclipse.che.selenium.pageobject.Ide;
import org.eclipse.che.selenium.pageobject.ImportProjectFromLocation;
import org.eclipse.che.selenium.pageobject.Loader;
import org.eclipse.che.selenium.pageobject.Menu;
import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.PanelSelector;
import org.eclipse.che.selenium.pageobject.Preferences;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.PullRequestPanel;
import org.eclipse.che.selenium.pageobject.Wizard;
import org.openqa.selenium.By;
import org.eclipse.che.selenium.pageobject.git.Git;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -64,10 +76,20 @@ public class PullRequestPluginTest {
private static final String MAIN_BRANCH = "master";
private static final String PULL_REQUEST_CREATED = "Your pull request has been created.";
private static final String PUll_REQUEST_UPDATED = "Your pull request has been updated.";
private static final String NEW_BRANCH = generate("branch-", 8);
private static final String DEV_BRANCH_NAME = generate("dev-", 4);
private static final String BASE_BRANCH_NAME = generate("base-", 4);
private static final String NEW_BRANCH_NAME = generate("new-", 8);
private static final String TITLE = generate("Title: ", 8);
private static final String COMMENT = generate("Comment: ", 8);
private static final String PATH_TO_README_FILE = FIRST_PROJECT_NAME + "/README.md";
private static final String PATH_TO_README_FILE_1ST_PROJECT = FIRST_PROJECT_NAME + "/README.md";
private static final String PATH_TO_README_FILE_2ND_PROJECT = SECOND_PROJECT_NAME + "/README.md";
private static final String READ_FACTORY_URL_FROM_PR_DESCRIPTION_TEMPLATE =
"\\[!\\[Review\\]\\(.*%1$s/factory/resources/factory-review.svg\\)\\]\\((.*%1$s/f\\?id=factory.*)\\).*"
+ COMMENT;
private String mainBrowserTabHandle;
private String firstProjectUrl;
private String secondProjectUrl;
@Inject
@Named("github.username")
@ -77,7 +99,12 @@ public class PullRequestPluginTest {
@Named("github.password")
private String gitHubPassword;
@Inject
@Named("che.host")
private String cheHost;
@Inject private Ide ide;
@Inject private Git git;
@Inject private Menu menu;
@Inject private Loader loader;
@Inject private Wizard wizard;
@ -85,6 +112,7 @@ public class PullRequestPluginTest {
@Inject private CodenvyEditor editor;
@Inject private AskDialog askDialog;
@Inject private Preferences preferences;
@Inject private PanelSelector panelSelector;
@Inject private TestWorkspace testWorkspace;
@Inject private AskForValueDialog valueDialog;
@Inject private TestGitHubRepository testRepo;
@ -94,18 +122,23 @@ public class PullRequestPluginTest {
@Inject private SeleniumWebDriver seleniumWebDriver;
@Inject private ImportProjectFromLocation importWidget;
@Inject private SeleniumWebDriverHelper seleniumWebDriverHelper;
@Inject private TestWorkspaceServiceClient workspaceServiceClient;
@Inject private TestWorkspaceServiceClient testWorkspaceServiceClient;
@Inject private TestUserPreferencesServiceClient testUserPreferencesServiceClient;
@Inject private TestProjectServiceClient testProjectServiceClient;
@Inject private NotificationsPopupPanel notificationsPopupPanel;
@BeforeClass
public void setUp() throws Exception {
// preconditions
Path entryPath =
Paths.get(getClass().getResource("/projects/default-spring-project").getPath());
testRepo.addContent(entryPath);
testRepo2.addContent(entryPath);
testRepo.createBranch(NEW_BRANCH_NAME);
testRepo2.createBranch(BASE_BRANCH_NAME);
ide.open(testWorkspace);
mainBrowserTabHandle = seleniumWebDriver.getWindowHandle();
// add committer info
testUserPreferencesServiceClient.addGitCommitter(gitHubUsername, user.getEmail());
@ -114,65 +147,110 @@ public class PullRequestPluginTest {
menu.runCommand(PROFILE_MENU, PREFERENCES);
preferences.waitPreferencesForm();
preferences.generateAndUploadSshKeyOnGithub(gitHubUsername, gitHubPassword);
// import the test projects
firstProjectUrl = testRepo.getHttpsTransportUrl();
secondProjectUrl = testRepo2.getHttpsTransportUrl();
importProject(firstProjectUrl, FIRST_PROJECT_NAME);
importProject(secondProjectUrl, SECOND_PROJECT_NAME);
}
@AfterMethod
public void returnToMainWindow() {
if (seleniumWebDriver.getWindowHandles().size() > 1) {
seleniumWebDriverHelper.closeCurrentWindowAndSwitchToAnother(mainBrowserTabHandle);
}
}
@AfterClass
public void tearDown() throws Exception {
workspaceServiceClient.deleteFactoryWorkspaces(testWorkspace.getName(), user.getName());
public void deleteFactoryWorkspace() throws Exception {
testWorkspaceServiceClient.deleteFactoryWorkspaces(testWorkspace.getName(), user.getName());
}
@Test(priority = 0)
@AfterClass
public void restoreContributionTabPreference() throws Exception {
testUserPreferencesServiceClient.restoreDefaultContributionTabPreference();
}
@Test
public void switchingBetweenProjects() {
String firstProjectUrl = testRepo.getHtmlUrl() + ".git";
String secondProjectUrl = testRepo2.getHtmlUrl() + ".git";
// import first project
projectExplorer.waitProjectExplorer();
menu.runCommand(WORKSPACE, IMPORT_PROJECT);
importWidget.waitAndTypeImporterAsGitInfo(firstProjectUrl, FIRST_PROJECT_NAME);
configureTypeOfProject();
// import second project
projectExplorer.waitProjectExplorer();
menu.runCommand(WORKSPACE, IMPORT_PROJECT);
importWidget.waitAndTypeImporterAsGitInfo(secondProjectUrl, SECOND_PROJECT_NAME);
configureTypeOfProject();
projectExplorer.waitItem(FIRST_PROJECT_NAME);
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
loader.waitOnClosed();
// switch between projects
// check the data of the first repository
pullRequestPanel.clickPullRequestBtn();
pullRequestPanel.waitRepoUrl(firstProjectUrl);
pullRequestPanel.waitBranchName(MAIN_BRANCH);
pullRequestPanel.waitProjectName(FIRST_PROJECT_NAME);
// checkout to another branch when the PR panel is closed
pullRequestPanel.closePanelByHideButton();
projectExplorer.waitAndSelectItem(SECOND_PROJECT_NAME);
checkoutToBranch("origin/" + BASE_BRANCH_NAME);
notificationsPopupPanel.waitPopupPanelsAreClosed();
// open PR panel by the 'Panel Selector'
panelSelector.selectPanelTypeFromPanelSelector(LEFT_RIGHT_BOTTOM_ID);
pullRequestPanel.waitOpenPanel();
// check the data of the second repository
pullRequestPanel.waitRepoUrl(secondProjectUrl);
pullRequestPanel.waitBranchName(MAIN_BRANCH);
pullRequestPanel.waitBranchName(BASE_BRANCH_NAME);
pullRequestPanel.waitProjectName(SECOND_PROJECT_NAME);
}
@Test(priority = 1)
public void createPullRequest() throws Exception {
projectExplorer.waitItem(FIRST_PROJECT_NAME);
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
projectExplorer.openItemByPath(FIRST_PROJECT_NAME);
public void createPullRequestToNonDefaultBranch() throws Exception {
projectExplorer.waitItem(SECOND_PROJECT_NAME);
projectExplorer.waitAndSelectItem(SECOND_PROJECT_NAME);
projectExplorer.openItemByPath(SECOND_PROJECT_NAME);
// change content in README.md file
openFileAndChangeContent(PATH_TO_README_FILE, generate("", 12));
openFileAndChangeContent(PATH_TO_README_FILE_2ND_PROJECT, generate("", 12));
// create branch
pullRequestPanel.waitOpenPanel();
pullRequestPanel.selectBranch(CREATE_BRANCH);
valueDialog.waitFormToOpen();
valueDialog.typeAndWaitText(NEW_BRANCH);
valueDialog.typeAndWaitText(DEV_BRANCH_NAME);
valueDialog.clickOkBtn();
valueDialog.waitFormToClose();
pullRequestPanel.enterComment(COMMENT);
pullRequestPanel.enterTitle(TITLE);
// change commit and create pull request
// commit the change create pull request
pullRequestPanel.clickCreatePullRequestButton();
pullRequestPanel.clickOkCommitBtn();
pullRequestPanel.waitStatusOk(BRANCH_PUSHED_ON_YOUR_ORIGIN);
pullRequestPanel.waitStatusOk(PULL_REQUEST_ISSUED);
pullRequestPanel.waitMessage(PULL_REQUEST_CREATED);
// check the base and head branches in the pull request
assertEquals(testRepo2.getPullRequestHeadBranchName(1), DEV_BRANCH_NAME);
assertEquals(testRepo2.getPullRequestBaseBranchName(1), BASE_BRANCH_NAME);
}
@Test(priority = 1)
public void createPullRequestToDefaultBranch() throws Exception {
projectExplorer.waitItem(FIRST_PROJECT_NAME);
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
projectExplorer.openItemByPath(FIRST_PROJECT_NAME);
// checkout to another branch when the PR panel is opened
pullRequestPanel.waitOpenPanel();
checkoutToBranch("origin/" + NEW_BRANCH_NAME);
pullRequestPanel.clickPullRequestBtn();
pullRequestPanel.clickRefreshBranchListButton();
pullRequestPanel.selectBranch(NEW_BRANCH_NAME);
// change content in README.md file
openFileAndChangeContent(PATH_TO_README_FILE_1ST_PROJECT, generate("", 12));
pullRequestPanel.enterComment(COMMENT);
pullRequestPanel.enterTitle(TITLE);
// commit the change and create pull request
pullRequestPanel.clickCreatePullRequestButton();
pullRequestPanel.clickOkCommitBtn();
pullRequestPanel.waitStatusOk(BRANCH_PUSHED_ON_YOUR_ORIGIN);
@ -185,13 +263,11 @@ public class PullRequestPluginTest {
String expectedText =
format(
"Branch '%s:%s' is already used. Would you like to overwrite it?",
gitHubUsername, NEW_BRANCH);
editor.closeAllTabs();
loader.waitOnClosed();
gitHubUsername, NEW_BRANCH_NAME);
// change content in README.md file
openFileAndChangeContent(PATH_TO_README_FILE, generate("", 12));
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
openFileAndChangeContent(PATH_TO_README_FILE_1ST_PROJECT, generate("", 12));
// update PR and check status
pullRequestPanel.clickUpdatePullRequestButton();
@ -203,15 +279,24 @@ public class PullRequestPluginTest {
}
@Test(priority = 3)
public void checkFactoryOnGitHub() {
String currentWindow = seleniumWebDriver.getWindowHandle();
public void checkFactoryOnGitHub() throws IOException {
// check pull request description
assertEquals(testRepo2.getPullRequestUserName(1), gitHubUsername);
assertEquals(testRepo2.getPullRequestTitle(1), TITLE);
// open and check projects page on github
pullRequestPanel.openPullRequestOnGitHub();
seleniumWebDriverHelper.switchToNextWindow(currentWindow);
checkGitHubUserPage();
String pullRequestDescription = testRepo2.getPullRequestBody(1);
consumeFactoryOnGitHub();
Matcher matcher =
compile(
format(READ_FACTORY_URL_FROM_PR_DESCRIPTION_TEMPLATE, cheHost),
Pattern.MULTILINE | Pattern.DOTALL)
.matcher(pullRequestDescription);
assertTrue(matcher.find(), "Actual PR description was " + pullRequestDescription);
// open factory from URL in pull request description
String factoryUrlFromPrDescription = matcher.group(1);
seleniumWebDriver.navigate().to(factoryUrlFromPrDescription);
seleniumWebDriverHelper.switchToIdeFrameAndWaitAvailability();
projectExplorer.waitProjectExplorer();
@ -219,10 +304,17 @@ public class PullRequestPluginTest {
projectExplorer.waitItem(SECOND_PROJECT_NAME);
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
projectExplorer.openItemByPath(FIRST_PROJECT_NAME);
projectExplorer.openItemByPath(PATH_TO_README_FILE);
projectExplorer.openItemByPath(PATH_TO_README_FILE_1ST_PROJECT);
editor.waitActive();
}
private void importProject(String projectUrl, String projectName) {
projectExplorer.waitProjectExplorer();
menu.runCommand(WORKSPACE, IMPORT_PROJECT);
importWidget.waitAndTypeImporterAsGitInfo(projectUrl, projectName);
configureTypeOfProject();
}
private void configureTypeOfProject() {
wizard.selectTypeProject(BLANK);
loader.waitOnClosed();
@ -231,23 +323,16 @@ public class PullRequestPluginTest {
wizard.waitCreateProjectWizardFormIsClosed();
}
private void checkoutToBranch(String branchName) {
menu.runCommand(GIT, BRANCHES);
git.waitBranchInTheList(branchName);
git.selectBranchAndClickCheckoutBtn(branchName);
git.waitGitCompareBranchFormIsClosed();
}
private void openFileAndChangeContent(String filePath, String text) throws Exception {
projectExplorer.openItemByPath(filePath);
editor.waitActive();
testProjectServiceClient.updateFile(testWorkspace.getId(), filePath, text);
}
/** check main elements of the GitHub user page */
private void checkGitHubUserPage() {
seleniumWebDriverHelper.waitVisibility(By.xpath("//h1//a[text()='" + gitHubUsername + "']"));
seleniumWebDriverHelper.waitVisibility(
By.xpath("//h1//a[text()='" + testRepo.getName() + "']"));
seleniumWebDriverHelper.waitVisibility(
By.xpath("//h1//span[contains(text(), '" + TITLE + "')]"));
seleniumWebDriverHelper.waitVisibility(By.xpath("//p[text()='" + COMMENT + "']"));
}
private void consumeFactoryOnGitHub() {
seleniumWebDriverHelper.waitAndClick(By.xpath("//a[contains(@href, 'id=factory')]"));
}
}

View File

@ -19,7 +19,6 @@ import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.BRANCH
import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.FORK_CREATED;
import static org.eclipse.che.selenium.pageobject.PullRequestPanel.Status.NEW_COMMITS_PUSHED;
import static org.eclipse.che.selenium.pageobject.Wizard.TypeProject.MAVEN;
import static org.testng.Assert.fail;
import com.google.inject.Inject;
import com.google.inject.name.Named;
@ -41,7 +40,6 @@ import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.PullRequestPanel;
import org.eclipse.che.selenium.pageobject.PullRequestPanel.Status;
import org.eclipse.che.selenium.pageobject.git.Git;
import org.openqa.selenium.TimeoutException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -108,6 +106,11 @@ public class PullRequestPluginWithForkTest {
}
}
@AfterClass
public void restoreContributionTabPreference() throws Exception {
testUserPreferencesServiceClient.restoreDefaultContributionTabPreference();
}
@Test
public void createPullRequest() throws Exception {
// import project
@ -126,13 +129,7 @@ public class PullRequestPluginWithForkTest {
pullRequestPanel.clickOkCommitBtn();
pullRequestPanel.waitStatusOk(FORK_CREATED);
pullRequestPanel.waitStatusOk(BRANCH_PUSHED_ON_YOUR_FORK);
try {
pullRequestPanel.waitMessage(PULL_REQUEST_CREATED);
} catch (TimeoutException te) {
// remove try-catch block after issue has been resolved
fail("Known issue https://github.com/eclipse/che/issues/9548");
}
pullRequestPanel.waitMessage(PULL_REQUEST_CREATED);
}
@Test(priority = 1)

View File

@ -280,7 +280,7 @@ public class YamlFileEditingTest {
preferences.addSchemaUrl("kubernetes");
preferences.clickOnOkBtn();
preferences.closeForm();
preferences.close();
}
private void deleteSchema() {
@ -293,6 +293,6 @@ public class YamlFileEditingTest {
preferences.deleteSchema();
preferences.clickOnOkBtn();
preferences.closeForm();
preferences.close();
}
}

View File

@ -94,7 +94,7 @@ public class CheckErrorsWarningsTabTest {
preferences.getItemsFromErrorWarningsWidget();
Assert.assertEquals(preferences.getItemsFromErrorWarningsWidget(), expectedErrorsWarningsList);
preferences.closeForm();
preferences.close();
consoles.closeProcessesArea();
menu.runCommand(TestMenuCommandsConstants.Profile.PROFILE_MENU, PREFERENCES);
changeAllSettingsInErrorsWarningsTab(Preferences.DropDownValueForErrorWaitingWidget.WARNING);
@ -120,7 +120,7 @@ public class CheckErrorsWarningsTabTest {
preferences.selectDroppedMenuByName(Preferences.DropDownJavaCompilerMenu.ERRORS_WARNINGS);
preferences.setAllSettingsInErrorWaitingWidget(valueOfRadioButton);
preferences.clickOnOkBtn();
preferences.closeForm();
preferences.close();
loader.waitOnClosed();
projectExplorer.waitItem(PATH_TO_CLASS_IN_SPRING_PACKAGE);
projectExplorer.openItemByPath(PATH_TO_CLASS_IN_SPRING_PACKAGE);

View File

@ -14,10 +14,7 @@ package org.eclipse.che.selenium.preferences;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Assistant.ASSISTANT;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Assistant.ToolWindows.CONTRIBUTE_TOOL_WIDOWS;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Assistant.ToolWindows.TOOL_WINDOWS;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Profile.PREFERENCES;
import static org.eclipse.che.selenium.core.constant.TestMenuCommandsConstants.Profile.PROFILE_MENU;
import static org.eclipse.che.selenium.pageobject.PanelSelector.PanelTypes.LEFT_RIGHT_BOTTOM_ID;
import static org.eclipse.che.selenium.pageobject.Preferences.DropDownGitInformationMenu.CONTRIBUTE_PREFERENCES;
import static org.eclipse.che.selenium.pageobject.Wizard.TypeProject.MAVEN;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@ -28,6 +25,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import org.eclipse.che.selenium.core.client.TestGitHubRepository;
import org.eclipse.che.selenium.core.client.TestProjectServiceClient;
import org.eclipse.che.selenium.core.client.TestUserPreferencesServiceClient;
import org.eclipse.che.selenium.core.project.ProjectTemplates;
import org.eclipse.che.selenium.core.user.DefaultTestUser;
import org.eclipse.che.selenium.core.workspace.TestWorkspace;
@ -40,16 +38,13 @@ import org.eclipse.che.selenium.pageobject.Preferences;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.PullRequestPanel;
import org.eclipse.che.selenium.pageobject.git.Git;
import org.eclipse.che.selenium.refactor.move.MoveItemsTest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/** @author Aleksandr Shmaraev */
public class ContributeTabTest {
private static final Logger LOG = LoggerFactory.getLogger(MoveItemsTest.class);
private static final String FIRST_PROJECT_NAME = "first-vcs-project";
private static final String SECOND_PROJECT_NAME = "second-vcs-project";
private static final String THIRD_PROJECT_NAME = "not-vcs-project";
@ -75,6 +70,7 @@ public class ContributeTabTest {
@Inject private TestProjectServiceClient testProjectServiceClient;
@Inject private NotificationsPopupPanel notificationsPopupPanel;
@Inject private PanelSelector panelSelector;
@Inject private TestUserPreferencesServiceClient testUserPreferencesServiceClient;
@BeforeClass
public void setUp() throws Exception {
@ -108,6 +104,13 @@ public class ContributeTabTest {
}
preferences.waitPreferencesFormIsClosed();
preferences.openContributeTab();
preferences.setStateContributeChecboxAndCloseForm(true);
}
@AfterClass
public void restoreContributionTabPreference() throws Exception {
testUserPreferencesServiceClient.restoreDefaultContributionTabPreference();
}
@Test
@ -132,14 +135,14 @@ public class ContributeTabTest {
pullRequestPanel.waitTextNotVcsProject(EXP_TEXT_NOT_VCS);
// check the 'Contribute' checkbox is true by default
openContributeTab();
preferences.openContributeTab();
preferences.waitContributeCheckboxIsSelected();
preferences.closeForm();
preferences.close();
}
@Test(priority = 1)
public void checkRefreshAndSaveButton() {
openContributeTab();
preferences.openContributeTab();
preferences.setContributeCheckbox(true);
preferences.clickOnOkBtn();
@ -157,19 +160,19 @@ public class ContributeTabTest {
assertFalse(preferences.isSaveButtonIsEnabled());
preferences.closeForm();
preferences.close();
}
@Test(priority = 1)
public void checkSwitchProjectsWhenContributeIsFalse() {
openContributeTab();
setStateContributeChecboxAndCloseForm(true);
preferences.openContributeTab();
preferences.setStateContributeChecboxAndCloseForm(true);
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
pullRequestPanel.waitOpenPanel();
openContributeTab();
setStateContributeChecboxAndCloseForm(false);
preferences.openContributeTab();
preferences.setStateContributeChecboxAndCloseForm(false);
// switch between projects
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
@ -186,8 +189,8 @@ public class ContributeTabTest {
@Test(priority = 1)
public void checkAutomaticChangeContributeToFalse() {
openContributeTab();
setStateContributeChecboxAndCloseForm(true);
preferences.openContributeTab();
preferences.setStateContributeChecboxAndCloseForm(true);
// change 'Contribute' to false by 'Hide' button
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
@ -195,11 +198,11 @@ public class ContributeTabTest {
pullRequestPanel.closePanelByHideButton();
notificationsPopupPanel.waitExpectedMessageOnProgressPanelAndClose(NOTIFICATION_MESSAGE);
openContributeTab();
preferences.openContributeTab();
preferences.waitContributeCheckboxIsNotSelected();
// change 'Contribute' to false by 'Hide' from 'Options' on the PR panel
setStateContributeChecboxAndCloseForm(true);
preferences.setStateContributeChecboxAndCloseForm(true);
projectExplorer.waitAndSelectItem(SECOND_PROJECT_NAME);
pullRequestPanel.waitOpenPanel();
@ -207,11 +210,11 @@ public class ContributeTabTest {
pullRequestPanel.closePanelFromContextMenu();
notificationsPopupPanel.waitExpectedMessageOnProgressPanelAndClose(NOTIFICATION_MESSAGE);
openContributeTab();
preferences.openContributeTab();
preferences.waitContributeCheckboxIsNotSelected();
// change 'Contribute' to false by 'Contribute' action from 'Assistant'
setStateContributeChecboxAndCloseForm(true);
preferences.setStateContributeChecboxAndCloseForm(true);
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
pullRequestPanel.waitOpenPanel();
@ -220,15 +223,15 @@ public class ContributeTabTest {
menu.runCommand(ASSISTANT, TOOL_WINDOWS, CONTRIBUTE_TOOL_WIDOWS);
pullRequestPanel.waitClosePanel();
openContributeTab();
preferences.openContributeTab();
preferences.waitContributeCheckboxIsNotSelected();
preferences.closeForm();
preferences.close();
}
@Test(priority = 1)
public void checkDirectAccessToContributeTab() {
openContributeTab();
setStateContributeChecboxAndCloseForm(false);
preferences.openContributeTab();
preferences.setStateContributeChecboxAndCloseForm(false);
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
pullRequestPanel.waitClosePanel();
@ -255,8 +258,8 @@ public class ContributeTabTest {
@Test(priority = 1)
public void checkHidingPrPanelWhenProjectExplorerIsMaximized() {
openContributeTab();
setStateContributeChecboxAndCloseForm(true);
preferences.openContributeTab();
preferences.setStateContributeChecboxAndCloseForm(true);
projectExplorer.waitAndSelectItem(FIRST_PROJECT_NAME);
pullRequestPanel.waitOpenPanel();
@ -270,17 +273,4 @@ public class ContributeTabTest {
projectExplorer.clickOnMaximizeButton();
pullRequestPanel.waitOpenPanel();
}
private void setStateContributeChecboxAndCloseForm(boolean state) {
preferences.setContributeCheckbox(state);
preferences.clickOnOkBtn();
preferences.closeForm();
}
private void openContributeTab() {
menu.runCommand(PROFILE_MENU, PREFERENCES);
preferences.waitPreferencesForm();
preferences.waitMenuInCollapsedDropdown(CONTRIBUTE_PREFERENCES);
preferences.selectDroppedMenuByName(CONTRIBUTE_PREFERENCES);
}
}

View File

@ -63,7 +63,7 @@ public class CheckDisplayingArtifactIdTest {
preferences.selectDroppedMenuByName("Maven");
preferences.clickOnShowArtifactCheckBox();
preferences.clickOnOkBtn();
preferences.closeForm();
preferences.close();
preferences.waitPreferencesFormIsClosed();
projectExplorer.waitVisibilityByName(PROJECT_NAME + " " + ARTIFACT_ID);
projectExplorer.quickExpandWithJavaScript();
@ -84,7 +84,7 @@ public class CheckDisplayingArtifactIdTest {
preferences.selectDroppedMenuByName("Maven");
preferences.clickOnShowArtifactCheckBox();
preferences.clickOnOkBtn();
preferences.closeForm();
preferences.close();
projectExplorer.waitVisibilityByName(PROJECT_NAME);
}

View File

@ -87,28 +87,28 @@
<class name="org.eclipse.che.selenium.editor.CheckWorkingWithTabsByUsingContextMenuTest"/>
<class name="org.eclipse.che.selenium.editor.ContextMenuEditorTest"/>
<class name="org.eclipse.che.selenium.editor.SplitEditorFeatureTest"/>
<class name="org.eclipse.che.selenium.factory.CheckFactoryWithMultiModuleTest"/>
<class name="org.eclipse.che.selenium.factory.CheckFactoryWithPerUserCreatePolicyTest"/>
<class name="org.eclipse.che.selenium.factory.CheckFactoryWithPerClickCreatePolicyTest"/>
<class name="org.eclipse.che.selenium.factory.CheckFactoryWithMultiModuleTest"/>
<class name="org.eclipse.che.selenium.factory.CheckFactoryWithSincePolicyTest"/>
<class name="org.eclipse.che.selenium.factory.CheckFactoryWithUntilPolicyTest"/>
<class name="org.eclipse.che.selenium.factory.CreateFactoryFromUiWithKeepDirTest"/>
<class name="org.eclipse.che.selenium.factory.CheckOpenFileFeatureTest"/>
<class name="org.eclipse.che.selenium.factory.CheckRunCommandFeatureTest"/>
<class name="org.eclipse.che.selenium.factory.CheckWelcomePanelOnCodenvyTest"/>
<class name="org.eclipse.che.selenium.factory.CreateNamedFactoryFromDashboardTest"/>
<class name="org.eclipse.che.selenium.factory.CreateFactoryFromUiWithKeepDirTest"/>
<class name="org.eclipse.che.selenium.factory.CheckFactoryWithSparseCheckoutTest"/>
<class name="org.eclipse.che.selenium.factory.DirectUrlFactoryWithRootFolderTest"/>
<class name="org.eclipse.che.selenium.factory.DirectUrlFactoryWithSpecificBranchTest"/>
<class name="org.eclipse.che.selenium.factory.CheckFactoryWithSparseCheckoutTest"/>
<class name="org.eclipse.che.selenium.filewatcher.EditFilesWithTabsTest"/>
<class name="org.eclipse.che.selenium.filewatcher.RefactoringFeatureTest"/>
<class name="org.eclipse.che.selenium.filewatcher.RemoveFilesWithActiveTabs"/>
<class name="org.eclipse.che.selenium.filewatcher.UpdateFilesWithoutIDE"/>
<class name="org.eclipse.che.selenium.factory.CreateNamedFactoryFromDashboardTest"/>
<class name="org.eclipse.che.selenium.filewatcher.CheckDeletingProjectByApiTest"/>
<class name="org.eclipse.che.selenium.filewatcher.CheckFileWatcherExcludeFeatureTest"/>
<class name="org.eclipse.che.selenium.git.ImportWizardFormTest"/>
<class name="org.eclipse.che.selenium.git.AddFilesToIndexTest"/>
<class name="org.eclipse.che.selenium.git.AmendCommitTest"/>
<class name="org.eclipse.che.selenium.factory.DirectUrlFactoryWithSpecificBranchTest"/>
<class name="org.eclipse.che.selenium.git.BranchTest"/>
<class name="org.eclipse.che.selenium.git.CheckoutReferenceTest"/>
<class name="org.eclipse.che.selenium.git.CheckoutToRemoteBranchWhichAlreadyHasLinkedLocalBranchTest"/>