Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelleduc committed Feb 28, 2024
1 parent b7c2c98 commit a9f717a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
package org.xwiki.administration.test.ui;

import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
Expand All @@ -39,6 +40,7 @@
import org.xwiki.test.ui.po.ViewPage;
import org.xwiki.test.ui.po.editor.RightsEditPage;

import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.not;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -295,7 +297,8 @@ void createAndDeleteUser(TestUtils setup, TestReference testReference)
ConfirmationModal confirmation = usersPage.clickDeleteUser(1);
assertTrue(confirmation.getMessage().contains("Are you sure you want to proceed?"));
confirmation.clickOk();
usersPage.getUsersLiveData().getTableLayout().assertRow("User", userName);
usersPage.getUsersLiveData().getTableLayout().assertRow("User",
not(hasItem(usersPage.getUsersLiveData().getTableLayout().getWebElementTextMatcher(userName))));

// Verify that when a user is removed, they are removed from the groups they belong to.
groupsPage = GroupsPage.gotoPage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@ private GroupEditPage addMembersToGroup(WebElement input, String... members)

public GroupEditPage removeMembers(String... members)
{

for (String member : members) {
System.out.printf("Member: %s%n", member);
int index = 1;
for (WebElement row : getMembersTable().getRows()) {
System.out.printf("Username [%s] at index [%d]%n", getRowUserName(row), index);
if (Objects.equals(getRowUserName(row), member)) {
getMembersTable().clickAction(index, "delete");
break;
Expand All @@ -106,25 +103,6 @@ public GroupEditPage removeMembers(String... members)
return this;
}

private static String getRowUserName(WebElement row)
{
List<WebElement> elements =
row.findElements(By.cssSelector("[data-livedata-property-id=\"member\"] .user-name"));
String rowUserName;
if (elements.isEmpty()) {
elements =
row.findElements(By.cssSelector("[data-livedata-property-id=\"member\"] .group-name"));
if (elements.isEmpty()) {
rowUserName = null;
} else {
rowUserName = elements.get(0).getText();
}
} else {
rowUserName = elements.get(0).getText();
}
return rowUserName;
}

public void filterMembers(String member)
{
this.membersLiveData.getTableLayout().filterColumn("Member", member);
Expand All @@ -146,4 +124,23 @@ public TableLayoutElement getMembersTable()
}
return this.tableLayout;
}

private static String getRowUserName(WebElement row)
{
List<WebElement> elements =
row.findElements(By.cssSelector("[data-livedata-property-id=\"member\"] .user-name"));
String rowUserName;
if (elements.isEmpty()) {
elements =
row.findElements(By.cssSelector("[data-livedata-property-id=\"member\"] .group-name"));
if (elements.isEmpty()) {
rowUserName = null;
} else {
rowUserName = elements.get(0).getText();
}
} else {
rowUserName = elements.get(0).getText();
}
return rowUserName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ public class GroupsPage extends BasePage
public GroupsPage addNewGroup(String groupName)
{
clickCreateGroup().createGroup(groupName);

// The live data is refreshed.
this.groupsLiveData.getTableLayout();

return this;
}

Expand Down Expand Up @@ -84,30 +80,28 @@ public TableLayoutElement getGroupsTable()
public DeleteGroupConfirmationModal clickDeleteGroup(String groupName)
{
int rowNumber = getRowNumberByGroupName(groupName);
this.groupsLiveData.getTableLayout().clickAction(rowNumber, "delete");
getGroupsTable().clickAction(rowNumber, "delete");
return new DeleteGroupConfirmationModal();
}

public GroupsPage deleteGroup(String groupName)
{
clickDeleteGroup(groupName).clickOk();
// The live data is refreshed.
this.groupsLiveData.getTableLayout();
return this;
}

public EditGroupModal clickEditGroup(String groupName)
{
int rowNumber = getRowNumberByGroupName(groupName);
this.groupsLiveData.getTableLayout().clickAction(rowNumber, "edit");
getGroupsTable().clickAction(rowNumber, "edit");

return new EditGroupModal().waitUntilReady();
}

public String getMemberCount(String groupName)
{
int rowNumber = getRowNumberByGroupName(groupName);
return this.groupsLiveData.getTableLayout().getCell("Members", rowNumber).getText();
return getGroupsTable().getCell("Members", rowNumber).getText();
}

private int getRowNumberByGroupName(String groupName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,21 +364,36 @@
<cache>long</cache>
</property>
<property>
<code>#template('colorThemeInit.vm')
<code>/* Make sure the selectize dropdown is displayed on top of the Bootstrap modal. */
body &gt; .selectize-dropdown {
z-index: 1051;
}

#groupusers .type,
#groupusers .scope {
color: $theme.textSecondaryColor;
/**
* Group members live table.
*/

#groupusers {
margin-top: 20px;

td.cell div.view {
vertical-align: middle;
}

[data-livedata-property-id="type"],
[data-livedata-property-id="scope"] {
color: @text-muted;
}
}</code>
</property>
<property>
<contentType>CSS</contentType>
<contentType>LESS</contentType>
</property>
<property>
<name/>
</property>
<property>
<parse>1</parse>
<parse>0</parse>
</property>
<property>
<use>onDemand</use>
Expand Down

0 comments on commit a9f717a

Please sign in to comment.