]> source.dussan.org Git - sonarqube.git/commitdiff
Add IT tests (#200)
authorPascal Mugnier <pascal.mugnier@sonarsource.com>
Tue, 1 May 2018 09:10:51 +0000 (11:10 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 3 May 2018 18:20:51 +0000 (20:20 +0200)
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/DocumentationPage.java [new file with mode: 0644]
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/Navigation.java
tests/build.gradle
tests/src/test/java/org/sonarqube/tests/Category4Suite.java
tests/src/test/java/org/sonarqube/tests/ui/DocumentationTest.java [new file with mode: 0644]
tests/src/test/java/org/sonarqube/tests/ui/UiExtensionsTest.java
tests/src/test/java/org/sonarqube/tests/ui/UiSuite.java [new file with mode: 0644]
tests/src/test/java/org/sonarqube/tests/ui/UiTest.java

diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/DocumentationPage.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/DocumentationPage.java
new file mode 100644 (file)
index 0000000..f2d7dab
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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 org.sonarqube.qa.util.pageobjects;
+
+import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.Selenide;
+
+public class DocumentationPage {
+
+  public DocumentationPage() {
+    Selenide.$(".markdown").shouldBe(Condition.visible);
+  }
+
+  public DocumentationPage shouldHaveLinks() {
+    Selenide.$(".api-documentation-results .list-group .list-group-item").exists();
+    return this;
+  }
+
+  public DocumentationPage selectLink(int index) {
+    Selenide.$$(".api-documentation-results .list-group .list-group-item").get(index).click();
+    return this;
+  }
+
+  public String getDocumentationContent() {
+    return Selenide.$(".markdown.cut-margins.boxed-group-inner").getText();
+  }
+
+}
index a0266da622a1ad945dc965ef06f647934a09c83b..9e37fd49ed3519689b5ff4d23075181fd8213b55 100644 (file)
@@ -86,6 +86,10 @@ public class Navigation {
     return open("/", Navigation.class);
   }
 
+  public DocumentationPage openDocumentation() {
+    return open("/documentation", DocumentationPage.class);
+  }
+
   public ProjectsPage openProjects() {
     return open("/projects", ProjectsPage.class);
   }
@@ -232,7 +236,7 @@ public class Navigation {
   }
 
   public WebhooksPage openProjectWebhooks(String projectKey) {
-    return open("/project/webhooks?id="+ projectKey, WebhooksPage.class);
+    return open("/project/webhooks?id=" + projectKey, WebhooksPage.class);
   }
 
   public LoginPage openLogin() {
index 2a6eb0c40e967347431b9891eadd9de2a0f8098d..8164dfebb19bbc145d0fce0d9d87b5149caa0741 100644 (file)
@@ -120,6 +120,7 @@ task integrationTest(type: Test) {
         includeTestsMatching 'org.sonarqube.tests.Category4Suite'
         includeTestsMatching 'org.sonarqube.tests.duplication.*Suite'
         includeTestsMatching 'org.sonarqube.tests.user.*Suite'
+        includeTestsMatching 'org.sonarqube.tests.ui.*Suite'
         includeTestsMatching 'org.sonarqube.tests.webhook.*Suite'
         break
       case 'Category5':
index b0296eaf19c2468340223e9bfe664067fc1fb905..378c1ea8736b0ab9446d42a4747b01f2d279b245 100644 (file)
@@ -59,10 +59,6 @@ import static util.ItUtils.xooPlugin;
   IssueExclusionsTest.class,
   // http
   HttpHeadersTest.class,
-  // ui
-  UiTest.class,
-  // ui extensions
-  UiExtensionsTest.class,
   WsLocalCallTest.class,
   WsTest.class,
   // quality profiles
diff --git a/tests/src/test/java/org/sonarqube/tests/ui/DocumentationTest.java b/tests/src/test/java/org/sonarqube/tests/ui/DocumentationTest.java
new file mode 100644 (file)
index 0000000..2627a22
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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 org.sonarqube.tests.ui;
+
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.qa.util.pageobjects.DocumentationPage;
+
+import static com.codeborne.selenide.Condition.visible;
+import static com.codeborne.selenide.Selenide.$;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class DocumentationTest {
+
+  @ClassRule
+  public static Orchestrator orchestrator = UiSuite.ORCHESTRATOR;
+
+  @Rule
+  public Tester tester = new Tester(orchestrator).disableOrganizations();
+
+  @Test
+  public void documentation_loads() {
+    tester.openBrowser().openDocumentation().shouldHaveLinks();
+  }
+
+  @Test
+  public void can_switch_between_content() {
+    DocumentationPage page = tester.openBrowser().openDocumentation().selectLink(0);
+    String content = page.getDocumentationContent();
+    page.selectLink(1);
+    assertThat(content).isNotEqualTo(page.getDocumentationContent());
+  }
+
+  @Test
+  public void display_not_found() {
+    tester.openBrowser().open("/documentation/foobarbaz");
+    $("#nonav").shouldBe(visible);
+  }
+
+}
index 8b0a88df99bb2173d22efb5f15af1e936e3eafb1..262d70e2ed0acee145cf08a83f27fa23a1c859b3 100644 (file)
@@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 public class UiExtensionsTest {
 
   @ClassRule
-  public static Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+  public static Orchestrator orchestrator = UiSuite.ORCHESTRATOR;
 
   @Rule
   public Tester tester = new Tester(orchestrator).disableOrganizations();
diff --git a/tests/src/test/java/org/sonarqube/tests/ui/UiSuite.java b/tests/src/test/java/org/sonarqube/tests/ui/UiSuite.java
new file mode 100644 (file)
index 0000000..e35917a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info 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 org.sonarqube.tests.ui;
+
+import com.sonar.orchestrator.Orchestrator;
+import org.junit.ClassRule;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+import static util.ItUtils.newOrchestratorBuilder;
+import static util.ItUtils.pluginArtifact;
+import static util.ItUtils.xooPlugin;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+  UiTest.class,
+  UiExtensionsTest.class,
+  DocumentationTest.class
+})
+public class UiSuite {
+
+  @ClassRule
+  public static final Orchestrator ORCHESTRATOR = newOrchestratorBuilder()
+    .addPlugin(xooPlugin())
+
+    // Used in UiExtensionsTest
+    .addPlugin(pluginArtifact("ui-extensions-plugin"))
+
+    .build();
+}
index ceead9bda023f33502560b8df40c93362431d463..dfc8a49b7d7354fd12f675f12f999038254fde6d 100644 (file)
@@ -27,7 +27,6 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.Tester;
 import org.sonarqube.qa.util.pageobjects.Navigation;
-import org.sonarqube.tests.Category4Suite;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsResponse;
 import util.ItUtils;
@@ -44,7 +43,7 @@ import static util.ItUtils.projectDir;
 public class UiTest {
 
   @ClassRule
-  public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+  public static final Orchestrator orchestrator = UiSuite.ORCHESTRATOR;
 
   @Rule
   public Tester tester = new Tester(orchestrator).disableOrganizations();