diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2016-11-07 15:48:53 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2016-11-07 15:49:00 +0100 |
commit | 271a84b5c2d3aa727d2eb4a2cc24195a8a931151 (patch) | |
tree | 3e1dfb470a3251f9d2214d27eef03eda53a86187 /it | |
parent | 5bcb1ae9ef1d237f312c7a64a96757843b9e3f20 (diff) | |
download | sonarqube-271a84b5c2d3aa727d2eb4a2cc24195a8a931151.tar.gz sonarqube-271a84b5c2d3aa727d2eb4a2cc24195a8a931151.zip |
SONAR-8300 add ITs
Diffstat (limited to 'it')
6 files changed, 226 insertions, 0 deletions
diff --git a/it/it-tests/src/test/java/it/Category1Suite.java b/it/it-tests/src/test/java/it/Category1Suite.java index efc2f42d24a..7190c2f5f9e 100644 --- a/it/it-tests/src/test/java/it/Category1Suite.java +++ b/it/it-tests/src/test/java/it/Category1Suite.java @@ -39,6 +39,7 @@ import it.projectAdministration.BackgroundTasksTest; import it.projectAdministration.BulkDeletionTest; import it.projectAdministration.ProjectAdministrationTest; import it.projectAdministration.ProjectLinksPageTest; +import it.projectSearch.ProjectsPageTest; import it.qualityGate.QualityGateNotificationTest; import it.qualityGate.QualityGateTest; import it.qualityGate.QualityGateUiTest; @@ -87,6 +88,7 @@ import static util.ItUtils.xooPlugin; // measure ProjectMeasuresPageTest.class, ProjectDashboardTest.class, + ProjectsPageTest.class, MeasuresWsTest.class, // measure history DifferentialPeriodsTest.class, diff --git a/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java b/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java new file mode 100644 index 00000000000..235a0c0a50f --- /dev/null +++ b/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java @@ -0,0 +1,81 @@ +/* + * 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.projectSearch; + +import com.sonar.orchestrator.Orchestrator; +import com.sonar.orchestrator.build.SonarScanner; +import it.Category1Suite; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import pageobjects.Navigation; +import pageobjects.projects.ProjectsPage; + +import static util.ItUtils.projectDir; + +public class ProjectsPageTest { + + @ClassRule + public static Orchestrator ORCHESTRATOR = Category1Suite.ORCHESTRATOR; + + @Rule + public Navigation nav = Navigation.get(ORCHESTRATOR); + + @BeforeClass + public static void setUp() { + ORCHESTRATOR.resetData(); + ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("shared/xoo-sample")).setProjectKey("key-foo")); + ORCHESTRATOR.executeBuild(SonarScanner.create(projectDir("duplications/file-duplications")).setProjectKey("key-bar")); + } + + @Test + public void should_display_projects() { + ProjectsPage page = nav.openProjects(); + page.shouldHaveTotal(2); + page.getProjectByKey("key-foo") + .shouldHaveMeasure("reliability_rating", "A") + .shouldHaveMeasure("security_rating", "A") + .shouldHaveMeasure("sqale_rating", "A") + .shouldHaveMeasure("duplicated_lines_density", "0.0%") + .shouldHaveMeasure("ncloc", "13") + .shouldHaveMeasure("ncloc", "Xoo"); + } + + @Test + public void should_display_facets() { + ProjectsPage page = nav.openProjects(); + page.getFacetByProperty("duplications") + .shouldHaveValue("1", "1") + .shouldHaveValue("2", "1") + .shouldHaveValue("3", "1") + .shouldHaveValue("4", "1") + .shouldHaveValue("5", "1"); + } + + @Test + public void should_filter_using_facet() { + ProjectsPage page = nav.openProjects(); + page.shouldHaveTotal(2); + page.getFacetByProperty("duplications").selectValue("3"); + page.shouldHaveTotal(1); + } + +} diff --git a/it/it-tests/src/test/java/pageobjects/Navigation.java b/it/it-tests/src/test/java/pageobjects/Navigation.java index 071df520c6e..f3f9102b55a 100644 --- a/it/it-tests/src/test/java/pageobjects/Navigation.java +++ b/it/it-tests/src/test/java/pageobjects/Navigation.java @@ -30,6 +30,7 @@ import javax.annotation.Nullable; import org.junit.rules.ExternalResource; import org.openqa.selenium.By; import pageobjects.licenses.LicensesPage; +import pageobjects.projects.ProjectsPage; import pageobjects.settings.SettingsPage; import static com.codeborne.selenide.Selenide.$; @@ -55,6 +56,10 @@ public class Navigation extends ExternalResource { return open("/", Navigation.class); } + public ProjectsPage openProjects() { + return open("/projects", ProjectsPage.class); + } + public ProjectDashboardPage openProjectDashboard(String projectKey) { // TODO encode projectKey String url = "/dashboard?id=" + projectKey; diff --git a/it/it-tests/src/test/java/pageobjects/projects/FacetItem.java b/it/it-tests/src/test/java/pageobjects/projects/FacetItem.java new file mode 100644 index 00000000000..936e64195f5 --- /dev/null +++ b/it/it-tests/src/test/java/pageobjects/projects/FacetItem.java @@ -0,0 +1,41 @@ +/* + * 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.projects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; + +public class FacetItem { + + private final SelenideElement elt; + + public FacetItem(SelenideElement elt) { + this.elt = elt; + } + + public FacetItem shouldHaveValue(String key, String value) { + this.elt.$(".facet[data-key=\"" + key + "\"] .facet-stat").shouldHave(Condition.text(value)); + return this; + } + + public void selectValue(String key) { + this.elt.$(".facet[data-key=\"" + key + "\"]").click(); + } +} diff --git a/it/it-tests/src/test/java/pageobjects/projects/ProjectItem.java b/it/it-tests/src/test/java/pageobjects/projects/ProjectItem.java new file mode 100644 index 00000000000..723b8450566 --- /dev/null +++ b/it/it-tests/src/test/java/pageobjects/projects/ProjectItem.java @@ -0,0 +1,37 @@ +/* + * 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.projects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.SelenideElement; + +public class ProjectItem { + + private final SelenideElement elt; + + public ProjectItem(SelenideElement elt) { + this.elt = elt; + } + + public ProjectItem shouldHaveMeasure(String metricKey, String value) { + this.elt.$(".project-card-measure[data-key=\"" + metricKey + "\"]").shouldHave(Condition.text(value)); + return this; + } +} diff --git a/it/it-tests/src/test/java/pageobjects/projects/ProjectsPage.java b/it/it-tests/src/test/java/pageobjects/projects/ProjectsPage.java new file mode 100644 index 00000000000..a87863c0d18 --- /dev/null +++ b/it/it-tests/src/test/java/pageobjects/projects/ProjectsPage.java @@ -0,0 +1,60 @@ +/* + * 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.projects; + +import com.codeborne.selenide.Condition; +import com.codeborne.selenide.ElementsCollection; +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.$; +import static com.codeborne.selenide.Selenide.$$; + +public class ProjectsPage { + + public ProjectsPage() { + $("#projects-page").shouldBe(visible); + } + + public ElementsCollection getProjects() { + return $$(".projects-list > .boxed-group"); + } + + public ElementsCollection getFacets() { + return $$(".search-navigator-facet-box"); + } + + public ProjectItem getProjectByKey(String projectKey) { + SelenideElement element = getProjects().find(Condition.attribute("data-key", projectKey)); + return new ProjectItem(element); + } + + public FacetItem getFacetByProperty(String facetProperty) { + SelenideElement element = getFacets().find(Condition.attribute("data-key", facetProperty)); + return new FacetItem(element); + } + + public ProjectsPage shouldHaveTotal(int total) { + // warning - number is localized + $("#projects-total").shouldHave(text(String.valueOf(total))); + return this; + } +} |