aboutsummaryrefslogtreecommitdiffstats
path: root/it
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-03-31 14:15:11 +0200
committerGrégoire Aubert <gregaubert@users.noreply.github.com>2017-03-31 14:56:31 +0200
commit0abc21b94ebf3ec8cedaecfe3b8eeb957832309d (patch)
tree5f4bf886ac55d33ecb3f2f4f72cca361552e0234 /it
parent2c6256d0b4a8daa9d63ea1d5acbdf5133828a037 (diff)
downloadsonarqube-0abc21b94ebf3ec8cedaecfe3b8eeb957832309d.tar.gz
sonarqube-0abc21b94ebf3ec8cedaecfe3b8eeb957832309d.zip
SONAR-8994 Add integration test and fix existing members tests
Diffstat (limited to 'it')
-rw-r--r--it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java34
-rw-r--r--it/it-tests/src/test/java/pageobjects/organization/MemberItem.java10
2 files changed, 30 insertions, 14 deletions
diff --git a/it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java b/it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java
index 6cfd268b4ff..efc78a946cb 100644
--- a/it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java
+++ b/it/it-tests/src/test/java/it/organization/OrganizationMembershipTest.java
@@ -133,21 +133,21 @@ public class OrganizationMembershipTest {
@Test
public void should_display_members_page() {
String orgKey = createOrganization();
- String user1 = createUser();
- String user2 = createUser();
+ userRule.createUser("foo", "pwd");
+ userRule.createUser("bar", "pwd");
createUser();
- adminClient.organizations().addMember(orgKey, user1);
- adminClient.organizations().addMember(orgKey, user2);
+ adminClient.organizations().addMember(orgKey, "foo");
+ adminClient.organizations().addMember(orgKey, "bar");
MembersPage page = nav.openOrganizationMembers(orgKey);
page
.canNotAddMember()
.shouldHaveTotal(3);
page.getMembersByIdx(0).shouldBeNamed("admin", "Administrator");
- page.getMembersByIdx(1).shouldBeNamed(user1, user1);
+ page.getMembersByIdx(1).shouldBeNamed("bar", "bar");
page.getMembersByIdx(2)
- .shouldBeNamed(user2, user2)
+ .shouldBeNamed("foo", "foo")
.shouldNotHaveActions();
}
@@ -175,16 +175,16 @@ public class OrganizationMembershipTest {
@Test
public void admin_can_add_members() {
String orgKey = createOrganization();
- String user1 = createUser();
+ userRule.createUser("foo", "pwd");
createUser();
MembersPage page = nav.logIn().asAdmin().openOrganizationMembers(orgKey);
page
.shouldHaveTotal(1)
- .addMember(user1)
+ .addMember("foo")
.shouldHaveTotal(2);
page.getMembersByIdx(0).shouldBeNamed("admin", "Administrator").shouldHaveGroups(1);
- page.getMembersByIdx(1).shouldBeNamed(user1, user1).shouldHaveGroups(0);
+ page.getMembersByIdx(1).shouldBeNamed("foo", "foo").shouldHaveGroups(0);
}
@Test
@@ -222,6 +222,22 @@ public class OrganizationMembershipTest {
.shouldHaveGroups(0);
}
+ @Test
+ public void groups_count_should_be_updated_when_a_member_was_just_added() {
+ String orgKey = createOrganization();
+ String user1 = createUser();
+
+ MembersPage page = nav.logIn().asAdmin().openOrganizationMembers(orgKey);
+ page
+ .addMember(user1)
+ .getMembersByIdx(1)
+ .shouldHaveGroups(0)
+ .manageGroupsOpen()
+ .manageGroupsSelect("owners")
+ .manageGroupsSave()
+ .shouldHaveGroups(1);
+ }
+
private void verifyMembership(String login, String organizationKey, boolean isMember) {
// TODO replace with search member WS
int count = orchestrator.getDatabase().countSql(format("SELECT COUNT(1) FROM organization_members om " +
diff --git a/it/it-tests/src/test/java/pageobjects/organization/MemberItem.java b/it/it-tests/src/test/java/pageobjects/organization/MemberItem.java
index e3a4f543203..f3099f5ec7f 100644
--- a/it/it-tests/src/test/java/pageobjects/organization/MemberItem.java
+++ b/it/it-tests/src/test/java/pageobjects/organization/MemberItem.java
@@ -20,12 +20,12 @@
package pageobjects.organization;
+import com.codeborne.selenide.CollectionCondition;
import com.codeborne.selenide.Condition;
import com.codeborne.selenide.ElementsCollection;
import com.codeborne.selenide.SelenideElement;
import static com.codeborne.selenide.Selenide.$;
-import static org.assertj.core.api.Assertions.assertThat;
public class MemberItem {
private final SelenideElement elt;
@@ -44,18 +44,18 @@ public class MemberItem {
public MemberItem shouldHaveGroups(Integer groups) {
ElementsCollection tds = this.elt.$$("td");
tds.get(2).should(Condition.exist);
- assertThat(tds.get(2).text()).contains(groups.toString());
+ tds.get(2).shouldHave(Condition.text(groups.toString()));
return this;
}
public MemberItem shouldNotHaveActions() {
- assertThat(this.elt.$$("td").size()).isLessThan(3);
+ this.elt.$$("td").shouldHave(CollectionCondition.sizeLessThan(3));
return this;
}
public MemberItem removeMembership() {
ElementsCollection tds = this.elt.$$("td");
- assertThat(tds.size()).isGreaterThan(3);
+ tds.shouldHave(CollectionCondition.sizeGreaterThan(3));
SelenideElement actionTd = tds.get(3);
actionTd.$("button").should(Condition.exist).click();
actionTd.$$(".dropdown-menu > li").get(2).shouldBe(Condition.visible).click();
@@ -66,7 +66,7 @@ public class MemberItem {
public MemberItem manageGroupsOpen() {
ElementsCollection tds = this.elt.$$("td");
- assertThat(tds.size()).isGreaterThan(3);
+ tds.shouldHave(CollectionCondition.sizeGreaterThan(3));
SelenideElement actionTd = tds.get(3);
actionTd.$("button").should(Condition.exist).click();
actionTd.$$(".dropdown-menu > li").get(0).shouldBe(Condition.visible).click();