aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-08-10 14:04:38 +0200
committerGitHub <noreply@github.com>2016-08-10 14:04:38 +0200
commit143f3c560bcf7ceac9585c1dfea7311f037834cb (patch)
tree6d8c5b4884c699ca6f996c0eb9639db7bcfa9fc7 /it
parent04c13b353fcb16dc53b1287f301301dad8d79abf (diff)
downloadsonarqube-143f3c560bcf7ceac9585c1dfea7311f037834cb.tar.gz
sonarqube-143f3c560bcf7ceac9585c1dfea7311f037834cb.zip
SONAR-7921 Rewrite "Quality Gate" project page (#1138)
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/projectAdministration/ProjectQualityGatePageTest.java149
-rw-r--r--it/it-tests/src/test/java/pageobjects/Navigation.java6
-rw-r--r--it/it-tests/src/test/java/pageobjects/ProjectQualityGatePage.java45
3 files changed, 200 insertions, 0 deletions
diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectQualityGatePageTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectQualityGatePageTest.java
new file mode 100644
index 00000000000..401f5a87766
--- /dev/null
+++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectQualityGatePageTest.java
@@ -0,0 +1,149 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package it.projectAdministration;
+
+import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.SelenideElement;
+import com.sonar.orchestrator.Orchestrator;
+import it.Category1Suite;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.wsclient.qualitygate.QualityGate;
+import org.sonar.wsclient.qualitygate.QualityGateClient;
+import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.WsClient;
+import org.sonarqube.ws.client.qualitygate.SelectWsRequest;
+import pageobjects.Navigation;
+import pageobjects.ProjectQualityGatePage;
+
+import static util.ItUtils.newAdminWsClient;
+
+public class ProjectQualityGatePageTest {
+
+ @ClassRule
+ public static Orchestrator ORCHESTRATOR = Category1Suite.ORCHESTRATOR;
+
+ @Rule
+ public Navigation nav = Navigation.get(ORCHESTRATOR);
+
+ private static WsClient wsClient;
+
+ @BeforeClass
+ public static void prepare() {
+ wsClient = newAdminWsClient(ORCHESTRATOR);
+ }
+
+ @Before
+ public void setUp() {
+ ORCHESTRATOR.resetData();
+
+ wsClient.wsConnector().call(new PostRequest("api/projects/create")
+ .setParam("name", "Sample")
+ .setParam("key", "sample"));
+ }
+
+ @Test
+ public void should_display_default() {
+ QualityGate customQualityGate = createCustomQualityGate("should_display_default");
+ qualityGateClient().setDefault(customQualityGate.id());
+
+ ProjectQualityGatePage page = openPage();
+ SelenideElement selectedQualityGate = page.getSelectedQualityGate();
+ selectedQualityGate.should(Condition.hasText("Default"));
+ selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
+ }
+
+ @Test
+ public void should_display_custom() {
+ QualityGate customQualityGate = createCustomQualityGate("should_display_custom");
+ associateWithQualityGate(customQualityGate);
+
+ ProjectQualityGatePage page = openPage();
+ SelenideElement selectedQualityGate = page.getSelectedQualityGate();
+ selectedQualityGate.shouldNot(Condition.hasText("Default"));
+ selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
+ }
+
+ @Test
+ public void should_display_none() {
+ qualityGateClient().unsetDefault();
+
+ ProjectQualityGatePage page = openPage();
+ page.assertNotSelected();
+ }
+
+ @Test
+ public void should_set_custom() {
+ QualityGate customQualityGate = createCustomQualityGate("should_set_custom");
+
+ ProjectQualityGatePage page = openPage();
+ page.setQualityGate(customQualityGate.name());
+
+ SelenideElement selectedQualityGate = page.getSelectedQualityGate();
+ selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
+ }
+
+ @Test
+ public void should_set_default() {
+ QualityGate customQualityGate = createCustomQualityGate("should_set_default");
+ qualityGateClient().setDefault(customQualityGate.id());
+
+ ProjectQualityGatePage page = openPage();
+ page.setQualityGate(customQualityGate.name());
+
+ SelenideElement selectedQualityGate = page.getSelectedQualityGate();
+ selectedQualityGate.should(Condition.hasText("Default"));
+ selectedQualityGate.should(Condition.hasText(customQualityGate.name()));
+ }
+
+ @Test
+ @Ignore("find a way to select None")
+ public void should_set_none() {
+ qualityGateClient().unsetDefault();
+ QualityGate customQualityGate = createCustomQualityGate("should_set_none");
+ associateWithQualityGate(customQualityGate);
+
+ ProjectQualityGatePage page = openPage();
+ page.setQualityGate("");
+
+ page.assertNotSelected();
+ }
+
+ private ProjectQualityGatePage openPage() {
+ nav.logIn().submitCredentials("admin", "admin");
+ return nav.openProjectQualityGate("sample");
+ }
+
+ private static QualityGate createCustomQualityGate(String name) {
+ return qualityGateClient().create(name);
+ }
+
+ private void associateWithQualityGate(QualityGate qualityGate) {
+ wsClient.qualityGates().associateProject(new SelectWsRequest().setProjectKey("sample").setGateId(qualityGate.id()));
+ }
+
+ private static QualityGateClient qualityGateClient() {
+ return ORCHESTRATOR.getServer().adminWsClient().qualityGateClient();
+ }
+}
diff --git a/it/it-tests/src/test/java/pageobjects/Navigation.java b/it/it-tests/src/test/java/pageobjects/Navigation.java
index e615acdcded..d7d4a794614 100644
--- a/it/it-tests/src/test/java/pageobjects/Navigation.java
+++ b/it/it-tests/src/test/java/pageobjects/Navigation.java
@@ -56,6 +56,12 @@ public class Navigation extends ExternalResource {
return open(url, ProjectLinksPage.class);
}
+ public ProjectQualityGatePage openProjectQualityGate(String projectKey) {
+ // TODO encode projectKey
+ String url = "/project/quality_gate?id=" + projectKey;
+ return open(url, ProjectQualityGatePage.class);
+ }
+
public ProjectHistoryPage openProjectHistory(String projectKey) {
// TODO encode projectKey
String url = "/project/history?id=" + projectKey;
diff --git a/it/it-tests/src/test/java/pageobjects/ProjectQualityGatePage.java b/it/it-tests/src/test/java/pageobjects/ProjectQualityGatePage.java
new file mode 100644
index 00000000000..952f9640319
--- /dev/null
+++ b/it/it-tests/src/test/java/pageobjects/ProjectQualityGatePage.java
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package pageobjects;
+
+import com.codeborne.selenide.SelenideElement;
+
+import static com.codeborne.selenide.Condition.exist;
+import static com.codeborne.selenide.Selenide.$;
+
+public class ProjectQualityGatePage {
+
+ public ProjectQualityGatePage() {
+ $("#project-quality-gate").should(exist);
+ }
+
+ public SelenideElement getSelectedQualityGate() {
+ return $(".Select-value-label");
+ }
+
+ public void assertNotSelected() {
+ $(".Select-placeholder").should(exist);
+ $(".Select-value-label").shouldNot(exist);
+ }
+
+ public void setQualityGate(String name) {
+ $(".Select-input input").val(name).pressEnter();
+ }
+}