diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-12-19 14:07:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-19 14:07:32 +0100 |
commit | 2a91ab92dac4203e4410f5b2ab0ffbd1a6efac0e (patch) | |
tree | c711f5da56f2f4ef0dd90f897112372223ece703 /it | |
parent | afb6610a84b5f237bd036c900dd1a20ca8526311 (diff) | |
download | sonarqube-2a91ab92dac4203e4410f5b2ab0ffbd1a6efac0e.tar.gz sonarqube-2a91ab92dac4203e4410f5b2ab0ffbd1a6efac0e.zip |
SONAR-7674 Add Activity Stream interface (#1459)
Diffstat (limited to 'it')
-rw-r--r-- | it/it-tests/src/test/java/it/Category4Suite.java | 2 | ||||
-rw-r--r-- | it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java | 2 | ||||
-rw-r--r-- | it/it-tests/src/test/java/it/projectEvent/EventTest.java | 12 | ||||
-rw-r--r-- | it/it-tests/src/test/java/it/projectEvent/ProjectActivityPageTest.java (renamed from it/it-tests/src/test/java/it/projectAdministration/ProjectHistoryPageTest.java) | 66 | ||||
-rw-r--r-- | it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java | 9 | ||||
-rw-r--r-- | it/it-tests/src/test/java/pageobjects/Navigation.java | 12 | ||||
-rw-r--r-- | it/it-tests/src/test/java/pageobjects/ProjectActivityPage.java (renamed from it/it-tests/src/test/java/pageobjects/ProjectHistoryPage.java) | 35 | ||||
-rw-r--r-- | it/it-tests/src/test/java/pageobjects/ProjectAnalysisItem.java | 104 | ||||
-rw-r--r-- | it/it-tests/src/test/java/pageobjects/ProjectHistorySnapshotItem.java | 56 | ||||
-rw-r--r-- | it/it-tests/src/test/resources/projectEvent/EventTest/create_delete_standard_event.html | 114 |
10 files changed, 179 insertions, 233 deletions
diff --git a/it/it-tests/src/test/java/it/Category4Suite.java b/it/it-tests/src/test/java/it/Category4Suite.java index 4e6e08af980..db87ef57d3c 100644 --- a/it/it-tests/src/test/java/it/Category4Suite.java +++ b/it/it-tests/src/test/java/it/Category4Suite.java @@ -30,6 +30,7 @@ import it.duplication.CrossProjectDuplicationsTest; import it.duplication.DuplicationsTest; import it.duplication.NewDuplicationsTest; import it.projectEvent.EventTest; +import it.projectEvent.ProjectActivityPageTest; import it.projectSearch.SearchProjectsTest; import it.qualityProfile.QualityProfilesPageTest; import it.serverSystem.HttpHeadersTest; @@ -80,6 +81,7 @@ import static util.ItUtils.xooPlugin; PurgeTest.class, // project event EventTest.class, + ProjectActivityPageTest.class, // project search SearchProjectsTest.class, // http diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java index 044e342a07c..e9aa4ba0f99 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java +++ b/it/it-tests/src/test/java/it/projectAdministration/ProjectAdministrationTest.java @@ -128,7 +128,7 @@ public class ProjectAdministrationTest { // SONAR-4203 @Test - @Ignore("history page is not available yet") + @Ignore("refactor with wsClient") public void delete_version_of_multimodule_project() { GregorianCalendar today = new GregorianCalendar(); SonarScanner build = SonarScanner.create(projectDir("shared/xoo-multi-modules-sample")) diff --git a/it/it-tests/src/test/java/it/projectEvent/EventTest.java b/it/it-tests/src/test/java/it/projectEvent/EventTest.java index 062e2666966..749e27a1ec6 100644 --- a/it/it-tests/src/test/java/it/projectEvent/EventTest.java +++ b/it/it-tests/src/test/java/it/projectEvent/EventTest.java @@ -37,9 +37,8 @@ import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; import static util.ItUtils.projectDir; -import static util.selenium.Selenese.runSelenese; -@Ignore("history page is not available yet") +@Ignore("refactor using wsClient") public class EventTest { @ClassRule @@ -50,7 +49,6 @@ public class EventTest { orchestrator.resetData(); } - @Ignore("UUID column of Events is not handled with Ruby pages and WS") @Test public void old_ws_events_does_not_allow_creating_events_on_modules() { SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-multi-modules-sample")); @@ -72,14 +70,6 @@ public class EventTest { .setParam("category", "Foo"); } - @Ignore("UUID column of Events is not handled with Ruby pages and WS") - @Test - public void delete_standard_event() { - executeAnalysis(); - - runSelenese(orchestrator, "/projectEvent/EventTest/create_delete_standard_event.html"); - } - /** * SONAR-3308 */ diff --git a/it/it-tests/src/test/java/it/projectAdministration/ProjectHistoryPageTest.java b/it/it-tests/src/test/java/it/projectEvent/ProjectActivityPageTest.java index f7e2afdcd49..cc2d7063078 100644 --- a/it/it-tests/src/test/java/it/projectAdministration/ProjectHistoryPageTest.java +++ b/it/it-tests/src/test/java/it/projectEvent/ProjectActivityPageTest.java @@ -17,7 +17,7 @@ * 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; +package it.projectEvent; import com.sonar.orchestrator.Orchestrator; import com.sonar.orchestrator.build.SonarScanner; @@ -28,15 +28,12 @@ import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import pageobjects.Navigation; -import pageobjects.ProjectHistoryPage; -import pageobjects.ProjectHistorySnapshotItem; +import pageobjects.ProjectActivityPage; +import pageobjects.ProjectAnalysisItem; -import static com.codeborne.selenide.Condition.exist; -import static com.codeborne.selenide.Condition.text; -import static com.codeborne.selenide.Selenide.confirm; import static util.ItUtils.projectDir; -public class ProjectHistoryPageTest { +public class ProjectActivityPageTest { @ClassRule public static Orchestrator ORCHESTRATOR = Category1Suite.ORCHESTRATOR; @@ -45,47 +42,54 @@ public class ProjectHistoryPageTest { public Navigation nav = Navigation.get(ORCHESTRATOR); @Before - public void setUp() { + public void setUp() throws Exception { ORCHESTRATOR.resetData(); - analyzeProject("shared/xoo-history-v1", "2014-10-19"); - analyzeProject("shared/xoo-history-v2", "2014-11-13"); } @Test public void should_list_snapshots() { - ProjectHistoryPage page = openPage(); - - page.getSnapshots().shouldHaveSize(2); + analyzeProject("shared/xoo-history-v1", "2014-10-19"); + analyzeProject("shared/xoo-history-v2", "2014-11-13"); - List<ProjectHistorySnapshotItem> snapshots = page.getSnapshotsAsItems(); + ProjectActivityPage page = openPage(); + page.getAnalyses().shouldHaveSize(2); - snapshots.get(0).getVersionText().shouldBe(text("1.0-SNAPSHOT")); - snapshots.get(0).getDeleteButton().shouldNot(exist); + List<ProjectAnalysisItem> analyses = page.getAnalysesAsItems(); + analyses.get(0) + .shouldHaveEventWithText("1.0-SNAPSHOT") + .shouldNotHaveDeleteButton(); - snapshots.get(1).getVersionText().shouldBe(text("0.9-SNAPSHOT")); - snapshots.get(1).getDeleteButton().should(exist); + analyses.get(1) + .shouldHaveEventWithText("0.9-SNAPSHOT") + .shouldHaveDeleteButton(); } @Test - public void should_delete_snapshot() { - ProjectHistoryPage page = openPage(); - - page.getSnapshots().shouldHaveSize(2); - - page.getSnapshotsAsItems().get(1).clickDelete(); - confirm(); + public void add_change_delete_custom_event() { + analyzeProject(); + openPage().getLastAnalysis() + .addCustomEvent("foo") + .changeLastEvent("bar") + .deleteLastEvent(); + } - page.checkAlertDisplayed(); - page.getSnapshots().shouldHaveSize(1); + @Test + public void delete_analysis() { + analyzeProject(); + analyzeProject(); + openPage().getFirstAnalysis().delete(); } - private ProjectHistoryPage openPage() { + private ProjectActivityPage openPage() { nav.logIn().submitCredentials("admin", "admin"); - return nav.openProjectHistory("sample"); + return nav.openProjectActivity("sample"); + } + + private static void analyzeProject() { + ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample"))); } private static void analyzeProject(String path, String date) { - ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir(path)) - .setProperties("sonar.projectDate", date)); + ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir(path)).setProperties("sonar.projectDate", date)); } } diff --git a/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java b/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java index ef5fdf25a82..5ee509687fb 100644 --- a/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java +++ b/it/it-tests/src/test/java/it/qualityGate/QualityGateUiTest.java @@ -27,13 +27,14 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; -import org.junit.Ignore; import org.junit.Test; import org.sonar.wsclient.qualitygate.NewCondition; import org.sonar.wsclient.qualitygate.QualityGate; import org.sonar.wsclient.qualitygate.QualityGateClient; import org.sonar.wsclient.qualitygate.QualityGateCondition; import org.sonar.wsclient.qualitygate.UpdateCondition; +import pageobjects.Navigation; +import pageobjects.ProjectActivityPage; import util.ItUtils; import static util.ItUtils.projectDir; @@ -70,7 +71,6 @@ public class QualityGateUiTest { * SONAR-3326 */ @Test - @Ignore("history page is not available yet") public void display_alerts_correctly_in_history_page() { QualityGateClient qgClient = qgClient(); QualityGate qGate = qgClient.create("AlertsForHistory"); @@ -83,7 +83,10 @@ public class QualityGateUiTest { qgClient.updateCondition(UpdateCondition.create(lowThresholds.id()).metricKey("lines").operator("GT").warningThreshold("5000").errorThreshold("5000")); scanSampleWithDate("2012-01-02"); - runSelenese(orchestrator, "/qualityGate/QualityGateUiTest/should-display-alerts-correctly-history-page.html"); + ProjectActivityPage page = Navigation.get(orchestrator).openProjectActivity("sample"); + page + .assertFirstAnalysisOfTheDayHasText("2012-01-02", "Green (was Orange)") + .assertFirstAnalysisOfTheDayHasText("2012-01-01", "Orange"); qgClient.unsetDefault(); qgClient.destroy(qGate.id()); diff --git a/it/it-tests/src/test/java/pageobjects/Navigation.java b/it/it-tests/src/test/java/pageobjects/Navigation.java index 840f4b2f658..e9c23d63f14 100644 --- a/it/it-tests/src/test/java/pageobjects/Navigation.java +++ b/it/it-tests/src/test/java/pageobjects/Navigation.java @@ -79,18 +79,18 @@ public class Navigation extends ExternalResource { return open(url, ProjectQualityGatePage.class); } - public ProjectHistoryPage openProjectHistory(String projectKey) { - // TODO encode projectKey - String url = "/project/history?id=" + projectKey; - return open(url, ProjectHistoryPage.class); - } - public ProjectKeyPage openProjectKey(String projectKey) { // TODO encode projectKey String url = "/project/key?id=" + projectKey; return open(url, ProjectKeyPage.class); } + public ProjectActivityPage openProjectActivity(String projectKey) { + // TODO encode projectKey + String url = "/project/activity?id=" + projectKey; + return open(url, ProjectActivityPage.class); + } + public BackgroundTasksPage openBackgroundTasksPage() { return open("/background_tasks", BackgroundTasksPage.class); } diff --git a/it/it-tests/src/test/java/pageobjects/ProjectHistoryPage.java b/it/it-tests/src/test/java/pageobjects/ProjectActivityPage.java index 83b0f5c9241..8acf8920a2b 100644 --- a/it/it-tests/src/test/java/pageobjects/ProjectHistoryPage.java +++ b/it/it-tests/src/test/java/pageobjects/ProjectActivityPage.java @@ -19,32 +19,45 @@ */ package pageobjects; +import com.codeborne.selenide.Condition; import com.codeborne.selenide.ElementsCollection; import java.util.List; import java.util.stream.Collectors; -import static com.codeborne.selenide.Condition.exist; +import static com.codeborne.selenide.Condition.hasText; import static com.codeborne.selenide.Selenide.$; import static com.codeborne.selenide.Selenide.$$; -public class ProjectHistoryPage { +public class ProjectActivityPage { - public ProjectHistoryPage() { - $("#project-history").should(exist); + public ProjectActivityPage() { + $("#project-activity").should(Condition.exist); } - public ElementsCollection getSnapshots() { - return $$("tr.snapshot"); + public ElementsCollection getAnalyses() { + return $$(".project-activity-analysis"); } - public List<ProjectHistorySnapshotItem> getSnapshotsAsItems() { - return getSnapshots() + public List<ProjectAnalysisItem> getAnalysesAsItems() { + return getAnalyses() .stream() - .map(ProjectHistorySnapshotItem::new) + .map(ProjectAnalysisItem::new) .collect(Collectors.toList()); } - public void checkAlertDisplayed() { - $("#info:not(.hidden)").should(exist); + public ProjectAnalysisItem getLastAnalysis() { + return new ProjectAnalysisItem($(".project-activity-analysis")); + } + + public ProjectAnalysisItem getFirstAnalysis() { + return new ProjectAnalysisItem($$(".project-activity-analysis").last()); + } + + public ProjectActivityPage assertFirstAnalysisOfTheDayHasText(String day, String text) { + $("#project-activity") + .find(".project-activity-day[data-day=\"" + day + "\"]") + .find(".project-activity-analysis") + .should(hasText(text)); + return this; } } diff --git a/it/it-tests/src/test/java/pageobjects/ProjectAnalysisItem.java b/it/it-tests/src/test/java/pageobjects/ProjectAnalysisItem.java new file mode 100644 index 00000000000..84de55eea95 --- /dev/null +++ b/it/it-tests/src/test/java/pageobjects/ProjectAnalysisItem.java @@ -0,0 +1,104 @@ +/* + * 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.Condition; +import com.codeborne.selenide.SelenideElement; + +import static com.codeborne.selenide.Condition.text; +import static com.codeborne.selenide.Condition.visible; +import static com.codeborne.selenide.Selenide.$; + +public class ProjectAnalysisItem { + + private final SelenideElement elt; + + public ProjectAnalysisItem(SelenideElement elt) { + this.elt = elt; + } + + public ProjectAnalysisItem shouldHaveEventWithText(String text) { + elt.find(".project-activity-events").shouldHave(Condition.text(text)); + return this; + } + + public ProjectAnalysisItem shouldHaveDeleteButton() { + elt.find(".js-delete-analysis").shouldBe(visible); + return this; + } + + public ProjectAnalysisItem shouldNotHaveDeleteButton() { + elt.find(".js-delete-analysis").shouldNotBe(visible); + return this; + } + + public void delete() { + elt.find(".js-delete-analysis").click(); + + SelenideElement modal = $(".modal"); + modal.shouldBe(visible); + modal.find("button[type=\"submit\"]").click(); + + elt.shouldNotBe(visible); + } + + public ProjectAnalysisItem addCustomEvent(String name) { + elt.find(".js-create").click(); + elt.find(".js-add-event").click(); + + SelenideElement modal = $(".modal"); + modal.shouldBe(visible); + modal.find("input").setValue(name); + modal.find("button[type=\"submit\"]").click(); + + elt.find(".project-activity-event:last-child").shouldHave(text(name)); + + return this; + } + + public ProjectAnalysisItem changeLastEvent(String newName) { + SelenideElement lastEvent = elt.find(".project-activity-event:last-child"); + lastEvent.find(".js-change-event").click(); + + SelenideElement modal = $(".modal"); + modal.shouldBe(visible); + modal.find("input").setValue(newName); + modal.find("button[type=\"submit\"]").click(); + + lastEvent.shouldHave(text(newName)); + + return this; + } + + public ProjectAnalysisItem deleteLastEvent() { + int eventsCount = elt.findAll(".project-activity-event").size(); + + SelenideElement lastEvent = elt.find(".project-activity-event:last-child"); + lastEvent.find(".js-delete-event").click(); + + SelenideElement modal = $(".modal"); + modal.shouldBe(visible); + modal.find("button[type=\"submit\"]").click(); + + elt.findAll(".project-activity-event").shouldHaveSize(eventsCount - 1); + + return this; + } +} diff --git a/it/it-tests/src/test/java/pageobjects/ProjectHistorySnapshotItem.java b/it/it-tests/src/test/java/pageobjects/ProjectHistorySnapshotItem.java deleted file mode 100644 index d265e98f00b..00000000000 --- a/it/it-tests/src/test/java/pageobjects/ProjectHistorySnapshotItem.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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 org.openqa.selenium.NoSuchElementException; - -public class ProjectHistorySnapshotItem { - - private final SelenideElement elt; - - public ProjectHistorySnapshotItem(SelenideElement elt) { - this.elt = elt; - } - - public SelenideElement getVersionText() { - return elt.$("td:nth-child(5) table td:nth-child(1)"); - } - - public SelenideElement getType() { - try { - return elt.$(".js-type"); - } catch (NoSuchElementException e) { - return null; - } - } - - public SelenideElement getUrl() { - return elt.$(".js-url"); - } - - public SelenideElement getDeleteButton() { - return elt.$("td:nth-child(9) input[type=\"submit\"]"); - } - - public void clickDelete() { - getDeleteButton().click(); - } -} diff --git a/it/it-tests/src/test/resources/projectEvent/EventTest/create_delete_standard_event.html b/it/it-tests/src/test/resources/projectEvent/EventTest/create_delete_standard_event.html deleted file mode 100644 index ae697da4326..00000000000 --- a/it/it-tests/src/test/resources/projectEvent/EventTest/create_delete_standard_event.html +++ /dev/null @@ -1,114 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head profile="http://selenium-ide.openqa.org/profiles/test-case"> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> - <title>create_delete_standard_event</title> -</head> -<body> -<table cellpadding="1" cellspacing="1" border="1"> - <thead> - <tr> - <td rowspan="1" colspan="3">create_delete_standard_event</td> - </tr> - </thead> - <tbody> - <tr> - <td>open</td> - <td>/sessions/logout</td> - <td></td> -</tr> -<tr> - <td>open</td> - <td>/sessions/login</td> - <td></td> -</tr> -<tr> - <td>type</td> - <td>login</td> - <td>admin</td> -</tr> -<tr> - <td>type</td> - <td>password</td> - <td>admin</td> -</tr> -<tr> - <td>clickAndWait</td> - <td>commit</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>css=.js-user-authenticated</td> - <td></td> -</tr> -<tr> - <td>open</td> - <td>/project/history?id=sample</td> - <td></td> -</tr> -<tr> - <td>click</td> - <td>link=Create</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>create_event_name_0</td> - <td></td> -</tr> -<tr> - <td>type</td> - <td>create_event_name_0</td> - <td>EventToBeDeleted</td> -</tr> -<tr> - <td>clickAndWait</td> - <td>create_save_event_0</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>infomsg</td> - <td></td> -</tr> -<tr> - <td>waitForText</td> - <td>infomsg</td> - <td>Event 'EventToBeDeleted' was created.</td> -</tr> -<tr> - <td>assertElementPresent</td> - <td>//td[text()='EventToBeDeleted']</td> - <td></td> -</tr> -<tr> - <td>clickAndWait</td> - <td>link=Remove</td> - <td></td> -</tr> -<tr> - <td>assertConfirmation</td> - <td>Are you sure you want to remove 'EventToBeDeleted' from this snapshot?</td> - <td></td> -</tr> -<tr> - <td>waitForElementPresent</td> - <td>infomsg</td> - <td></td> -</tr> -<tr> - <td>waitForText</td> - <td>infomsg</td> - <td>Event 'EventToBeDeleted' was deleted.</td> -</tr> -<tr> - <td>assertElementNotPresent</td> - <td>//td[text()='EventToBeDeleted']</td> - <td></td> -</tr> -</tbody> -</table> -</body> -</html> |