diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-11-11 12:04:33 +0100 |
---|---|---|
committer | Eric Hartmann <hartmann.eric@gmail.Com> | 2017-11-14 13:10:17 +0100 |
commit | 525e102ac6942a032546559ae14ecf20bfb20da9 (patch) | |
tree | e95f9eee04a86e6ef9d84da173c8a950b9f4f7c0 /server | |
parent | 35128eb81138f5c4b631d2c24b7aefa2d49b4139 (diff) | |
download | sonarqube-525e102ac6942a032546559ae14ecf20bfb20da9.tar.gz sonarqube-525e102ac6942a032546559ae14ecf20bfb20da9.zip |
Add category measure to integration tests
Diffstat (limited to 'server')
3 files changed, 40 insertions, 4 deletions
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java index 50412d8bc50..f5077ad3266 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java @@ -39,12 +39,21 @@ import static java.util.Objects.requireNonNull; * <li>clean-up of users between tests</li> * <li>clean-up of session when opening a browser (cookies, local storage)</li> * <li>quick access to {@link WsClient} instances</li> + * <li>clean-up of defined settings. Properties that are not defined by a plugin are not reset.</li> * <li>helpers to generate organizations and users</li> * </ul> - * <p> + * * Recommendation is to define a {@code @Rule} instance. If not possible, then * {@code @ClassRule} must be used through a {@link org.junit.rules.RuleChain} * around {@link Orchestrator}. + * + * Not supported: + * <ul> + * <li>clean-up global settings</li> + * <li>clean-up system administrators/roots</li> + * <li>clean-up default organization</li> + * <li>clean-up the properties that are not defined (no PropertyDefinition)</li> + * </ul> */ public class Tester extends ExternalResource implements TesterSession { diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java index 5f4f4a943d0..6c57c8a81aa 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/UserTester.java @@ -67,6 +67,9 @@ public class UserTester { return service().create(request.build()).getUser(); } + /** + * For standalone mode only + */ @SafeVarargs public final User generateAdministrator(Consumer<CreateRequest.Builder>... populators) { User user = generate(populators); @@ -77,10 +80,11 @@ public class UserTester { @SafeVarargs public final User generateAdministrator(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) { + String organizationKey = organization.getKey(); User user = generate(populators); - session.wsClient().organizations().addMember(organization.getKey(), user.getLogin()); + session.wsClient().organizations().addMember(organizationKey, user.getLogin()); session.wsClient().userGroups().addUser(AddUserWsRequest.builder() - .setOrganization(organization.getKey()) + .setOrganization(organizationKey) .setLogin(user.getLogin()) .setName("Owners") .build()); @@ -88,6 +92,18 @@ public class UserTester { } @SafeVarargs + public final User generateAdministratorOnDefaultOrganization(Consumer<CreateRequest.Builder>... populators) { + User user = generate(populators); + session.wsClient().organizations().addMember("default-organization", user.getLogin()); + session.wsClient().userGroups().addUser(AddUserWsRequest.builder() + .setOrganization("default-organization") + .setLogin(user.getLogin()) + .setName("sonar-administrators") + .build()); + return user; + } + + @SafeVarargs public final User generateMember(Organizations.Organization organization, Consumer<CreateRequest.Builder>... populators) { User user = generate(populators); session.wsClient().organizations().addMember(organization.getKey(), user.getLogin()); diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java index f3cd21aac1b..4e39003c048 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/measures/MeasuresPage.java @@ -23,7 +23,9 @@ import com.codeborne.selenide.CollectionCondition; import com.codeborne.selenide.Condition; import com.codeborne.selenide.Selenide; import com.codeborne.selenide.SelenideElement; +import com.codeborne.selenide.WebDriverRunner; import org.openqa.selenium.Keys; +import org.openqa.selenium.interactions.Actions; public class MeasuresPage { public MeasuresPage() { @@ -61,7 +63,16 @@ public class MeasuresPage { } public MeasuresPage backShortcut() { - Selenide.$(".layout-page-header-panel").sendKeys(Keys.LEFT); + SelenideElement panel = Selenide.$(".layout-page-header-panel"); + + // panel.sendKeys(Keys.LEFT) does not work correctly on Chrome + // The workaround is to use Actions + // https://bugs.chromium.org/p/chromedriver/issues/detail?id=35 + Actions actions = new Actions(WebDriverRunner.getWebDriver()); + actions.moveToElement(panel); + actions.click(); + actions.sendKeys(Keys.LEFT); + actions.build().perform(); return this; } |