aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorGrégoire Aubert <gregaubert@users.noreply.github.com>2017-03-22 13:40:13 +0100
committerGitHub <noreply@github.com>2017-03-22 13:40:13 +0100
commit685a373cc4a9028fbdd09ec2765074e8ef72e408 (patch)
tree4081f070b8e704f80626740cd1650a5eb97efea0 /it
parent926e6e3a8a76efd342b51c511426af6e4a15b765 (diff)
downloadsonarqube-685a373cc4a9028fbdd09ec2765074e8ef72e408.tar.gz
sonarqube-685a373cc4a9028fbdd09ec2765074e8ef72e408.zip
SONAR-8844 Add tags editor on the project homepage (#1821)
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java62
-rw-r--r--it/it-tests/src/test/java/pageobjects/ProjectDashboardPage.java48
2 files changed, 106 insertions, 4 deletions
diff --git a/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java b/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java
index ab5326e41a2..269acc7d9d3 100644
--- a/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java
+++ b/it/it-tests/src/test/java/it/measure/ProjectDashboardTest.java
@@ -25,22 +25,32 @@ import it.Category1Suite;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Ignore;
+import org.junit.Rule;
import org.junit.Test;
+import org.openqa.selenium.Keys;
+import org.sonarqube.ws.client.PostRequest;
+import org.sonarqube.ws.client.WsClient;
import pageobjects.Navigation;
import pageobjects.ProjectDashboardPage;
import static com.codeborne.selenide.Condition.hasText;
import static com.codeborne.selenide.Condition.text;
+import static util.ItUtils.newAdminWsClient;
import static util.ItUtils.projectDir;
import static util.selenium.Selenese.runSelenese;
public class ProjectDashboardTest {
-
@ClassRule
public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR;
+ @Rule
+ public Navigation nav = Navigation.get(orchestrator);
+
+ private static WsClient wsClient;
+
@Before
- public void resetData() throws Exception {
+ public void setUp() throws Exception {
+ wsClient = newAdminWsClient(orchestrator);
orchestrator.resetData();
}
@@ -55,7 +65,6 @@ public class ProjectDashboardTest {
public void display_size() {
executeBuild("shared/xoo-sample", "sample", "Sample");
- Navigation nav = Navigation.get(orchestrator);
ProjectDashboardPage page = nav.openProjectDashboard("sample");
page.getLinesOfCode().should(hasText("13"));
@@ -63,9 +72,54 @@ public class ProjectDashboardTest {
}
@Test
+ public void display_tags_without_edit() {
+ executeBuild("shared/xoo-sample", "sample", "Sample");
+
+ // Add some tags to the project
+ wsClient.wsConnector().call(
+ new PostRequest("api/project_tags/set")
+ .setParam("project", "sample")
+ .setParam("tags", "foo,bar,baz")
+ );
+
+ ProjectDashboardPage page = nav.openProjectDashboard("sample");
+ page
+ .shouldHaveTags("foo", "bar", "baz")
+ .shouldNotBeEditable();
+ }
+
+ @Test
+ public void display_tags_with_edit() {
+ executeBuild("shared/xoo-sample", "sample-with-tags", "Sample with tags");
+ // Add some tags to another project to have them in the list
+ wsClient.wsConnector().call(
+ new PostRequest("api/project_tags/set")
+ .setParam("project", "sample-with-tags")
+ .setParam("tags", "foo,bar,baz")
+ );
+
+ executeBuild("shared/xoo-sample", "sample", "Sample");
+ ProjectDashboardPage page = nav.logIn().asAdmin().openProjectDashboard("sample");
+ page
+ .shouldHaveTags("No tags")
+ .shouldBeEditable()
+ .openTagEditor()
+ .getTagAtIdx(2).click();
+ page
+ .shouldHaveTags("foo")
+ .sendKeysToTagsInput("test")
+ .getTagAtIdx(0).should(hasText("+ test")).click();
+ page
+ .shouldHaveTags("foo", "test")
+ .getTagAtIdx(1).should(hasText("test"));
+ page
+ .sendKeysToTagsInput(Keys.ENTER)
+ .shouldHaveTags("test");
+ }
+
+ @Test
@Ignore("there is no more place to show the error")
public void display_a_nice_error_when_requesting_unknown_project() {
- Navigation nav = Navigation.get(orchestrator);
nav.open("/dashboard/index?id=unknown");
nav.getErrorMessage().should(text("The requested project does not exist. Either it has never been analyzed successfully or it has been deleted."));
// TODO verify that on global homepage
diff --git a/it/it-tests/src/test/java/pageobjects/ProjectDashboardPage.java b/it/it-tests/src/test/java/pageobjects/ProjectDashboardPage.java
index 296a6369213..0bb44703f64 100644
--- a/it/it-tests/src/test/java/pageobjects/ProjectDashboardPage.java
+++ b/it/it-tests/src/test/java/pageobjects/ProjectDashboardPage.java
@@ -20,7 +20,11 @@
package pageobjects;
import com.codeborne.selenide.SelenideElement;
+import java.util.Arrays;
+import java.util.List;
+import static com.codeborne.selenide.Condition.exist;
+import static com.codeborne.selenide.Condition.hasText;
import static com.codeborne.selenide.Condition.visible;
import static com.codeborne.selenide.Selenide.$;
@@ -41,4 +45,48 @@ public class ProjectDashboardPage {
element.shouldBe(visible);
return element;
}
+
+ private SelenideElement getTagsMeta() {
+ SelenideElement element = $(".overview-meta-tags");
+ element.shouldBe(visible);
+ return element;
+ }
+
+ public ProjectDashboardPage shouldHaveTags(String... tags) {
+ String tagsList = String.join(", ", Arrays.asList(tags));
+ this.getTagsMeta().$(".tags-list > span").should(hasText(tagsList));
+ return this;
+ }
+
+ public ProjectDashboardPage shouldNotBeEditable() {
+ SelenideElement tagsElem = this.getTagsMeta();
+ tagsElem.$("button").shouldNot(exist);
+ tagsElem.$("div.multi-select").shouldNot(exist);
+ return this;
+ }
+
+ public ProjectDashboardPage shouldBeEditable() {
+ SelenideElement tagsElem = this.getTagsMeta();
+ tagsElem.$("button").shouldBe(visible);
+ return this;
+ }
+
+ public ProjectDashboardPage openTagEditor() {
+ SelenideElement tagsElem = this.getTagsMeta();
+ tagsElem.$("button").shouldBe(visible).click();
+ tagsElem.$("div.multi-select").shouldBe(visible);
+ return this;
+ }
+
+ public SelenideElement getTagAtIdx(Integer idx) {
+ SelenideElement tagsElem = this.getTagsMeta();
+ tagsElem.$("div.multi-select").shouldBe(visible);
+ return tagsElem.$$("ul.menu a").get(idx);
+ }
+
+ public ProjectDashboardPage sendKeysToTagsInput(CharSequence... charSequences) {
+ SelenideElement tagsInput = this.getTagsMeta().find("input");
+ tagsInput.sendKeys(charSequences);
+ return this;
+ }
}