]> source.dussan.org Git - sonarqube.git/commitdiff
Activate integration test ProjectKeyUpdatePageTest
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 14 Nov 2017 13:30:35 +0000 (14:30 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 16 Nov 2017 16:36:07 +0000 (17:36 +0100)
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/pageobjects/ProjectKeyPage.java
tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdatePageTest.java [new file with mode: 0644]
tests/src/test/java/org/sonarqube/tests/project/ProjectSuite.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectAdministrationTest.java
tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectKeyUpdatePageTest.java [deleted file]

index cfc2e8137ab177bdcb16731da2f9fbf3d4b6186d..02438a9bf6b8b4277daf4e6bbffe1797d20ffda1 100644 (file)
@@ -94,7 +94,9 @@ public class ProjectKeyPage {
   }
 
   public ProjectKeyPage assertSuccessfulBulkUpdate() {
-    Selenide.$("#project-key-bulk-update").$(".alert.alert-success").shouldBe(Condition.visible);
+    Selenide.$(".process-spinner")
+      .shouldBe(Condition.visible)
+      .shouldHave(Condition.text("The key has successfully been updated for all required resources"));
     return this;
   }
 }
diff --git a/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdatePageTest.java b/tests/src/test/java/org/sonarqube/tests/project/ProjectKeyUpdatePageTest.java
new file mode 100644 (file)
index 0000000..8f2fbbd
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.project;
+
+import com.codeborne.selenide.Selenide;
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarScanner;
+import org.junit.Before;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.qa.util.pageobjects.ProjectKeyPage;
+import org.sonarqube.ws.client.PostRequest;
+
+import static com.codeborne.selenide.Condition.visible;
+import static com.codeborne.selenide.Selenide.$;
+import static com.codeborne.selenide.WebDriverRunner.url;
+import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.projectDir;
+
+public class ProjectKeyUpdatePageTest {
+
+  @ClassRule
+  public static Orchestrator orchestrator = ProjectSuite.ORCHESTRATOR;
+
+  @Rule
+  public Tester tester = new Tester(orchestrator);
+
+  @Before
+  public void setUp() throws Exception {
+    tester.wsClient().users().skipOnboardingTutorial();
+  }
+
+  @Test
+  public void change_key_when_no_modules() {
+    createProject("sample");
+
+    ProjectKeyPage page = openPage("sample");
+    page.assertSimpleUpdate().trySimpleUpdate("another");
+
+    Selenide.Wait().until(driver -> driver.getCurrentUrl().endsWith("/project/key?id=another"));
+  }
+
+  @Test
+  public void fail_to_change_key_when_no_modules() {
+    createProject("sample");
+    createProject("another");
+
+    ProjectKeyPage page = openPage("sample");
+    page.assertSimpleUpdate().trySimpleUpdate("another");
+
+    $(".process-spinner").shouldBe(visible);
+    Selenide.Wait().until(driver -> driver.getCurrentUrl().endsWith("/project/key?id=sample"));
+  }
+
+  @Test
+  public void change_key_of_multi_modules_project() {
+    analyzeProject("shared/xoo-multi-modules-sample", "sample");
+
+    ProjectKeyPage page = openPage("sample");
+    page.openFineGrainedUpdate().tryFineGrainedUpdate("sample", "another");
+
+    Selenide.Wait().until(driver -> driver.getCurrentUrl().endsWith("/project/key?id=another"));
+  }
+
+  @Test
+  public void fail_to_change_key_of_multi_modules_project() {
+    analyzeProject("shared/xoo-multi-modules-sample", "sample");
+    createProject("another");
+
+    ProjectKeyPage page = openPage("sample");
+    page.openFineGrainedUpdate().tryFineGrainedUpdate("sample", "another");
+
+    $(".process-spinner").shouldBe(visible);
+    assertThat(url()).endsWith("/project/key?id=sample");
+  }
+
+  @Test
+  public void change_key_of_module_of_multi_modules_project() {
+    analyzeProject("shared/xoo-multi-modules-sample", "sample");
+
+    ProjectKeyPage page = openPage("sample");
+    page.openFineGrainedUpdate().tryFineGrainedUpdate("sample:module_a:module_a1", "another");
+
+    $("#update-key-confirmation-form").shouldNotBe(visible);
+
+    tester.openBrowser().openProjectKey("another");
+    assertThat(url()).endsWith("/project/key?id=another");
+  }
+
+  @Test
+  public void fail_to_change_key_of_module_of_multi_modules_project() {
+    analyzeProject("shared/xoo-multi-modules-sample", "sample");
+    createProject("another");
+
+    ProjectKeyPage page = openPage("sample");
+    page.openFineGrainedUpdate().tryFineGrainedUpdate("sample:module_a:module_a1", "another");
+
+    $(".process-spinner").shouldBe(visible);
+  }
+
+  @Test
+  public void bulk_change() {
+    analyzeProject("shared/xoo-multi-modules-sample", "sample");
+
+    ProjectKeyPage page = openPage("sample");
+    page.assertBulkChange().simulateBulkChange("sample", "another");
+
+    $("#bulk-update-results").shouldBe(visible);
+    page.assertBulkChangeSimulationResult("sample", "another")
+      .assertBulkChangeSimulationResult("sample:module_a:module_a1", "another:module_a:module_a1");
+
+    page
+      .confirmBulkUpdate()
+      .assertSuccessfulBulkUpdate();
+  }
+
+  @Test
+  public void fail_to_bulk_change_because_no_changed_key() {
+    analyzeProject("shared/xoo-multi-modules-sample", "sample");
+
+    ProjectKeyPage page = openPage("sample");
+    page.assertBulkChange().simulateBulkChange("random", "another");
+
+    $("#bulk-update-nothing").shouldBe(visible);
+    $("#bulk-update-results").shouldNotBe(visible);
+  }
+
+  @Test
+  public void fail_to_bulk_change_because_of_duplications() {
+    analyzeProject("shared/xoo-multi-modules-sample", "sample");
+
+    ProjectKeyPage page = openPage("sample");
+    page.assertBulkChange().simulateBulkChange("module_a1", "module_a2");
+
+    $("#bulk-update-duplicate").shouldBe(visible);
+    $("#bulk-update-results").shouldBe(visible);
+
+    page.assertBulkChangeSimulationResult("sample:module_a:module_a1", "sample:module_a:module_a2")
+      .assertDuplicated("sample:module_a:module_a1");
+  }
+
+  private ProjectKeyPage openPage(String projectKey) {
+    return tester.openBrowser()
+      .logIn()
+      .submitCredentials("admin", "admin")
+      .openProjectKey(projectKey);
+  }
+
+  private void createProject(String projectKey) {
+    tester.wsClient().wsConnector().call(new PostRequest("api/projects/create")
+      .setParam("key", projectKey)
+      .setParam("name", projectKey));
+  }
+
+  private void analyzeProject(String path, String projectKey) {
+    orchestrator.executeBuild(SonarScanner.create(projectDir(path))
+      .setProjectKey(projectKey));
+  }
+}
index 58dd29c92894f0c656bf661e4333ba4f19eadc1f..65121e03c67c23399b372d109c4ffc48b98a3b76 100644 (file)
@@ -35,6 +35,7 @@ import static util.ItUtils.xooPlugin;
   ProjectDeletionTest.class,
   ProjectFilterTest.class,
   ProjectKeyUpdateTest.class,
+  ProjectKeyUpdatePageTest.class,
   ProjectLeakPageTest.class,
   ProjectLinksTest.class,
   ProjectListTest.class,
index 92fac69dda2355b0568d123570fe734195486687..2e2c5a4551db7550a2059fbc1c4d227f0748344b 100644 (file)
@@ -44,6 +44,9 @@ import static com.codeborne.selenide.Selenide.$;
 import static org.assertj.core.api.Assertions.assertThat;
 import static util.ItUtils.projectDir;
 
+/**
+ * TODO to be split and moved to project package
+ */
 public class ProjectAdministrationTest {
 
   @ClassRule
diff --git a/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectKeyUpdatePageTest.java b/tests/src/test/java/org/sonarqube/tests/projectAdministration/ProjectKeyUpdatePageTest.java
deleted file mode 100644 (file)
index b907898..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 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.projectAdministration;
-
-import com.sonar.orchestrator.Orchestrator;
-import com.sonar.orchestrator.build.SonarScanner;
-import org.sonarqube.tests.Category1Suite;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsClient;
-import org.sonarqube.qa.util.pageobjects.Navigation;
-import org.sonarqube.qa.util.pageobjects.ProjectKeyPage;
-
-import static com.codeborne.selenide.Condition.visible;
-import static com.codeborne.selenide.Selenide.$;
-import static com.codeborne.selenide.WebDriverRunner.url;
-import static org.assertj.core.api.Assertions.assertThat;
-import static util.ItUtils.newAdminWsClient;
-import static util.ItUtils.projectDir;
-
-public class ProjectKeyUpdatePageTest {
-
-  @ClassRule
-  public static Orchestrator ORCHESTRATOR = Category1Suite.ORCHESTRATOR;
-
-  private static WsClient wsClient;
-
-  @BeforeClass
-  public static void setUp() {
-    wsClient = newAdminWsClient(ORCHESTRATOR);
-  }
-
-  @Before
-  public void cleanUp() {
-    ORCHESTRATOR.resetData();
-  }
-
-  private Navigation nav = Navigation.create(ORCHESTRATOR);
-
-  @Test
-  public void change_key_when_no_modules() {
-    createProject("sample");
-
-    ProjectKeyPage page = openPage("sample");
-    page.assertSimpleUpdate().trySimpleUpdate("another");
-
-    assertThat(url()).endsWith("/project/key?id=another");
-  }
-
-  @Test
-  public void fail_to_change_key_when_no_modules() {
-    createProject("sample");
-    createProject("another");
-
-    ProjectKeyPage page = openPage("sample");
-    page.assertSimpleUpdate().trySimpleUpdate("another");
-
-    $(".alert.alert-danger").shouldBe(visible);
-    assertThat(url()).endsWith("/project/key?id=sample");
-  }
-
-  @Test
-  public void change_key_of_multi_modules_project() {
-    analyzeProject("shared/xoo-multi-modules-sample", "sample");
-
-    ProjectKeyPage page = openPage("sample");
-    page.openFineGrainedUpdate().tryFineGrainedUpdate("sample", "another");
-
-    assertThat(url()).endsWith("/project/key?id=another");
-  }
-
-  @Test
-  public void fail_to_change_key_of_multi_modules_project() {
-    analyzeProject("shared/xoo-multi-modules-sample", "sample");
-    createProject("another");
-
-    ProjectKeyPage page = openPage("sample");
-    page.openFineGrainedUpdate().tryFineGrainedUpdate("sample", "another");
-
-    $(".alert.alert-danger").shouldBe(visible);
-    assertThat(url()).endsWith("/project/key?id=sample");
-  }
-
-  @Test
-  public void change_key_of_module_of_multi_modules_project() {
-    analyzeProject("shared/xoo-multi-modules-sample", "sample");
-
-    ProjectKeyPage page = openPage("sample");
-    page.openFineGrainedUpdate().tryFineGrainedUpdate("sample:module_a:module_a1", "another");
-
-    $("#update-key-confirmation-form").shouldNotBe(visible);
-
-    nav.openProjectKey("another");
-    assertThat(url()).endsWith("/project/key?id=another");
-  }
-
-  @Test
-  public void fail_to_change_key_of_module_of_multi_modules_project() {
-    analyzeProject("shared/xoo-multi-modules-sample", "sample");
-    createProject("another");
-
-    ProjectKeyPage page = openPage("sample");
-    page.openFineGrainedUpdate().tryFineGrainedUpdate("sample:module_a:module_a1", "another");
-
-    $(".alert.alert-danger").shouldBe(visible);
-  }
-
-  @Test
-  public void bulk_change() {
-    analyzeProject("shared/xoo-multi-modules-sample", "sample");
-
-    ProjectKeyPage page = openPage("sample");
-    page.assertBulkChange().simulateBulkChange("sample", "another");
-
-    $("#bulk-update-results").shouldBe(visible);
-    page.assertBulkChangeSimulationResult("sample", "another")
-      .assertBulkChangeSimulationResult("sample:module_a:module_a1", "another:module_a:module_a1");
-
-    page.confirmBulkUpdate().assertSuccessfulBulkUpdate();
-  }
-
-  @Test
-  public void fail_to_bulk_change_because_no_changed_key() {
-    analyzeProject("shared/xoo-multi-modules-sample", "sample");
-
-    ProjectKeyPage page = openPage("sample");
-    page.assertBulkChange().simulateBulkChange("random", "another");
-
-    $("#bulk-update-nothing").shouldBe(visible);
-    $("#bulk-update-results").shouldNotBe(visible);
-  }
-
-  @Test
-  public void fail_to_bulk_change_because_of_duplications() {
-    analyzeProject("shared/xoo-multi-modules-sample", "sample");
-
-    ProjectKeyPage page = openPage("sample");
-    page.assertBulkChange().simulateBulkChange("module_a1", "module_a2");
-
-    $("#bulk-update-duplicate").shouldBe(visible);
-    $("#bulk-update-results").shouldBe(visible);
-
-    page.assertBulkChangeSimulationResult("sample:module_a:module_a1", "sample:module_a:module_a2")
-      .assertDuplicated("sample:module_a:module_a1");
-  }
-
-  private ProjectKeyPage openPage(String projectKey) {
-    nav.logIn().submitCredentials("admin", "admin");
-    return nav.openProjectKey(projectKey);
-  }
-
-  private static void createProject(String projectKey) {
-    wsClient.wsConnector().call(new PostRequest("api/projects/create")
-      .setParam("key", projectKey)
-      .setParam("name", projectKey));
-  }
-
-  private static void analyzeProject(String path, String projectKey) {
-    ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir(path))
-      .setProjectKey(projectKey));
-  }
-}