diff options
author | Grégoire Aubert <gregoire.aubert@sonarsource.com> | 2018-02-14 15:57:48 +0100 |
---|---|---|
committer | Guillaume Jambet <guillaume.jambet@gmail.com> | 2018-03-01 15:21:05 +0100 |
commit | bfb8b46ce0f4850775ccab4e2fa13ed83901c842 (patch) | |
tree | e0779b2bf177d0417d3c40ff0b38b7067909cabe /server/sonar-qa-util | |
parent | bad30545b5ed235f7778c00baedbbe0e41006049 (diff) | |
download | sonarqube-bfb8b46ce0f4850775ccab4e2fa13ed83901c842.tar.gz sonarqube-bfb8b46ce0f4850775ccab4e2fa13ed83901c842.zip |
SONAR-10347 Add IT's for webhook deliveries
Diffstat (limited to 'server/sonar-qa-util')
-rw-r--r-- | server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/Tester.java | 1 | ||||
-rw-r--r-- | server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java | 53 |
2 files changed, 54 insertions, 0 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 fe1d5d8236e..b97c2638fb3 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 @@ -114,6 +114,7 @@ public class Tester extends ExternalResource implements TesterSession { projects().deleteAll(); settings().deleteAll(); qGates().deleteAll(); + webhooks().deleteAllGlobal(); } public TesterSession asAnonymous() { diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java index 75260c11e11..bca17a54cb6 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/WebhooksPage.java @@ -21,6 +21,7 @@ package org.sonarqube.qa.util.pageobjects; import com.codeborne.selenide.ElementsCollection; import com.codeborne.selenide.SelenideElement; +import java.util.Arrays; import static com.codeborne.selenide.Condition.cssClass; import static com.codeborne.selenide.Condition.enabled; @@ -46,6 +47,16 @@ public class WebhooksPage { return this; } + public WebhooksPage hasLatestDelivery(String webhookName) { + getWebhook(webhookName).shouldNotHave(text("Never")); + return this; + } + + public WebhooksPage hasNoLatestDelivery(String webhookName) { + getWebhook(webhookName).shouldHave(text("Never")); + return this; + } + public WebhooksPage countWebhooks(Integer number) { getWebhooks().shouldHaveSize(number); return this; @@ -77,6 +88,48 @@ public class WebhooksPage { return this; } + public DeliveriesForm showDeliveries(String webhookName) { + SelenideElement webhook = getWebhook(webhookName); + webhook.$(".dropdown-toggle").shouldBe(visible).click(); + webhook.$(".js-webhook-deliveries").shouldBe(visible).click(); + modalShouldBeOpen("Recent deliveries for " + webhookName); + return new DeliveriesForm($(".modal-body")); + } + + public static class DeliveriesForm { + private final SelenideElement elt; + + public DeliveriesForm(SelenideElement elt) { + this.elt = elt; + } + + public DeliveriesForm countDeliveries(Integer number) { + this.getDeliveries().shouldHaveSize(number); + return this; + } + + public DeliveriesForm isSuccessFull(Integer deliveryIndex) { + this.getDeliveries().get(deliveryIndex).$(".js-success").should(exist); + return this; + } + + public DeliveriesForm payloadContains(Integer deliveryIndex, String... payload) { + SelenideElement delivery = this.getDeliveries().get(deliveryIndex); + SelenideElement header = delivery.$(".boxed-group-header").should(exist); + if (!delivery.$(".boxed-group-inner").exists()) { + header.click(); + } + SelenideElement inner = delivery.$(".boxed-group-inner").shouldBe(visible); + Arrays.stream(payload).forEach(p -> inner.shouldHave(text(p))); + header.click(); + return this; + } + + private ElementsCollection getDeliveries() { + return this.elt.$$(".boxed-group-accordion"); + } + } + private static SelenideElement getWebhook(String webhookName) { return getWebhooks().find(text(webhookName)).should(exist); } |