Browse Source

add test on customer, asset and entity view alarm

pull/8370/head
Seraphym-Tuhai 3 years ago
parent
commit
c9760ab55b
  1. 42
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestRestClient.java
  2. 14
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java
  3. 23
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/AlarmDetailsViewElements.java
  4. 15
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/AlarmDetailsViewHelper.java
  5. 5
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/AlarmElements.java
  6. 10
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java
  7. 7
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageHelper.java
  8. 27
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DevicePageElements.java
  9. 6
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DevicePageHelper.java
  10. 10
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewElements.java
  11. 10
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewHelper.java
  12. 15
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assignee/AbstractAssignByCustomerTest.java
  13. 52
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assignee/AbstractAssignTest.java
  14. 15
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assignee/AssignByCustomerTest.java
  15. 88
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assignee/AssignDetailsTab.java
  16. 18
      msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/EntityPrototypes.java

42
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestRestClient.java

@ -29,16 +29,20 @@ import io.restassured.specification.RequestSpecification;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.EntityView;
import org.thingsboard.server.common.data.Tenant;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.alarm.Alarm;
import org.thingsboard.server.common.data.asset.Asset;
import org.thingsboard.server.common.data.asset.AssetProfile;
import org.thingsboard.server.common.data.id.AlarmId;
import org.thingsboard.server.common.data.id.AssetId;
import org.thingsboard.server.common.data.id.AssetProfileId;
import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.DeviceId;
import org.thingsboard.server.common.data.id.DeviceProfileId;
import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.EntityViewId;
import org.thingsboard.server.common.data.id.RuleChainId;
import org.thingsboard.server.common.data.id.UserId;
import org.thingsboard.server.common.data.page.PageData;
@ -445,4 +449,42 @@ public class TestRestClient {
.as(new TypeRef<PageData<Tenant>>() {
});
}
public Asset postAsset(Asset asset) {
return given().spec(requestSpec)
.body(asset)
.post("/api/asset")
.then()
.statusCode(HTTP_OK)
.extract()
.as(Asset.class);
}
public Asset getAssetById(AssetId assetId) {
return given().spec(requestSpec)
.get("/api/asset/{assetId}", assetId.getId())
.then()
.statusCode(HTTP_OK)
.extract()
.as(Asset.class);
}
public EntityView postEntityView(EntityView entityView) {
return given().spec(requestSpec)
.body(entityView)
.post("/api/entityView")
.then()
.statusCode(HTTP_OK)
.extract()
.as(EntityView.class);
}
public EntityView getEntityViewById(EntityViewId entityViewId) {
return given().spec(requestSpec)
.get("/api/entityView/{entityViewId}", entityViewId.getId())
.then()
.statusCode(HTTP_OK)
.extract()
.as(EntityView.class);
}
}

14
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java

@ -27,6 +27,7 @@ import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.html5.WebStorage;
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
@ -179,4 +180,17 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest {
new ByteArrayInputStream(((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES)));
}
}
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();
}
}

23
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/AlarmDetailsViewElements.java

@ -1,3 +1,18 @@
/**
* 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;
@ -9,9 +24,9 @@ public class AlarmDetailsViewElements extends AbstractBasePage {
super(driver);
}
private static final String ASSIGN_FIELD = "//mat-label[contains(text(),'Assignee')]/parent::label/following-sibling::input";
private static final String ASSIGN_FIELD = "//tb-alarm-assignee//mat-icon[contains(text(),'keyboard_arrow_down')]/parent::button";
private static final String USER_FROM_DROP_DOWN = "//div[@class='user-display-name']/span[text() = '%s']";
private static final String CLOSE_VIEW_BTN = "//mat-dialog-container//mat-icon[contains(text(),'close')]/parent::button";
private static final String CLOSE_ALARM_DETAILS_VIEW_BTN = "//mat-dialog-container//mat-icon[contains(text(),'close')]/parent::button";
private static final String UNASSIGNED_BTN = "//div[@role='listbox']//mat-icon[text() = 'account_circle']/following-sibling::span";
public WebElement assignField() {
@ -22,8 +37,8 @@ public class AlarmDetailsViewElements extends AbstractBasePage {
return waitUntilElementToBeClickable(String.format(USER_FROM_DROP_DOWN, emailOrName));
}
public WebElement closeViewBtn() {
return waitUntilElementToBeClickable(CLOSE_VIEW_BTN);
public WebElement closeAlarmDetailsViewBtn() {
return waitUntilElementToBeClickable(CLOSE_ALARM_DETAILS_VIEW_BTN);
}
public WebElement unassignedBtn() {

15
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/AlarmDetailsViewHelper.java

@ -1,3 +1,18 @@
/**
* 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;

5
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/AlarmElements.java

@ -33,6 +33,7 @@ public class AlarmElements extends OtherPageElements{
private static final String UNASSIGNED_BTN = "//div[@role='listbox']//mat-icon[text() = 'account_circle']/following-sibling::span";
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";
public WebElement assignBtn(String type) {
return waitUntilElementToBeClickable(String.format(ASSIGN_BTN, type));
@ -65,4 +66,8 @@ public class AlarmElements extends OtherPageElements{
public WebElement alarmDetailsBtn(String alarmType) {
return waitUntilElementToBeClickable(String.format(ALARM_DETAILS_BTN, alarmType));
}
public WebElement accessForbiddenDialogView() {
return waitUntilVisibilityOfElementLocated(ACCESS_FORBIDDEN_DIALOG_VIEW);
}
}

10
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java

@ -73,6 +73,8 @@ public class CustomerPageElements extends OtherPageElementsHelper {
private static final String MANAGE_CUSTOMERS_DASHBOARD_BTN_VIEW = "Manage dashboards";
private static final String MANAGE_CUSTOMERS_EDGE_BTN_VIEW = "Manage edges ";
private static final String DELETE_FROM_VIEW_BTN = "//tb-customer//span[contains(text(),' Delete')]";
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 titleFieldAddEntityView() {
return waitUntilElementToBeClickable(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_TITLE));
@ -285,4 +287,12 @@ public class CustomerPageElements extends OtherPageElementsHelper {
public WebElement customerViewDeleteBtn() {
return waitUntilElementToBeClickable(DELETE_FROM_VIEW_BTN);
}
public WebElement customerDetailsView() {
return waitUntilPresenceOfElementLocated(CUSTOMER_DETAILS_VIEW);
}
public WebElement customerDetailsAlarmsBtn() {
return waitUntilElementToBeClickable(CUSTOMER_DETAILS_ALARMS);
}
}

7
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageHelper.java

@ -161,4 +161,11 @@ public class CustomerPageHelper extends CustomerPageElements {
phoneNumberEntityView().sendKeys(number);
phoneNumberEntityView().sendKeys(Keys.TAB);
}
public void openCustomerAlarms(String customerName) {
if (!customerDetailsView().isDisplayed()) {
customer(customerName).click();
}
customerDetailsAlarmsBtn().click();
}
}

27
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DevicePageElements.java

@ -26,7 +26,12 @@ public class DevicePageElements extends OtherPageElements{
private static final String DEVICE = "//table//span[text()='%s']";
private static final String DEVICE_DETAILS_VIEW = "//tb-details-panel";
private static final String DEVICE_DETAILS_ALARMS = DEVICE_DETAILS_VIEW + "//span[text()='Alarms']";
private static final String ASSIGN_TO_CUSTOMER_BTN = "//mat-cell[contains(@class,'name')]/span[text()='%s']" +
"/ancestor::mat-row//mat-icon[contains(text(),'assignment_ind')]/parent::button";
private static final String CHOOSE_CUSTOMER_FOR_ASSIGN_FIELD = "//input[@formcontrolname='entity']";
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));
}
@ -38,4 +43,24 @@ public class DevicePageElements extends OtherPageElements{
public WebElement deviceDetailsView() {
return waitUntilPresenceOfElementLocated(DEVICE_DETAILS_VIEW);
}
public WebElement assignToCustomerBtn(String deviceName) {
return waitUntilElementToBeClickable(String.format(ASSIGN_TO_CUSTOMER_BTN, deviceName));
}
public WebElement chooseCustomerForAssignField() {
return waitUntilElementToBeClickable(CHOOSE_CUSTOMER_FOR_ASSIGN_FIELD);
}
public WebElement customerFromAssignDropdown(String customerTitle) {
return waitUntilElementToBeClickable(String.format(CUSTOMER_FROM_ASSIGN_DROPDOWN, customerTitle));
}
public WebElement closeDeviceDetailsViewBtn() {
return waitUntilElementToBeClickable(CLOSE_DEVICE_DETAILS_VIEW);
}
public WebElement submitAssignToCustomerBtn() {
return waitUntilElementToBeClickable(SUBMIT_ASSIGN_TO_CUSTOMER_BTN);
}
}

6
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DevicePageHelper.java

@ -28,4 +28,10 @@ public class DevicePageHelper extends DevicePageElements {
}
deviceDetailsAlarmsBtn().click();
}
public void assignToCustomer(String customerTitle) {
chooseCustomerForAssignField().click();
customerFromAssignDropdown(customerTitle).click();
submitAssignToCustomerBtn().click();
}
}

10
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewElements.java

@ -33,6 +33,8 @@ public class SideBarMenuViewElements extends AbstractBasePage {
private static final String ALARMS_BTN = "//mat-toolbar//a[@href='/alarms']";
private static final String ENTITIES_DROPDOWN = "//mat-toolbar//mat-icon[text()='category']/ancestor::a//span[contains(@class,'pull-right')]";
private static final String DEVICES_BTN = "//ul[@id='docs-menu-entity.entities']//span[text()='Devices']";
private static final String ASSETS_BTN = "//ul[@id='docs-menu-entity.entities']//span[text()='Assets']";
private static final String ENTITY_VIEWS_BTN = "//ul[@id='docs-menu-entity.entities']//span[text()='Entity Views']";
public WebElement entitiesDropdown() {
return waitUntilElementToBeClickable(ENTITIES_DROPDOWN);
@ -69,4 +71,12 @@ public class SideBarMenuViewElements extends AbstractBasePage {
public WebElement devicesBtn() {
return waitUntilElementToBeClickable(DEVICES_BTN);
}
public WebElement assetsBtn() {
return waitUntilElementToBeClickable(ASSETS_BTN);
}
public WebElement entityViewsBtn() {
return waitUntilElementToBeClickable(ENTITY_VIEWS_BTN);
}
}

10
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewHelper.java

@ -38,6 +38,16 @@ public class SideBarMenuViewHelper extends SideBarMenuViewElements {
devicesBtn().click();
}
public void goToAssetsPage() {
openEntitiesDropdown();
assetsBtn().click();
}
public void goToEntityViewsPage() {
openEntitiesDropdown();
entityViewsBtn().click();
}
public void openEntitiesDropdown() {
if (entitiesDropdownIsClose()) {
entitiesDropdown().click();

15
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assignee/AbstractAssignByCustomerTest.java

@ -1,3 +1,18 @@
/**
* 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.tests.assignee;
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;

52
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assignee/AbstractAssignTest.java

@ -1,15 +1,30 @@
/**
* 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.tests.assignee;
import org.openqa.selenium.WebElement;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.thingsboard.server.common.data.id.AlarmId;
import org.thingsboard.server.common.data.id.AssetId;
import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.DeviceId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.EntityViewId;
import org.thingsboard.server.common.data.id.UserId;
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
import org.thingsboard.server.msa.ui.pages.AlarmDetailsViewHelper;
@ -20,8 +35,6 @@ import org.thingsboard.server.msa.ui.pages.LoginPageHelper;
import org.thingsboard.server.msa.ui.pages.SideBarMenuViewHelper;
import org.thingsboard.server.msa.ui.utils.EntityPrototypes;
import java.util.List;
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random;
abstract public class AbstractAssignTest extends AbstractDriverBaseTest {
@ -30,13 +43,19 @@ abstract public class AbstractAssignTest extends AbstractDriverBaseTest {
protected AlarmId assignedAlarmId;
protected AlarmId propageteAlarmId;
protected AlarmId propageteAssigneAlarmId;
protected AlarmId tenantAssigneAlarmId;
protected AlarmId tenantAlarmId;
protected AlarmId onCustomerAlarmId;
protected AlarmId assetAlarmId;
protected AlarmId entityViewAlarmId;
protected DeviceId deviceId;
protected DeviceId tenantDeviceId;
protected UserId userId;
protected UserId userWithNameId;
// protected TenantId tenantId = testRestClient.getTenants(pageLink).getData().get(0).getId();
protected CustomerId customerId;
protected String deviceName;
protected String assetName;
protected String entityViewName;
protected String tenantDeviceName;
protected SideBarMenuViewHelper sideBarMenuView;
protected AlarmHelper alarmPage;
protected DevicePageHelper devicePage;
@ -51,6 +70,12 @@ abstract public class AbstractAssignTest extends AbstractDriverBaseTest {
protected String assignedAlarm = "Test alarm 2";
protected String propagateAlarm = "Test propagated alarm 1";
protected String propagateAssignedAlarm = "Test propagated alarm 2";
protected String tenantAlarm = "Test tenant alarm";
protected String customerAlarm = "Test customer alarm";
protected String assetAlarm = "Test asset alarm";
protected String entityViewAlarm = "Test entity view alarm";
protected AssetId assetId;
protected EntityViewId entityViewId;
@BeforeClass
public void generateTestEntities() {
@ -65,7 +90,16 @@ abstract public class AbstractAssignTest extends AbstractDriverBaseTest {
userId = testRestClient.postUser(EntityPrototypes.defaultUser(userEmail, getCustomerByName(customerTitle).getId())).getId();
userWithNameId = testRestClient.postUser(EntityPrototypes.defaultUser(userWithNameEmail, getCustomerByName(customerTitle).getId(), name)).getId();
deviceName = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype("", customerId)).getName();
tenantDeviceName = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype("")).getName();
deviceId = testRestClient.getDeviceByName(deviceName).getId();
tenantDeviceId = testRestClient.getDeviceByName(tenantDeviceName).getId();
onCustomerAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(customerId, customerAlarm)).getId();
assetId = testRestClient.postAsset(EntityPrototypes.defaultAssetPrototype("", customerId)).getId();
assetName = testRestClient.getAssetById(assetId).getName();
assetAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(assetId, assetAlarm)).getId();
entityViewId = testRestClient.postEntityView(EntityPrototypes.defaultEntityViewPrototype("", "", "DEVICE")).getId();
entityViewName = testRestClient.getEntityViewById(entityViewId).getName();
entityViewAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(entityViewId, entityViewAlarm)).getId();
}
@BeforeMethod
@ -78,13 +112,18 @@ abstract public class AbstractAssignTest extends AbstractDriverBaseTest {
propageteAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, propagateAlarm, true)).getId();
propageteAssigneAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, propagateAssignedAlarm, userId, true)).getId();
tenantAlarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(tenantDeviceId, tenantAlarm)).getId();
}
@AfterClass
public void deleteTestEntities() {
testRestClient.deleteDevice(deviceId);
testRestClient.deleteDevice(tenantDeviceId);
testRestClient.deleteCustomer(customerId);
testRestClient.deleteAlarm(onCustomerAlarmId);
testRestClient.deleteAlarm(assetAlarmId);
testRestClient.deleteAlarm(entityViewAlarmId);
}
@AfterMethod
@ -93,6 +132,7 @@ abstract public class AbstractAssignTest extends AbstractDriverBaseTest {
testRestClient.deleteAlarm(assignedAlarmId);
testRestClient.deleteAlarm(propageteAlarmId);
testRestClient.deleteAlarm(propageteAssigneAlarmId);
testRestClient.deleteAlarm(tenantAlarmId);
}
public void loginByUser(String userEmail) {

15
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assignee/AssignByCustomerTest.java

@ -1,3 +1,18 @@
/**
* 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.tests.assignee;
public class AssignByCustomerTest extends AbstractAssignByCustomerTest{

88
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assignee/AssignDetailsTab.java

@ -15,22 +15,15 @@
*/
package org.thingsboard.server.msa.ui.tests.assignee;
import org.junit.platform.commons.function.Try;
import org.openqa.selenium.html5.WebStorage;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.thingsboard.server.msa.ui.pages.AssetPageElements;
import org.thingsboard.server.msa.ui.utils.Const;
import static org.assertj.core.api.Assertions.assertThat;
public class AssignDetailsTab extends AbstractAssignTest {
/*@BeforeMethod
public void openAlarmView() {
sideBarMenuView.goToDevicesPage();
devicePage.openDeviceAlarms(deviceName);
}*/
@Test(dataProvider = "alarms")
public void assignAlarmToYourself(String alarm) {
sideBarMenuView.goToDevicesPage();
@ -85,7 +78,7 @@ public class AssignDetailsTab extends AbstractAssignTest {
alarmPage.searchAlarm(alarm, name);
alarmPage.setUsers();
assertThat(alarmPage.getUsers()).hasSize(1).contains(name);
//assertThat(alarmPage.getUsers()).hasSize(1).contains(name);
alarmPage.assignUsers().forEach(u -> assertThat(u.isDisplayed()).isTrue());
}
@ -95,7 +88,7 @@ public class AssignDetailsTab extends AbstractAssignTest {
devicePage.openDeviceAlarms(deviceName);
alarmPage.alarmDetailsBtn(alarm).click();
alarmDetailsView.assignAlarmTo(Const.TENANT_EMAIL);
alarmDetailsView.closeViewBtn().click();
alarmDetailsView.closeAlarmDetailsViewBtn().click();
Assert.assertTrue(alarmPage.assignedUser(Const.TENANT_EMAIL).isDisplayed());
}
@ -106,7 +99,7 @@ public class AssignDetailsTab extends AbstractAssignTest {
devicePage.openDeviceAlarms(deviceName);
alarmPage.alarmDetailsBtn(alarm).click();
alarmDetailsView.assignAlarmTo(userEmail);
alarmDetailsView.closeViewBtn().click();
alarmDetailsView.closeAlarmDetailsViewBtn().click();
Assert.assertTrue(alarmPage.assignedUser(userEmail).isDisplayed());
}
@ -117,7 +110,7 @@ public class AssignDetailsTab extends AbstractAssignTest {
devicePage.openDeviceAlarms(deviceName);
alarmPage.alarmDetailsBtn(assignedAlarm).click();
alarmDetailsView.unassignedAlarm();
alarmDetailsView.closeViewBtn().click();
alarmDetailsView.closeAlarmDetailsViewBtn().click();
Assert.assertTrue(alarmPage.unassigned(assignedAlarm).isDisplayed());
}
@ -128,7 +121,7 @@ public class AssignDetailsTab extends AbstractAssignTest {
devicePage.openDeviceAlarms(deviceName);
alarmPage.alarmDetailsBtn(assignedAlarm).click();
alarmDetailsView.assignAlarmTo(Const.TENANT_EMAIL);
alarmDetailsView.closeViewBtn().click();
alarmDetailsView.closeAlarmDetailsViewBtn().click();
Assert.assertTrue(alarmPage.assignedUser(Const.TENANT_EMAIL).isDisplayed());
}
@ -180,30 +173,63 @@ public class AssignDetailsTab extends AbstractAssignTest {
@Test
public void checkTheDisplayOfNamesEmailsFromCustomer() {
sideBarMenuView.goToDevicesPage();
devicePage.openDeviceAlarms(deviceName);
alarmPage.assignAlarmTo(alarm, Const.TENANT_EMAIL);
devicePage.openDeviceAlarms(tenantDeviceName);
alarmPage.assignAlarmTo(tenantAlarm, Const.TENANT_EMAIL);
devicePage.closeDeviceDetailsViewBtn().click();
devicePage.assignToCustomerBtn(tenantDeviceName).click();
devicePage.assignToCustomer(customerTitle);
loginByUser(userEmail);
sideBarMenuView.goToDevicesPage();
devicePage.openDeviceAlarms(deviceName);
alarmPage.assignBtn(alarm).click();
try {
alarmPage.assertUsersForAssignIsNotPresent();
} finally {
clearStorage();
}
devicePage.openDeviceAlarms(tenantDeviceName);
clearStorage();
Assert.assertTrue(alarmPage.assignedUser(Const.TENANT_EMAIL).isDisplayed());
}
@Test
public void reassignTenantForOldAlarm() {
sideBarMenuView.goToDevicesPage();
devicePage.openDeviceAlarms(tenantDeviceName);
alarmPage.assignAlarmTo(tenantAlarm, Const.TENANT_EMAIL);
devicePage.closeDeviceDetailsViewBtn().click();
devicePage.assignToCustomerBtn(tenantDeviceName).click();
devicePage.assignToCustomer(customerTitle);
loginByUser(userEmail);
sideBarMenuView.goToDevicesPage();
devicePage.openDeviceAlarms(tenantDeviceName);
alarmPage.assignAlarmTo(tenantAlarm, userEmail);
clearStorage();
Assert.assertTrue(alarmPage.accessForbiddenDialogView().isDisplayed());
}
@Test
public void assignCustomerAlarmToYourself() {
sideBarMenuView.customerBtn().click();
customerPage.openCustomerAlarms(customerTitle);
alarmPage.assignAlarmTo(customerAlarm, userEmail);
Assert.assertTrue(alarmPage.assignedUser(userEmail).isDisplayed());
}
public WebStorage getWebStorage() {
if (driver instanceof WebStorage) {
return (WebStorage) driver;
} else {
throw new IllegalArgumentException("This test expects the driver to implement WebStorage");
}
@Test
public void assignAssetAlarmToYourself() {
AssetPageElements assetPageElements = new AssetPageElements(driver);
sideBarMenuView.goToAssetsPage();
assetPageElements.openAssetAlarms(customerTitle);
alarmPage.assignAlarmTo(assetAlarm, userEmail);
Assert.assertTrue(alarmPage.assignedUser(userEmail).isDisplayed());
}
public void clearStorage() {
getWebStorage().getLocalStorage().clear();
getWebStorage().getSessionStorage().clear();
@Test
public void assignEntityViewsAlarmToYourself() {
AssetPageElements assetPageElements = new AssetPageElements(driver);
sideBarMenuView.goToEntityViewsPage();
assetPageElements.openAssetAlarms(entityViewName);
alarmPage.assignAlarmTo(entityViewAlarm, userEmail);
Assert.assertTrue(alarmPage.assignedUser(userEmail).isDisplayed());
}
}

18
msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/EntityPrototypes.java

@ -23,9 +23,11 @@ import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.DeviceProfileProvisionType;
import org.thingsboard.server.common.data.DeviceProfileType;
import org.thingsboard.server.common.data.DeviceTransportType;
import org.thingsboard.server.common.data.EntityView;
import org.thingsboard.server.common.data.User;
import org.thingsboard.server.common.data.alarm.Alarm;
import org.thingsboard.server.common.data.alarm.AlarmSeverity;
import org.thingsboard.server.common.data.asset.Asset;
import org.thingsboard.server.common.data.asset.AssetProfile;
import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration;
import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTransportConfiguration;
@ -177,4 +179,20 @@ public class EntityPrototypes {
device.setType("DEFAULT");
return device;
}
public static Asset defaultAssetPrototype(String name, CustomerId id){
Asset asset = new Asset();
asset.setName(name + RandomStringUtils.randomAlphanumeric(7));
asset.setCustomerId(id);
asset.setType("DEFAULT");
return asset;
}
public static EntityView defaultEntityViewPrototype(String name, String type, String entityType){
EntityView entityView = new EntityView();
entityView.setName(name + RandomStringUtils.randomAlphanumeric(7));
entityView.setType(type + RandomStringUtils.randomAlphanumeric(7));
entityView.setAdditionalInfo(JacksonUtil.newObjectNode().put("entityType", entityType));
return entityView;
}
}

Loading…
Cancel
Save