Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selenium: cover sharing workspaces in organization by selenium test #9167

Merged
merged 12 commits into from
Mar 23, 2018
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<che-popup title="{{addMemberController.members.length > 0 ? 'Select developers to invite' : 'No members in team'}}"
on-close="addMemberController.abort()" ng-if="!addMemberController.isLoading">
on-close="addMemberController.abort()" ng-if="!addMemberController.isLoading" id="add-members-dialog">
<div layout="column" class="add-workspace-members">

<che-list-header che-hide-header="!addMemberController.members || addMemberController.members.length === 0">
Expand Down Expand Up @@ -30,7 +30,7 @@
</div>
</div>
</che-list-header>
<che-list ng-show="addMemberController.cheListHelper.visibleItemsNumber > 0" class="members-list">
<che-list ng-show="addMemberController.cheListHelper.visibleItemsNumber > 0" class="members-list" id="add-members-list">
<member-item
ng-repeat="member in addMemberController.cheListHelper.getVisibleItems()"
callback="addMemberController"
Expand All @@ -53,6 +53,7 @@
che-button-title="Share" name="shareButton"
ng-click="addMemberController.shareWorkspace()"></che-button-primary>
<che-button-notice che-button-title="Close"
name="close-dialog-button"
ng-click="addMemberController.abort()"></che-button-notice>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
class="che-checkbox-area">
<div layout="row" layout-align="start center" class="che-list-item-checkbox-main">
<md-checkbox class="che-list-item-checkbox md-default-theme"
id="share-workspace-bulk-selection"
aria-label="Bulk check on users"
ng-checked="shareWorkspaceController.cheListHelper.areAllItemsSelected"
ng-click="shareWorkspaceController.cheListHelper.changeBulkSelection()"></md-checkbox>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<che-list-item flex-gt-sm="100" flex="33" ng-mouseover="hover=true" ng-mouseout="hover=false">
<div flex="100"
id="member-name-{{userItemController.user.email}}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's about user email, not member name.

layout="row"
layout-align="start stretch"
class="che-list-item-row user-list-row">
Expand All @@ -19,16 +20,16 @@
class="che-list-item-name">
<span class="che-xs-header noselect" hide-gt-xs>Email</span>
<span><img class="user-face" gravatar-src="userItemController.user.email"></span>
<span class="user-email che-hover ">{{userItemController.user.email}}</span>
<span class="user-email che-hover " name="member-name">{{userItemController.user.email}}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rename "member-name" to "member-email"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I would notice that it is about user, not member.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name attribute is usually used in input elements. It's better to use id for div element.

</div>
<div flex-gt-xs="35">
<span class="che-xs-header noselect" hide-gt-xs>Permissions</span>
<span class="user-permissions">{{userItemController.getUserActions()}}</span>
<span class="user-permissions" name="member-permissions">{{userItemController.getUserActions()}}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems is about user, not member.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name attribute is usually used in input elements. It's better to use id for div element.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each member has permissions and id is not suitable here.

</div>
<div flex-gt-xs="25">
<span class="che-xs-header noselect" hide-gt-xs>Actions</span>
<span class="che-list-actions">
<div ng-click="userItemController.removeUser();" uib-tooltip="Remove member">
<div ng-click="userItemController.removeUser();" uib-tooltip="Remove member" name="remove-member">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name attribute is usually used in input elements. It's better to use id for div element.

<span class="material-design icon-ic_remove_circle_outline_24px"></span>
</div>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,92 +11,118 @@
package org.eclipse.che.selenium.pageobject.dashboard.workspaces;

import static java.lang.String.format;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.LOAD_PAGE_TIMEOUT_SEC;
import static org.eclipse.che.selenium.core.constant.TestTimeoutsConstants.REDRAW_UI_ELEMENTS_TIMEOUT_SEC;
import static org.openqa.selenium.support.ui.ExpectedConditions.invisibilityOfElementLocated;
import static org.openqa.selenium.support.ui.ExpectedConditions.visibilityOfElementLocated;

import com.google.inject.Inject;
import org.eclipse.che.selenium.core.SeleniumWebDriver;
import org.eclipse.che.selenium.pageobject.SeleniumWebDriverHelper;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.WebDriverWait;

public class WorkspaceShare {
private final SeleniumWebDriver seleniumWebDriver;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need separate field seleniumWebDriver while we use seleniumWebDriverHelper only.

private final SeleniumWebDriverHelper seleniumWebDriverHelper;

@Inject
public WorkspaceShare(SeleniumWebDriver seleniumWebDriver) {
public WorkspaceShare(
SeleniumWebDriver seleniumWebDriver, SeleniumWebDriverHelper seleniumWebDriverHelper) {
this.seleniumWebDriver = seleniumWebDriver;
Copy link
Contributor

@dmytro-ndp dmytro-ndp Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.seleniumWebDriver bacame redundant here

this.seleniumWebDriverHelper = seleniumWebDriverHelper;
PageFactory.initElements(seleniumWebDriver, this);
}

private interface Locators {
String ADD_DEVELOPER_BTN = "//span[text()='Add Developer']";
String REMOVE_DEVELOPER_ICON =
"//span[text()='%s']//following::div[@tooltip='Remove member'][1]";
String INPUT_SHARE_DIALOG = "//md-chips[contains(@class,'share-user-input')]//input";
String SHARE_BTN_DIALOG = "//che-button-primary[@aria-disabled='false']//span[text()='Share']";
String DEVELOPER_SHARE_ITEM = "//span[text()='%s']";
String WARNING_DIALOG_DELETE = "//div[@class='ng-binding' and text()=\"%s\"]";
}

/**
* Adds developer to share list
*
* @param email is an email of developer into sharing list
*/
public void addDeveloperToShareList(String email) {
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(Locators.ADD_DEVELOPER_BTN)))
.click();
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(Locators.INPUT_SHARE_DIALOG)))
.sendKeys(email + ",");
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(Locators.SHARE_BTN_DIALOG)))
.click();
}

/**
* Delete a developer from sharing list
*
* @param email is an email of developer into sharing list
*/
public void deleteDeveloperFromShareList(String email) {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(
visibilityOfElementLocated(
By.xpath(String.format(Locators.REMOVE_DEVELOPER_ICON, email))))
.click();
}

/** Wait the text into warning dialog delete or remove */
public void waitTextInWarningDialogDelete(String expText) {
new WebDriverWait(seleniumWebDriver, LOAD_PAGE_TIMEOUT_SEC)
.until(
visibilityOfElementLocated(
By.xpath(String.format(Locators.WARNING_DIALOG_DELETE, expText))));
}

/**
* Wait the email of developer is present in 'Share' tab
*
* @param email the email of developer
*/
public void waitDeveloperIsPresentInShareTab(String email) {
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(visibilityOfElementLocated(By.xpath(format(Locators.DEVELOPER_SHARE_ITEM, email))));
}

/**
* Wait the email of developer is not present in 'Share' tab
*
* @param email the email of developer
*/
public void waitDeveloperIsNotPresentInShareTab(String email) {
new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
.until(
invisibilityOfElementLocated(By.xpath(format(Locators.DEVELOPER_SHARE_ITEM, email))));
String ADD_DEVELOPER_BTN_XPATH = "//che-button-primary[@che-button-title='Add Developer']";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to shorten BUTTON to BTN, because it doesn't effectively shorten the code, but make it harder to understand.

String BULK_SELECTION_ID = "share-workspace-bulk-selection";
String FILTER_MEMBERS_BY_NAME_FIELD_XPATH = "//input[@ng-placeholder='Search']";
String MEMBER_ITEM_XPATH = "//div[@id='member-name-%s']";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEMBER_ITEM_XPATH is actually MEMBER_ITEM_XPATH_PATTERN which should be completed before usage.

String MEMBER_NAME_XPATH = MEMBER_ITEM_XPATH + "//span[@name='member-name']";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is also looks like xpath pattern

String MEMBER_CHECKBOX_XPATH = MEMBER_ITEM_XPATH + "//md-checkbox";
String MEMBER_PERMISSIONS_XPATH = MEMBER_ITEM_XPATH + "//span[@name='member-permissions']";;
String REMOVE_MEMBER_ICON_XPATH = MEMBER_ITEM_XPATH + "//div[@name='remove-member']";
String INVITE_MEMBER_DIALOG_ID = "add-members-dialog";
String CLOSE_DIALOG_BUTTON_NAME_ID = "close-dialog-button";
String SELECT_ALL_MEMBERS_BY_BULK_DIALOG_XPATH = "//md-checkbox[@aria-label='Member list']";
String SHARE_WORKSPACE_DIALOG_BUTTON_NAME = "shareButton";
String NO_MEMBERS_IN_ORGANIZATION_DIALOG_XPATH = "//che-popup[@title='No members in team']";
}

@FindBy(xpath = Locators.FILTER_MEMBERS_BY_NAME_FIELD_XPATH)
WebElement filterMembers;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memberFilter ?

Copy link
Contributor

@dmytro-ndp dmytro-ndp Mar 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or filterMembersField?


@FindBy(id = Locators.BULK_SELECTION_ID)
WebElement bulkSelection;

public void clickOnBulk() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clickOnBulkSelection?

seleniumWebDriverHelper.waitAndClick(bulkSelection);
}

public void typeToSearchInput(String value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it is filterMembers method

filterMembers.clear();
filterMembers.sendKeys(value);
}

public void waitMemberNameInShareList(String name) {
seleniumWebDriverHelper.waitVisibility(By.xpath(format(Locators.MEMBER_NAME_XPATH, name)));
}

public void waitMemberNameNotExistsInShareList(String name) {
seleniumWebDriverHelper.waitInvisibility(By.xpath(format(Locators.MEMBER_NAME_XPATH, name)));
}

public void clickOnAddDeveloperButton() {
seleniumWebDriverHelper.waitAndClick(By.xpath(Locators.ADD_DEVELOPER_BTN_XPATH));
}

public String getMemberPermissions(String name) {
return seleniumWebDriverHelper.waitVisibilityAndGetText(
By.xpath(format(Locators.MEMBER_PERMISSIONS_XPATH, name)));
}

public void clickOnMemberCheckbox(String name) {
seleniumWebDriverHelper.waitAndClick(By.xpath(format(Locators.MEMBER_CHECKBOX_XPATH, name)));
}

public Boolean isMemberCheckedInList(String name) {
return Boolean.parseBoolean(
seleniumWebDriverHelper
.waitVisibility(By.xpath(format(Locators.MEMBER_CHECKBOX_XPATH, name)))
.getAttribute("aria-checked"));
}

public void clickOnRemoveMemberButton(String name) {
seleniumWebDriverHelper.waitAndClick(By.xpath(format(Locators.REMOVE_MEMBER_ICON_XPATH, name)));
}

public void waitInviteMemberDialog() {
seleniumWebDriverHelper.waitVisibility(By.id(Locators.INVITE_MEMBER_DIALOG_ID));
}

public void waitInviteMemberDialogClosed() {
seleniumWebDriverHelper.waitInvisibility(By.id(Locators.INVITE_MEMBER_DIALOG_ID));
}

public void selectAllMembersInDialogByBulk() {
seleniumWebDriverHelper.waitAndClick(
By.xpath(Locators.SELECT_ALL_MEMBERS_BY_BULK_DIALOG_XPATH));
}

public void clickOnShareWorkspaceButton() {
seleniumWebDriverHelper.waitAndClick(By.name(Locators.SHARE_WORKSPACE_DIALOG_BUTTON_NAME));
}

public void closeInviteMemberDialog() {
seleniumWebDriverHelper.waitAndClick(By.id(Locators.INVITE_MEMBER_DIALOG_ID));
}

public void waitNoMembersDialog() {
seleniumWebDriverHelper.waitVisibility(
By.xpath(Locators.NO_MEMBERS_IN_ORGANIZATION_DIALOG_XPATH));
}

public void closeNoMembersDialog() {
seleniumWebDriverHelper.waitAndClick(
By.xpath(Locators.NO_MEMBERS_IN_ORGANIZATION_DIALOG_XPATH));
}
}
Loading