aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-03-08 14:43:43 +0100
committerGrégoire Aubert <gregaubert@users.noreply.github.com>2017-03-13 10:03:16 +0100
commitdf0aad09cff6801af52be40e993cb2a57009676e (patch)
tree29eab9d853616d42f5d6e754df891a8a3590a22d /it
parentb7587766c4bb8967d177e308bf35e4fc8bd7f3b2 (diff)
downloadsonarqube-df0aad09cff6801af52be40e993cb2a57009676e.tar.gz
sonarqube-df0aad09cff6801af52be40e993cb2a57009676e.zip
SONAR-8878 Add ut and it's for Language, Search and Sort filters
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java25
-rw-r--r--it/it-tests/src/test/java/pageobjects/projects/FacetItem.java27
-rw-r--r--it/it-tests/src/test/java/pageobjects/projects/ProjectsPage.java10
3 files changed, 62 insertions, 0 deletions
diff --git a/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java b/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java
index 70c9f708f4a..29128f15556 100644
--- a/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java
+++ b/it/it-tests/src/test/java/it/projectSearch/ProjectsPageTest.java
@@ -101,4 +101,29 @@ public class ProjectsPageTest {
page.shouldHaveTotal(2).shouldDisplayAllProjects();
}
+ @Test
+ public void should_add_language() {
+ ProjectsPage page = nav.openProjects();
+ page.getFacetByProperty("languages")
+ .selectOptionItem("xoo2")
+ .shouldHaveValue("xoo2", "0");
+ }
+
+ @Test
+ public void should_sort_by_facet() {
+ ProjectsPage page = nav.openProjects();
+ page.getFacetByProperty("duplications")
+ .sortListDesc();
+ page.getProjectByIdx(0).shouldHaveMeasure("duplicated_lines_density", "63.7%");
+ page.getFacetByProperty("duplications")
+ .sortListAsc();
+ page.getProjectByIdx(0).shouldHaveMeasure("duplicated_lines_density", "0.0%");
+ }
+
+ @Test
+ public void should_search_for_project() {
+ ProjectsPage page = nav.openProjects();
+ page.searchProject("s").shouldHaveTotal(2);
+ page.searchProject("sam").shouldHaveTotal(1);
+ }
}
diff --git a/it/it-tests/src/test/java/pageobjects/projects/FacetItem.java b/it/it-tests/src/test/java/pageobjects/projects/FacetItem.java
index ec9e4c8f0e4..2d0adce7de4 100644
--- a/it/it-tests/src/test/java/pageobjects/projects/FacetItem.java
+++ b/it/it-tests/src/test/java/pageobjects/projects/FacetItem.java
@@ -20,7 +20,9 @@
package pageobjects.projects;
import com.codeborne.selenide.Condition;
+import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.SelenideElement;
+import org.openqa.selenium.WebElement;
public class FacetItem {
@@ -38,4 +40,29 @@ public class FacetItem {
public void selectValue(String key) {
this.elt.$(".facet[data-key=\"" + key + "\"]").click();
}
+
+ public FacetItem selectOptionItem(String value) {
+ this.elt.$(".Select-input input").val(value).pressEnter();
+ return this;
+ }
+
+ public FacetItem sortListDesc() {
+ this.getSortingButton("-").click();
+ return this;
+ }
+
+ public FacetItem sortListAsc() {
+ this.getSortingButton("[a-zA-Z ]").click();
+ return this;
+ }
+
+ public SelenideElement getSortingButton(String selector) {
+ ElementsCollection buttons = this.elt.$$(".projects-facet-sort a");
+ return buttons.find(new Condition("AttributeMatch") {
+ @Override
+ public boolean apply(WebElement webElement) {
+ return webElement.getAttribute("href").matches(".*sort=" + selector + ".*");
+ }
+ });
+ }
}
diff --git a/it/it-tests/src/test/java/pageobjects/projects/ProjectsPage.java b/it/it-tests/src/test/java/pageobjects/projects/ProjectsPage.java
index 0cc1b638a11..de3b50834fa 100644
--- a/it/it-tests/src/test/java/pageobjects/projects/ProjectsPage.java
+++ b/it/it-tests/src/test/java/pageobjects/projects/ProjectsPage.java
@@ -49,6 +49,10 @@ public class ProjectsPage {
return new ProjectItem(element);
}
+ public ProjectItem getProjectByIdx(Integer idx) {
+ return new ProjectItem(getProjects().get(idx));
+ }
+
public FacetItem getFacetByProperty(String facetProperty) {
SelenideElement element = getFacets().find(Condition.attribute("data-key", facetProperty));
return new FacetItem(element);
@@ -79,4 +83,10 @@ public class ProjectsPage {
$("#favorite-projects").click();
return shouldDisplayFavoriteProjects();
}
+
+ public ProjectsPage searchProject(String search) {
+ SelenideElement searchInput = $(".projects-facet-search input");
+ searchInput.setValue("").sendKeys(search);
+ return this;
+ }
}