From e5ca2e82985cf4071e3512e95bf40da436369ec3 Mon Sep 17 00:00:00 2001 From: Aleksandr Shmaraiev Date: Mon, 1 Oct 2018 16:21:33 +0000 Subject: [PATCH] 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 --- .../contribute/ContributePartViewImpl.java | 1 + .../core/client/TestGitHubRepository.java | 20 ++ .../TestUserPreferencesServiceClient.java | 20 ++ .../che/selenium/pageobject/Preferences.java | 227 ++++++++---------- .../selenium/pageobject/PullRequestPanel.java | 9 + .../CheckFactoryWithMultiModuleTest.java | 9 +- .../CheckFactoryWithSparseCheckoutTest.java | 9 +- .../CreateFactoryFromUiWithKeepDirTest.java | 9 +- .../CreateNamedFactoryFromDashboardTest.java | 9 +- ...irectUrlFactoryWithSpecificBranchTest.java | 9 +- .../AuthorizeOnGithubFromPreferencesTest.java | 2 +- .../selenium/git/ImportWizardFormTest.java | 2 +- .../selenium/git/PullRequestPluginTest.java | 201 +++++++++++----- .../git/PullRequestPluginWithForkTest.java | 15 +- .../languageserver/YamlFileEditingTest.java | 4 +- .../CheckErrorsWarningsTabTest.java | 4 +- .../preferences/ContributeTabTest.java | 70 +++--- .../CheckDisplayingArtifactIdTest.java | 4 +- .../src/test/resources/suites/CheSuite.xml | 10 +- 19 files changed, 387 insertions(+), 247 deletions(-) diff --git a/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-ide/src/main/java/org/eclipse/che/plugin/pullrequest/client/parts/contribute/ContributePartViewImpl.java b/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-ide/src/main/java/org/eclipse/che/plugin/pullrequest/client/parts/contribute/ContributePartViewImpl.java index 9334dd1c27..599c385816 100644 --- a/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-ide/src/main/java/org/eclipse/che/plugin/pullrequest/client/parts/contribute/ContributePartViewImpl.java +++ b/plugins/plugin-pullrequest-parent/che-plugin-pullrequest-ide/src/main/java/org/eclipse/che/plugin/pullrequest/client/parts/contribute/ContributePartViewImpl.java @@ -142,6 +142,7 @@ public class ContributePartViewImpl extends BaseView) 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) - 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) - 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 getItemsFromErrorWarningsWidget() { + String errorWarnings = + seleniumWebDriverHelper.waitVisibilityAndGetText( + errorsWarningsTab, REDRAW_UI_ELEMENTS_TIMEOUT_SEC); List 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 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 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 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(); } } diff --git a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/PullRequestPanel.java b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/PullRequestPanel.java index edcdac829c..2a08e1496e 100644 --- a/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/PullRequestPanel.java +++ b/selenium/che-selenium-test/src/main/java/org/eclipse/che/selenium/pageobject/PullRequestPanel.java @@ -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); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CheckFactoryWithMultiModuleTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CheckFactoryWithMultiModuleTest.java index 4b3f6237d5..28f91d57a0 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CheckFactoryWithMultiModuleTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CheckFactoryWithMultiModuleTest.java @@ -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(); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CheckFactoryWithSparseCheckoutTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CheckFactoryWithSparseCheckoutTest.java index 7f593a9e0f..94b49ef438 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CheckFactoryWithSparseCheckoutTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CheckFactoryWithSparseCheckoutTest.java @@ -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(); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CreateFactoryFromUiWithKeepDirTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CreateFactoryFromUiWithKeepDirTest.java index 3c5fefddcf..51fe84b212 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CreateFactoryFromUiWithKeepDirTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CreateFactoryFromUiWithKeepDirTest.java @@ -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(); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CreateNamedFactoryFromDashboardTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CreateNamedFactoryFromDashboardTest.java index 4f1f5f7415..6985da9330 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CreateNamedFactoryFromDashboardTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/CreateNamedFactoryFromDashboardTest.java @@ -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(); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/DirectUrlFactoryWithSpecificBranchTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/DirectUrlFactoryWithSpecificBranchTest.java index 7b45afb550..30a63921ce 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/DirectUrlFactoryWithSpecificBranchTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/factory/DirectUrlFactoryWithSpecificBranchTest.java @@ -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(); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/AuthorizeOnGithubFromPreferencesTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/AuthorizeOnGithubFromPreferencesTest.java index d0430d4a8a..7b2cb62d0a 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/AuthorizeOnGithubFromPreferencesTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/AuthorizeOnGithubFromPreferencesTest.java @@ -108,7 +108,7 @@ public class AuthorizeOnGithubFromPreferencesTest { preferences.deleteSshKeyByHost(GITHUB_COM); } - preferences.closeForm(); + preferences.close(); } @Test diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/ImportWizardFormTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/ImportWizardFormTest.java index b7a078ca7f..8dff712289 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/ImportWizardFormTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/ImportWizardFormTest.java @@ -139,7 +139,7 @@ public class ImportWizardFormTest { preferences.deleteSshKeyByHost(GITHUB_COM); } - preferences.closeForm(); + preferences.close(); } @AfterMethod diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginTest.java index b2e547d3b9..3c4dc5eb0f 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginTest.java @@ -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')]")); - } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginWithForkTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginWithForkTest.java index d39473d048..604f912e19 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginWithForkTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/git/PullRequestPluginWithForkTest.java @@ -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) diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/languageserver/YamlFileEditingTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/languageserver/YamlFileEditingTest.java index 22ef1901d4..7910a41070 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/languageserver/YamlFileEditingTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/languageserver/YamlFileEditingTest.java @@ -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(); } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/preferences/CheckErrorsWarningsTabTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/preferences/CheckErrorsWarningsTabTest.java index 7c31f6bce8..a8699c1533 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/preferences/CheckErrorsWarningsTabTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/preferences/CheckErrorsWarningsTabTest.java @@ -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); diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/preferences/ContributeTabTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/preferences/ContributeTabTest.java index b5424cd688..5ec7b54c9c 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/preferences/ContributeTabTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/preferences/ContributeTabTest.java @@ -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); - } } diff --git a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/CheckDisplayingArtifactIdTest.java b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/CheckDisplayingArtifactIdTest.java index 83a11d5a1b..b32dd20fa8 100644 --- a/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/CheckDisplayingArtifactIdTest.java +++ b/selenium/che-selenium-test/src/test/java/org/eclipse/che/selenium/projectexplorer/CheckDisplayingArtifactIdTest.java @@ -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); } diff --git a/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml b/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml index 735814ff45..69f9975271 100644 --- a/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml +++ b/selenium/che-selenium-test/src/test/resources/suites/CheSuite.xml @@ -87,28 +87,28 @@ + - + - - - - + + +