10 changed files with 261 additions and 2 deletions
@ -0,0 +1,26 @@ |
|||||
|
package org.thingsboard.server.msa.ui.pages; |
||||
|
|
||||
|
import org.openqa.selenium.WebDriver; |
||||
|
import org.openqa.selenium.WebElement; |
||||
|
|
||||
|
public class AlarmElements extends OtherPageElements{ |
||||
|
public AlarmElements(WebDriver driver) { |
||||
|
super(driver); |
||||
|
} |
||||
|
|
||||
|
private static final String ASSIGN_BTN = "//mat-icon[contains(text(),'keyboard_arrow_down')]/parent::button"; |
||||
|
private static final String USER_ASSIGN_DROPDOWN = "//div[contains(@class,'tb-assignee')]//span[contains(text(),'%s')]"; |
||||
|
private static final String ASSIGN_USER_DISPLAY_NAME = "//span[text()='%s']/ancestor::mat-row//span[@class='user-display-name']"; |
||||
|
|
||||
|
public WebElement assignBtn() { |
||||
|
return waitUntilElementToBeClickable(ASSIGN_BTN); |
||||
|
} |
||||
|
|
||||
|
public WebElement userFromAssignDropDown(String userEmail) { |
||||
|
return waitUntilElementToBeClickable(String.format(USER_ASSIGN_DROPDOWN, userEmail)); |
||||
|
} |
||||
|
|
||||
|
public WebElement assignUserDisplayName(String userEmail) { |
||||
|
return waitUntilElementToBeClickable(String.format(ASSIGN_USER_DISPLAY_NAME, userEmail)); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package org.thingsboard.server.msa.ui.pages; |
||||
|
|
||||
|
import org.openqa.selenium.WebDriver; |
||||
|
|
||||
|
public class AlarmHelper extends AlarmElements { |
||||
|
public AlarmHelper(WebDriver driver) { |
||||
|
super(driver); |
||||
|
} |
||||
|
|
||||
|
public void assignTo(String user) { |
||||
|
jsClick(assignBtn()); |
||||
|
userFromAssignDropDown(user).click(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
package org.thingsboard.server.msa.ui.pages; |
||||
|
|
||||
|
import org.openqa.selenium.WebDriver; |
||||
|
import org.openqa.selenium.WebElement; |
||||
|
|
||||
|
public class DevicePageElements extends OtherPageElements{ |
||||
|
public DevicePageElements(WebDriver driver) { |
||||
|
super(driver); |
||||
|
} |
||||
|
|
||||
|
private static final String DEVICE = "//table//span[text()='%s']"; |
||||
|
private static final String DEVICE_DETAILS_ALARMS = "//tb-details-panel//span[text()='Alarms']"; |
||||
|
|
||||
|
public WebElement device(String deviceName) { |
||||
|
return waitUntilElementToBeClickable(String.format(DEVICE, deviceName)); |
||||
|
} |
||||
|
|
||||
|
public WebElement deviceDetailsAlarmsBtn() { |
||||
|
return waitUntilElementToBeClickable(DEVICE_DETAILS_ALARMS); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package org.thingsboard.server.msa.ui.pages; |
||||
|
|
||||
|
import org.openqa.selenium.WebDriver; |
||||
|
|
||||
|
public class DevicePageHelper extends DevicePageElements{ |
||||
|
public DevicePageHelper(WebDriver driver) { |
||||
|
super(driver); |
||||
|
} |
||||
|
|
||||
|
public void openDeviceAlarms(String deviceName) { |
||||
|
device(deviceName).click(); |
||||
|
deviceDetailsAlarmsBtn().click(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,73 @@ |
|||||
|
package org.thingsboard.server.msa.ui.tests; |
||||
|
|
||||
|
import org.testng.Assert; |
||||
|
import org.testng.annotations.AfterClass; |
||||
|
import org.testng.annotations.AfterMethod; |
||||
|
import org.testng.annotations.BeforeClass; |
||||
|
import org.testng.annotations.Test; |
||||
|
import org.thingsboard.server.common.data.id.AlarmId; |
||||
|
import org.thingsboard.server.common.data.id.DeviceId; |
||||
|
import org.thingsboard.server.common.data.id.UserId; |
||||
|
import org.thingsboard.server.msa.prototypes.DevicePrototypes; |
||||
|
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; |
||||
|
import org.thingsboard.server.msa.ui.pages.AlarmHelper; |
||||
|
import org.thingsboard.server.msa.ui.pages.DevicePageHelper; |
||||
|
import org.thingsboard.server.msa.ui.pages.LoginPageHelper; |
||||
|
import org.thingsboard.server.msa.ui.pages.SideBarMenuViewHelper; |
||||
|
import org.thingsboard.server.msa.ui.utils.DataProviderCredential; |
||||
|
import org.thingsboard.server.msa.ui.utils.EntityPrototypes; |
||||
|
|
||||
|
public class AssignDetailsTab extends AbstractDriverBaseTest { |
||||
|
|
||||
|
AlarmId alarmId; |
||||
|
DeviceId deviceId; |
||||
|
UserId userId; |
||||
|
String deviceName; |
||||
|
SideBarMenuViewHelper sideBarMenuView; |
||||
|
AlarmHelper alarmPage; |
||||
|
DevicePageHelper devicePage; |
||||
|
|
||||
|
@BeforeClass |
||||
|
public void generateAlarm() { |
||||
|
new LoginPageHelper(driver).authorizationTenant(); |
||||
|
sideBarMenuView = new SideBarMenuViewHelper(driver); |
||||
|
alarmPage = new AlarmHelper(driver); |
||||
|
devicePage = new DevicePageHelper(driver); |
||||
|
} |
||||
|
|
||||
|
@AfterMethod |
||||
|
public void deleteAlarm() { |
||||
|
testRestClient.deleteAlarm(alarmId); |
||||
|
testRestClient.deleteDevice(deviceId); |
||||
|
if (userId != null) { |
||||
|
testRestClient.deleteUser(userId); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Test(dataProviderClass = DataProviderCredential.class, dataProvider = "assignTo") |
||||
|
public void assignAlarmTo(String user) { |
||||
|
deviceName = testRestClient.postDevice("", DevicePrototypes.defaultDevicePrototype("")).getName(); |
||||
|
deviceId = testRestClient.getDeviceByName(deviceName).getId(); |
||||
|
alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId)).getId(); |
||||
|
|
||||
|
sideBarMenuView.goToDevicesPage(); |
||||
|
devicePage.openDeviceAlarms(deviceName); |
||||
|
alarmPage.assignTo(user); |
||||
|
|
||||
|
Assert.assertTrue(alarmPage.assignUserDisplayName(user).isDisplayed()); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void reassignAlarm() { |
||||
|
userId = testRestClient.postUser(EntityPrototypes.defaultUser(getCustomerByName("Customer A").getId())).getId(); |
||||
|
deviceName = testRestClient.postDevice("", DevicePrototypes.defaultDevicePrototype("")).getName(); |
||||
|
deviceId = testRestClient.getDeviceByName(deviceName).getId(); |
||||
|
alarmId = testRestClient.postAlarm(EntityPrototypes.defaultAlarm(deviceId, userId)).getId(); |
||||
|
|
||||
|
sideBarMenuView.goToDevicesPage(); |
||||
|
devicePage.openDeviceAlarms(deviceName); |
||||
|
alarmPage.assignTo("customer@thingsboard.org"); |
||||
|
|
||||
|
Assert.assertTrue(alarmPage.assignUserDisplayName("customer@thingsboard.org").isDisplayed()); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue