refactoring
This commit is contained in:
parent
c51d75a2cc
commit
2eecf7f066
@ -48,6 +48,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.time.Duration;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@ -64,9 +65,12 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
private static final int WIDTH = 1680;
|
||||
private static final int HEIGHT = 1050;
|
||||
private static final String REMOTE_WEBDRIVER_HOST = "http://localhost:4444";
|
||||
protected static final PageLink pageLink = new PageLink(10);
|
||||
private static final ContainerTestSuite instance = ContainerTestSuite.getInstance();
|
||||
protected final PageLink pageLink = new PageLink(10);
|
||||
private final ContainerTestSuite instance = ContainerTestSuite.getInstance();
|
||||
private JavascriptExecutor js;
|
||||
public static final long WAIT_TIMEOUT = TimeUnit.SECONDS.toMillis(10);
|
||||
private final Duration duration = Duration.ofMillis(WAIT_TIMEOUT);
|
||||
private WebStorage webStorage;
|
||||
|
||||
@BeforeClass
|
||||
public void startUp() throws MalformedURLException {
|
||||
@ -104,8 +108,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
}
|
||||
|
||||
public String getJwtTokenFromLocalStorage() {
|
||||
js = (JavascriptExecutor) driver;
|
||||
return (String) js.executeScript("return window.localStorage.getItem('jwt_token');");
|
||||
return (String) getJs().executeScript("return window.localStorage.getItem('jwt_token');");
|
||||
}
|
||||
|
||||
public void openBaseUiUrl() {
|
||||
@ -121,7 +124,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
}
|
||||
|
||||
protected boolean urlContains(String urlPath) {
|
||||
WebDriverWait wait = new WebDriverWait(driver, Duration.ofMillis(5000));
|
||||
WebDriverWait wait = new WebDriverWait(driver, duration);
|
||||
try {
|
||||
wait.until(ExpectedConditions.urlContains(urlPath));
|
||||
} catch (WebDriverException e) {
|
||||
@ -131,11 +134,10 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
}
|
||||
|
||||
public void jsClick(WebElement element) {
|
||||
js = (JavascriptExecutor) driver;
|
||||
js.executeScript("arguments[0].click();", element);
|
||||
getJs().executeScript("arguments[0].click();", element);
|
||||
}
|
||||
|
||||
public static RuleChain getRuleChainByName(String name) {
|
||||
public RuleChain getRuleChainByName(String name) {
|
||||
try {
|
||||
return testRestClient.getRuleChains(pageLink).getData().stream()
|
||||
.filter(s -> s.getName().equals(name)).collect(Collectors.toList()).get(0);
|
||||
@ -145,7 +147,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
}
|
||||
}
|
||||
|
||||
public static Customer getCustomerByName(String name) {
|
||||
public Customer getCustomerByName(String name) {
|
||||
try {
|
||||
return testRestClient.getCustomers(pageLink).getData().stream()
|
||||
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
|
||||
@ -155,7 +157,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
}
|
||||
}
|
||||
|
||||
public static DeviceProfile getDeviceProfileByName(String name) {
|
||||
public DeviceProfile getDeviceProfileByName(String name) {
|
||||
try {
|
||||
return testRestClient.getDeviceProfiles(pageLink).getData().stream()
|
||||
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
|
||||
@ -165,7 +167,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
}
|
||||
}
|
||||
|
||||
public static AssetProfile getAssetProfileByName(String name) {
|
||||
public AssetProfile getAssetProfileByName(String name) {
|
||||
try {
|
||||
return testRestClient.getAssetProfiles(pageLink).getData().stream()
|
||||
.filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0);
|
||||
@ -182,14 +184,6 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
}
|
||||
}
|
||||
|
||||
public WebStorage getWebStorage() {
|
||||
if (driver instanceof WebStorage) {
|
||||
return (WebStorage) driver;
|
||||
} else {
|
||||
throw new IllegalArgumentException("This test expects the driver to implement WebStorage");
|
||||
}
|
||||
}
|
||||
|
||||
public void clearStorage() {
|
||||
getWebStorage().getLocalStorage().clear();
|
||||
getWebStorage().getSessionStorage().clear();
|
||||
@ -198,4 +192,12 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
|
||||
public void assertIsDisplayed(WebElement element) {
|
||||
assertThat(element.isDisplayed()).as(element + " is displayed").isTrue();
|
||||
}
|
||||
|
||||
public JavascriptExecutor getJs() {
|
||||
return js = (JavascriptExecutor) driver;
|
||||
}
|
||||
|
||||
public WebStorage getWebStorage() {
|
||||
return webStorage = (WebStorage) driver;
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,8 +20,8 @@ import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AlarmElements extends OtherPageElements{
|
||||
public AlarmElements(WebDriver driver) {
|
||||
public class AlarmDetailsEntityTabElements extends OtherPageElements {
|
||||
public AlarmDetailsEntityTabElements(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
@ -34,6 +34,7 @@ public class AlarmElements extends OtherPageElements{
|
||||
private static final String UNASSIGNED = "//span[text() = '%s']/ancestor::mat-row//span[@class='assignee-cell']/mat-icon[text() = 'account_circle']/following-sibling::span";
|
||||
private static final String ALARM_DETAILS_BTN = "//span[text() = '%s']/ancestor::mat-row//mat-icon[contains(text(),'more_horiz')]/parent::button";
|
||||
private static final String ACCESS_FORBIDDEN_DIALOG_VIEW = "//h2[text() = 'Access Forbidden']/parent::tb-confirm-dialog";
|
||||
private static final String ALARM_ASSIGNEE_DROPDOWN = "//tb-alarm-assignee-panel";
|
||||
|
||||
public WebElement assignBtn(String type) {
|
||||
return waitUntilElementToBeClickable(String.format(ASSIGN_BTN, type));
|
||||
@ -70,4 +71,8 @@ public class AlarmElements extends OtherPageElements{
|
||||
public WebElement accessForbiddenDialogView() {
|
||||
return waitUntilVisibilityOfElementLocated(ACCESS_FORBIDDEN_DIALOG_VIEW);
|
||||
}
|
||||
|
||||
public WebElement alarmAssigneeDropdown() {
|
||||
return waitUntilVisibilityOfElementLocated(ALARM_ASSIGNEE_DROPDOWN);
|
||||
}
|
||||
}
|
||||
@ -17,13 +17,12 @@ package org.thingsboard.server.msa.ui.pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.thingsboard.server.msa.ui.utils.Const;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AlarmHelper extends AlarmElements {
|
||||
public AlarmHelper(WebDriver driver) {
|
||||
public class AlarmDetailsEntityTabHelper extends AlarmDetailsEntityTabElements {
|
||||
public AlarmDetailsEntityTabHelper(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
@ -33,12 +32,12 @@ public class AlarmHelper extends AlarmElements {
|
||||
}
|
||||
|
||||
public void unassignedAlarm(String alarmType) {
|
||||
assignBtn(alarmType).click();
|
||||
jsClick(assignBtn(alarmType));
|
||||
unassignedBtn().click();
|
||||
}
|
||||
|
||||
public void searchAlarm(String alarmType, String emailOrName) {
|
||||
assignBtn(alarmType).click();
|
||||
jsClick(assignBtn(alarmType));
|
||||
searchUserField().sendKeys(emailOrName);
|
||||
}
|
||||
|
||||
@ -24,7 +24,6 @@ public class AlarmDetailsViewElements extends AbstractBasePage {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
//private static final String ASSIGN_FIELD = "//tb-alarm-assignee//mat-icon[contains(text(),'keyboard_arrow_down')]/parent::button";
|
||||
private static final String ASSIGN_FIELD = "//mat-label[text()='Assignee']/parent::label/parent::div//input";
|
||||
private static final String USER_FROM_DROP_DOWN = "//div[@class='user-display-name']/span[text() = '%s']";
|
||||
private static final String CLOSE_ALARM_DETAILS_VIEW_BTN = "//mat-dialog-container//mat-icon[contains(text(),'close')]/parent::button";
|
||||
|
||||
@ -17,7 +17,7 @@ package org.thingsboard.server.msa.ui.pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
public class AlarmDetailsViewHelper extends AlarmDetailsViewElements{
|
||||
public class AlarmDetailsViewHelper extends AlarmDetailsViewElements {
|
||||
public AlarmDetailsViewHelper(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
@ -18,27 +18,20 @@ package org.thingsboard.server.msa.ui.pages;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
public class AssetPageElements extends OtherPageElements{
|
||||
public class AssetPageElements extends OtherPageElements {
|
||||
public AssetPageElements(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
private static final String CUSTOMER_DETAILS_VIEW = "//tb-details-panel";
|
||||
private static final String CUSTOMER_DETAILS_ALARMS = CUSTOMER_DETAILS_VIEW + "//span[text()='Alarms']";
|
||||
private static final String ASSET_DETAILS_VIEW = "//tb-details-panel";
|
||||
private static final String ASSET_DETAILS_ALARMS = ASSET_DETAILS_VIEW + "//span[text()='Alarms']";
|
||||
|
||||
public WebElement customerDetailsView() {
|
||||
return waitUntilPresenceOfElementLocated(CUSTOMER_DETAILS_VIEW);
|
||||
public WebElement assetDetailsView() {
|
||||
return waitUntilPresenceOfElementLocated(ASSET_DETAILS_VIEW);
|
||||
}
|
||||
|
||||
public WebElement customerDetailsAlarmsBtn() {
|
||||
return waitUntilElementToBeClickable(CUSTOMER_DETAILS_ALARMS);
|
||||
}
|
||||
|
||||
public void openAssetAlarms(String assetName) {
|
||||
if (!customerDetailsView().isDisplayed()) {
|
||||
entity(assetName).click();
|
||||
}
|
||||
customerDetailsAlarmsBtn().click();
|
||||
public WebElement assetDetailsAlarmsBtn() {
|
||||
return waitUntilElementToBeClickable(ASSET_DETAILS_ALARMS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Copyright © 2016-2023 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.msa.ui.pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
|
||||
public class AssetPageHelper extends AssetPageElements {
|
||||
public AssetPageHelper(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
public void openAssetAlarms(String assetName) {
|
||||
if (!assetDetailsView().isDisplayed()) {
|
||||
entity(assetName).click();
|
||||
}
|
||||
assetDetailsAlarmsBtn().click();
|
||||
}
|
||||
|
||||
}
|
||||
@ -18,7 +18,7 @@ package org.thingsboard.server.msa.ui.pages;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
public class DevicePageElements extends OtherPageElements{
|
||||
public class DevicePageElements extends OtherPageElements {
|
||||
public DevicePageElements(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
@ -32,6 +32,7 @@ public class DevicePageElements extends OtherPageElements{
|
||||
private static final String CUSTOMER_FROM_ASSIGN_DROPDOWN = "//div[@role = 'listbox']//span[text() = '%s']";
|
||||
private static final String CLOSE_DEVICE_DETAILS_VIEW = "//header//mat-icon[contains(text(),'close')]/parent::button";
|
||||
private static final String SUBMIT_ASSIGN_TO_CUSTOMER_BTN = "//button[@type='submit']";
|
||||
|
||||
public WebElement device(String deviceName) {
|
||||
return waitUntilElementToBeClickable(String.format(DEVICE, deviceName));
|
||||
}
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright © 2016-2023 The Thingsboard Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.thingsboard.server.msa.ui.pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
public class EntityViewPageElements extends OtherPageElementsHelper {
|
||||
public EntityViewPageElements(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
private static final String ENTITY_VIEW_DETAILS_VIEW = "//tb-details-panel";
|
||||
private static final String ENTITY_VIEW_DETAILS_ALARMS = ENTITY_VIEW_DETAILS_VIEW + "//span[text()='Alarms']";
|
||||
|
||||
public WebElement entityViewDetailsView() {
|
||||
return waitUntilPresenceOfElementLocated(ENTITY_VIEW_DETAILS_VIEW);
|
||||
}
|
||||
|
||||
public WebElement entityViewDetailsAlarmsBtn() {
|
||||
return waitUntilElementToBeClickable(ENTITY_VIEW_DETAILS_ALARMS);
|
||||
}
|
||||
|
||||
}
|
||||
@ -16,30 +16,17 @@
|
||||
package org.thingsboard.server.msa.ui.pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
public class EntityViewPage extends OtherPageElementsHelper{
|
||||
public EntityViewPage(WebDriver driver) {
|
||||
public class EntityViewPageHelper extends EntityViewPageElements {
|
||||
public EntityViewPageHelper(WebDriver driver) {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
private static final String CUSTOMER_DETAILS_VIEW = "//tb-details-panel";
|
||||
private static final String CUSTOMER_DETAILS_ALARMS = CUSTOMER_DETAILS_VIEW + "//span[text()='Alarms']";
|
||||
|
||||
public WebElement customerDetailsView() {
|
||||
return waitUntilPresenceOfElementLocated(CUSTOMER_DETAILS_VIEW);
|
||||
}
|
||||
|
||||
public WebElement customerDetailsAlarmsBtn() {
|
||||
return waitUntilElementToBeClickable(CUSTOMER_DETAILS_ALARMS);
|
||||
}
|
||||
|
||||
|
||||
public void openEntityViewAlarms(String customerName) {
|
||||
if (!customerDetailsView().isDisplayed()) {
|
||||
if (!entityViewDetailsView().isDisplayed()) {
|
||||
entity(customerName).click();
|
||||
}
|
||||
customerDetailsAlarmsBtn().click();
|
||||
entityViewDetailsAlarmsBtn().click();
|
||||
}
|
||||
|
||||
}
|
||||
@ -16,8 +16,6 @@
|
||||
package org.thingsboard.server.msa.ui.pages;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.support.ui.ExpectedCondition;
|
||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||
import org.thingsboard.server.msa.ui.utils.Const;
|
||||
|
||||
public class LoginPageHelper extends LoginPageElements {
|
||||
@ -25,18 +23,10 @@ public class LoginPageHelper extends LoginPageElements {
|
||||
super(driver);
|
||||
}
|
||||
|
||||
public void login(String username, String password) {
|
||||
emailField().sendKeys(username);
|
||||
passwordField().sendKeys(password);
|
||||
public void authorizationTenant() {
|
||||
emailField().sendKeys(Const.TENANT_EMAIL);
|
||||
passwordField().sendKeys(Const.TENANT_PASSWORD);
|
||||
submitBtn().click();
|
||||
waitUntilUrlContainsText("/home");
|
||||
}
|
||||
|
||||
public void authorizationTenant() {
|
||||
login(Const.TENANT_EMAIL, Const.TENANT_PASSWORD);
|
||||
}
|
||||
|
||||
public void authorizationCustomer() {
|
||||
login("customer@thingsboard.org", "customer");
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@ import org.thingsboard.server.common.data.id.CustomerId;
|
||||
import org.thingsboard.server.common.data.id.DeviceId;
|
||||
import org.thingsboard.server.common.data.id.UserId;
|
||||
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
|
||||
import org.thingsboard.server.msa.ui.pages.AlarmDetailsEntityTabHelper;
|
||||
import org.thingsboard.server.msa.ui.pages.AlarmDetailsViewHelper;
|
||||
import org.thingsboard.server.msa.ui.pages.AlarmHelper;
|
||||
import org.thingsboard.server.msa.ui.pages.CustomerPageHelper;
|
||||
import org.thingsboard.server.msa.ui.pages.DevicePageHelper;
|
||||
import org.thingsboard.server.msa.ui.pages.LoginPageHelper;
|
||||
@ -39,56 +39,68 @@ abstract public class AbstractAssignTest extends AbstractDriverBaseTest {
|
||||
protected AlarmId alarmId;
|
||||
protected AlarmId assignedAlarmId;
|
||||
protected DeviceId deviceId;
|
||||
|
||||
protected UserId userId;
|
||||
protected UserId userWithNameId;
|
||||
protected CustomerId customerId;
|
||||
|
||||
protected String deviceName;
|
||||
protected String userName;
|
||||
protected String customerTitle;
|
||||
protected String userEmail;
|
||||
protected String userWithNameEmail;
|
||||
protected String alarmType;
|
||||
protected String assignedAlarmType;
|
||||
|
||||
protected SideBarMenuViewHelper sideBarMenuView;
|
||||
protected AlarmHelper alarmPage;
|
||||
protected AlarmDetailsEntityTabHelper alarmPage;
|
||||
protected DevicePageHelper devicePage;
|
||||
protected CustomerPageHelper customerPage;
|
||||
protected AlarmDetailsViewHelper alarmDetailsView;
|
||||
|
||||
protected String userName = "User " + random();
|
||||
protected String customerTitle = "Customer " + random();
|
||||
protected String userEmail = random() + "@thingsboard.org";
|
||||
protected String userWithNameEmail = random() + "@thingsboard.org";
|
||||
protected String alarm = "Test alarm " + random();
|
||||
protected String assignedAlarm = "Test assigned alarm " + random();
|
||||
|
||||
@BeforeClass
|
||||
public void generateTestEntity() {
|
||||
public void generateCommonTestEntity() {
|
||||
new LoginPageHelper(driver).authorizationTenant();
|
||||
sideBarMenuView = new SideBarMenuViewHelper(driver);
|
||||
alarmPage = new AlarmHelper(driver);
|
||||
alarmPage = new AlarmDetailsEntityTabHelper(driver);
|
||||
devicePage = new DevicePageHelper(driver);
|
||||
customerPage = new CustomerPageHelper(driver);
|
||||
alarmDetailsView = new AlarmDetailsViewHelper(driver);
|
||||
|
||||
userName = "User " + random();
|
||||
customerTitle = "Customer " + random();
|
||||
userEmail = random() + "@thingsboard.org";
|
||||
userWithNameEmail = random() + "@thingsboard.org";
|
||||
alarmType = "Test alarm " + random();
|
||||
assignedAlarmType = "Test assigned alarm " + random();
|
||||
|
||||
customerId = testRestClient.postCustomer(EntityPrototypes.defaultCustomerPrototype(customerTitle)).getId();
|
||||
userId = testRestClient.postUser(EntityPrototypes.defaultUser(userEmail, getCustomerByName(customerTitle).getId())).getId();
|
||||
userWithNameId = testRestClient.postUser(EntityPrototypes.defaultUser(userWithNameEmail, getCustomerByName(customerTitle).getId(), userName)).getId();
|
||||
deviceName = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype("", customerId)).getName();
|
||||
deviceName = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype("Device ", customerId)).getName();
|
||||
deviceId = testRestClient.getDeviceByName(deviceName).getId();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public void deleteEntities() {
|
||||
public void deleteCommonEntities() {
|
||||
testRestClient.deleteCustomer(customerId);
|
||||
testRestClient.deleteDevice(deviceId);
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void createTestAlarms() {
|
||||
alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, alarm)).getId();
|
||||
assignedAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, assignedAlarm, userId)).getId();
|
||||
public void createCommonTestAlarms() {
|
||||
alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, alarmType)).getId();
|
||||
assignedAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, assignedAlarmType, userId)).getId();
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void deleteCreatedAlarms() {
|
||||
public void deleteCommonCreatedAlarms() {
|
||||
testRestClient.deleteAlarm(alarmId);
|
||||
testRestClient.deleteAlarm(assignedAlarmId);
|
||||
}
|
||||
|
||||
public void loginByUser(String userEmail) {
|
||||
sideBarMenuView.customerBtn().click();
|
||||
customerPage.manageCustomersUserBtn(customerTitle).click();
|
||||
customerPage.getUserLoginBtnByEmail(userEmail).click();
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@ import org.testng.annotations.Test;
|
||||
import org.thingsboard.server.common.data.id.AlarmId;
|
||||
import org.thingsboard.server.common.data.id.AssetId;
|
||||
import org.thingsboard.server.common.data.id.EntityViewId;
|
||||
import org.thingsboard.server.msa.ui.pages.AssetPageElements;
|
||||
import org.thingsboard.server.msa.ui.pages.EntityViewPage;
|
||||
import org.thingsboard.server.msa.ui.pages.AssetPageHelper;
|
||||
import org.thingsboard.server.msa.ui.pages.EntityViewPageHelper;
|
||||
import org.thingsboard.server.msa.ui.utils.Const;
|
||||
import org.thingsboard.server.msa.ui.utils.EntityPrototypes;
|
||||
|
||||
@ -34,36 +34,49 @@ import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random;
|
||||
|
||||
public class AssignDetailsTabAssignTest extends AbstractAssignTest {
|
||||
|
||||
private AssetId assetId;
|
||||
private AlarmId propageteAlarmId;
|
||||
private AlarmId propageteAssigneAlarmId;
|
||||
private AlarmId customerAlarmId;
|
||||
private AlarmId assetAlarmId;
|
||||
private AlarmId entityViewAlarmId;
|
||||
private EntityViewId entityViewId;
|
||||
|
||||
private String assetName;
|
||||
private String entityViewName;
|
||||
private final String propagateAlarm = "Test propagated alarm 1 " + random();
|
||||
private final String propagateAssignedAlarm = "Test propagated alarm 2 " + random();
|
||||
private final String customerAlarm = "Test customer alarm" + random();
|
||||
private final String assetAlarm = "Test asset alarm" + random();
|
||||
private final String entityViewAlarm = "Test entity view alarm" + random();
|
||||
private AssetId assetId;
|
||||
private EntityViewId entityViewId;
|
||||
private String propagateAlarmType;
|
||||
private String propagateAssignedAlarmType;
|
||||
private String customerAlarmType;
|
||||
private String assetAlarmType;
|
||||
private String entityViewAlarmType;
|
||||
|
||||
private AssetPageHelper assetPage;
|
||||
private EntityViewPageHelper entityViewPage;
|
||||
|
||||
@BeforeClass
|
||||
public void generateTestEntities() {
|
||||
customerAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(customerId, customerAlarm)).getId();
|
||||
assetId = testRestClient.postAsset(EntityPrototypes.defaultAssetPrototype("", customerId)).getId();
|
||||
assetPage = new AssetPageHelper(driver);
|
||||
entityViewPage = new EntityViewPageHelper(driver);
|
||||
|
||||
customerAlarmType = "Test customer alarm" + random();
|
||||
assetAlarmType = "Test asset alarm" + random();
|
||||
entityViewAlarmType = "Test entity view alarm" + random();
|
||||
propagateAlarmType = "Test propagated alarm " + random();
|
||||
propagateAssignedAlarmType = "Test propagated alarm " + random();
|
||||
|
||||
customerAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(customerId, customerAlarmType)).getId();
|
||||
assetId = testRestClient.postAsset(EntityPrototypes.defaultAssetPrototype("Asset", customerId)).getId();
|
||||
assetName = testRestClient.getAssetById(assetId).getName();
|
||||
assetAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(assetId, assetAlarm)).getId();
|
||||
entityViewId = testRestClient.postEntityView(EntityPrototypes.defaultEntityViewPrototype("", "", "DEVICE")).getId();
|
||||
assetAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(assetId, assetAlarmType)).getId();
|
||||
entityViewId = testRestClient.postEntityView(EntityPrototypes.defaultEntityViewPrototype("Entity view", "", "DEVICE")).getId();
|
||||
entityViewName = testRestClient.getEntityViewById(entityViewId).getName();
|
||||
entityViewAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(entityViewId, entityViewAlarm)).getId();
|
||||
entityViewAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(entityViewId, entityViewAlarmType)).getId();
|
||||
}
|
||||
|
||||
@BeforeMethod
|
||||
public void generateTestAlarms() {
|
||||
propageteAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, propagateAlarm, true)).getId();
|
||||
propageteAssigneAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, propagateAssignedAlarm, userId, true)).getId();
|
||||
propageteAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, propagateAlarmType, true)).getId();
|
||||
propageteAssigneAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, propagateAssignedAlarmType, userId, true)).getId();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@ -84,15 +97,15 @@ public class AssignDetailsTabAssignTest extends AbstractAssignTest {
|
||||
@DataProvider
|
||||
public Object[][] alarms() {
|
||||
return new Object[][]{
|
||||
{alarm},
|
||||
{propagateAlarm}};
|
||||
{alarmType},
|
||||
{propagateAlarmType}};
|
||||
}
|
||||
|
||||
@DataProvider
|
||||
public Object[][] assignedAlarms() {
|
||||
return new Object[][]{
|
||||
{assignedAlarm},
|
||||
{propagateAssignedAlarm}};
|
||||
{assignedAlarmType},
|
||||
{propagateAssignedAlarmType}};
|
||||
}
|
||||
|
||||
@Test(dataProvider = "alarms")
|
||||
@ -135,7 +148,7 @@ public class AssignDetailsTabAssignTest extends AbstractAssignTest {
|
||||
public void searchByEmail() {
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.searchAlarm(alarm, Const.TENANT_EMAIL);
|
||||
alarmPage.searchAlarm(alarmType, Const.TENANT_EMAIL);
|
||||
alarmPage.setUsers();
|
||||
|
||||
assertThat(alarmPage.getUsers()).hasSize(1).as("Search result contains search input").contains(Const.TENANT_EMAIL);
|
||||
@ -146,7 +159,7 @@ public class AssignDetailsTabAssignTest extends AbstractAssignTest {
|
||||
public void searchByName() {
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.searchAlarm(alarm, userName);
|
||||
alarmPage.searchAlarm(alarmType, userName);
|
||||
alarmPage.setUsers();
|
||||
|
||||
assertThat(alarmPage.getUsers()).hasSize(1).as("Search result contains search input").contains(userName);
|
||||
@ -157,7 +170,7 @@ public class AssignDetailsTabAssignTest extends AbstractAssignTest {
|
||||
public void assignAlarmToYourselfFromDetails() {
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.alarmDetailsBtn(alarm).click();
|
||||
alarmPage.alarmDetailsBtn(alarmType).click();
|
||||
alarmDetailsView.assignAlarmTo(Const.TENANT_EMAIL);
|
||||
alarmDetailsView.closeAlarmDetailsViewBtn().click();
|
||||
|
||||
@ -168,7 +181,7 @@ public class AssignDetailsTabAssignTest extends AbstractAssignTest {
|
||||
public void assignAlarmToAnotherUserFromDetails() {
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.alarmDetailsBtn(alarm).click();
|
||||
alarmPage.alarmDetailsBtn(alarmType).click();
|
||||
alarmDetailsView.assignAlarmTo(userEmail);
|
||||
alarmDetailsView.closeAlarmDetailsViewBtn().click();
|
||||
|
||||
@ -179,18 +192,18 @@ public class AssignDetailsTabAssignTest extends AbstractAssignTest {
|
||||
public void unassignedAlarmFromDetails() {
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.alarmDetailsBtn(assignedAlarm).click();
|
||||
alarmPage.alarmDetailsBtn(assignedAlarmType).click();
|
||||
alarmDetailsView.unassignedAlarm();
|
||||
alarmDetailsView.closeAlarmDetailsViewBtn().click();
|
||||
|
||||
assertIsDisplayed(alarmPage.unassigned(assignedAlarm));
|
||||
assertIsDisplayed(alarmPage.unassigned(assignedAlarmType));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void reassignAlarmFromDetails() {
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.alarmDetailsBtn(assignedAlarm).click();
|
||||
alarmPage.alarmDetailsBtn(assignedAlarmType).click();
|
||||
alarmDetailsView.assignAlarmTo(Const.TENANT_EMAIL);
|
||||
alarmDetailsView.closeAlarmDetailsViewBtn().click();
|
||||
|
||||
@ -201,27 +214,25 @@ public class AssignDetailsTabAssignTest extends AbstractAssignTest {
|
||||
public void assignCustomerAlarmToYourself() {
|
||||
sideBarMenuView.customerBtn().click();
|
||||
customerPage.openCustomerAlarms(customerTitle);
|
||||
alarmPage.assignAlarmTo(customerAlarm, Const.TENANT_EMAIL);
|
||||
alarmPage.assignAlarmTo(customerAlarmType, Const.TENANT_EMAIL);
|
||||
|
||||
assertIsDisplayed(alarmPage.assignedUser(Const.TENANT_EMAIL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assignAssetAlarmToYourself() {
|
||||
AssetPageElements assetPageElements = new AssetPageElements(driver);
|
||||
sideBarMenuView.goToAssetsPage();
|
||||
assetPageElements.openAssetAlarms(assetName);
|
||||
alarmPage.assignAlarmTo(assetAlarm, Const.TENANT_EMAIL);
|
||||
assetPage.openAssetAlarms(assetName);
|
||||
alarmPage.assignAlarmTo(assetAlarmType, Const.TENANT_EMAIL);
|
||||
|
||||
assertIsDisplayed(alarmPage.assignedUser(Const.TENANT_EMAIL));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void assignEntityViewsAlarmToYourself() {
|
||||
EntityViewPage entityViewPage = new EntityViewPage(driver);
|
||||
sideBarMenuView.goToEntityViewsPage();
|
||||
entityViewPage.openEntityViewAlarms(entityViewName);
|
||||
alarmPage.assignAlarmTo(entityViewAlarm, Const.TENANT_EMAIL);
|
||||
alarmPage.assignAlarmTo(entityViewAlarmType, Const.TENANT_EMAIL);
|
||||
|
||||
assertIsDisplayed(alarmPage.assignedUser(Const.TENANT_EMAIL));
|
||||
}
|
||||
|
||||
@ -28,29 +28,26 @@ import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random;
|
||||
|
||||
public class AssignDetailsTabFromCustomerAssignTest extends AbstractAssignTest {
|
||||
|
||||
AlarmId tenantAlarmId;
|
||||
DeviceId tenantDeviceId;
|
||||
String tenantDeviceName;
|
||||
String tenantAlarm = "Test tenant alarm " + random();
|
||||
private AlarmId tenantAlarmId;
|
||||
private DeviceId tenantDeviceId;
|
||||
private String tenantDeviceName;
|
||||
|
||||
public void loginByUser(String userEmail) {
|
||||
sideBarMenuView.customerBtn().click();
|
||||
customerPage.manageCustomersUserBtn(customerTitle).click();
|
||||
customerPage.getUserLoginBtnByEmail(userEmail).click();
|
||||
}
|
||||
private String tenantAlarmType;
|
||||
|
||||
@BeforeMethod
|
||||
public void generateTenantEntity() {
|
||||
if (getJwtTokenFromLocalStorage() == null) {
|
||||
new LoginPageHelper(driver).authorizationTenant();
|
||||
}
|
||||
tenantAlarmType = "Test tenant alarm " + random();
|
||||
|
||||
tenantDeviceName = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype("")).getName();
|
||||
tenantDeviceId = testRestClient.getDeviceByName(tenantDeviceName).getId();
|
||||
tenantAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(tenantDeviceId, tenantAlarm)).getId();
|
||||
tenantAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(tenantDeviceId, tenantAlarmType)).getId();
|
||||
}
|
||||
|
||||
@AfterMethod
|
||||
public void clear() {
|
||||
public void deleteTenantEntity() {
|
||||
testRestClient.deleteAlarm(tenantAlarmId);
|
||||
testRestClient.deleteDevice(tenantDeviceId);
|
||||
clearStorage();
|
||||
@ -61,7 +58,7 @@ public class AssignDetailsTabFromCustomerAssignTest extends AbstractAssignTest {
|
||||
loginByUser(userEmail);
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.assignAlarmTo(alarm, userEmail);
|
||||
alarmPage.assignAlarmTo(alarmType, userEmail);
|
||||
|
||||
assertIsDisplayed(alarmPage.assignedUser(userEmail));
|
||||
}
|
||||
@ -71,7 +68,7 @@ public class AssignDetailsTabFromCustomerAssignTest extends AbstractAssignTest {
|
||||
loginByUser(userWithNameEmail);
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.assignAlarmTo(assignedAlarm, userName);
|
||||
alarmPage.assignAlarmTo(assignedAlarmType, userName);
|
||||
|
||||
assertIsDisplayed(alarmPage.assignedUser(userName));
|
||||
}
|
||||
@ -81,9 +78,9 @@ public class AssignDetailsTabFromCustomerAssignTest extends AbstractAssignTest {
|
||||
loginByUser(userWithNameEmail);
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.unassignedAlarm(assignedAlarm);
|
||||
alarmPage.unassignedAlarm(assignedAlarmType);
|
||||
|
||||
assertIsDisplayed(alarmPage.unassigned(assignedAlarm));
|
||||
assertIsDisplayed(alarmPage.unassigned(assignedAlarmType));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -91,16 +88,16 @@ public class AssignDetailsTabFromCustomerAssignTest extends AbstractAssignTest {
|
||||
loginByUser(userEmail);
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(deviceName);
|
||||
alarmPage.unassignedAlarm(assignedAlarm);
|
||||
alarmPage.unassignedAlarm(assignedAlarmType);
|
||||
|
||||
assertIsDisplayed(alarmPage.unassigned(assignedAlarm));
|
||||
assertIsDisplayed(alarmPage.unassigned(assignedAlarmType));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkTheDisplayOfNamesEmailsFromCustomer() {
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(tenantDeviceName);
|
||||
alarmPage.assignAlarmTo(tenantAlarm, Const.TENANT_EMAIL);
|
||||
alarmPage.assignAlarmTo(tenantAlarmType, Const.TENANT_EMAIL);
|
||||
devicePage.closeDeviceDetailsViewBtn().click();
|
||||
devicePage.assignToCustomerBtn(tenantDeviceName).click();
|
||||
devicePage.assignToCustomer(customerTitle);
|
||||
@ -115,14 +112,14 @@ public class AssignDetailsTabFromCustomerAssignTest extends AbstractAssignTest {
|
||||
public void reassignTenantForOldAlarm() {
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(tenantDeviceName);
|
||||
alarmPage.assignAlarmTo(tenantAlarm, Const.TENANT_EMAIL);
|
||||
alarmPage.assignAlarmTo(tenantAlarmType, Const.TENANT_EMAIL);
|
||||
devicePage.closeDeviceDetailsViewBtn().click();
|
||||
devicePage.assignToCustomerBtn(tenantDeviceName).click();
|
||||
devicePage.assignToCustomer(customerTitle);
|
||||
loginByUser(userEmail);
|
||||
sideBarMenuView.goToDevicesPage();
|
||||
devicePage.openDeviceAlarms(tenantDeviceName);
|
||||
alarmPage.assignBtn(tenantAlarm).click();
|
||||
jsClick(alarmPage.assignBtn(tenantAlarmType));
|
||||
|
||||
assertIsDisplayed(alarmPage.accessForbiddenDialogView());
|
||||
}
|
||||
|
||||
@ -149,5 +149,4 @@ public class DataProviderCredential {
|
||||
{description, newDescription, description + newDescription},
|
||||
{description, Keys.CONTROL + "A" + Keys.BACK_SPACE, ""}};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -18,11 +18,11 @@
|
||||
-->
|
||||
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
|
||||
|
||||
<suite name="Customer Smoke Tests">
|
||||
<suite name="Assignee ui tests">
|
||||
<listeners>
|
||||
<listener class-name="org.thingsboard.server.msa.ui.listeners.RetryTestListener"/>
|
||||
</listeners>
|
||||
<test name="Customer ui smoke tests">
|
||||
<test name="Assignee ui tests">
|
||||
<groups>
|
||||
<run>
|
||||
<exclude name="broken"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user