diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/devicessmoke/AssignToCustomerTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/devicessmoke/AssignToCustomerTest.java index 5a3404cee3..1d1c686d45 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/devicessmoke/AssignToCustomerTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/devicessmoke/AssignToCustomerTest.java @@ -15,6 +15,8 @@ */ package org.thingsboard.server.msa.ui.tests.devicessmoke; +import io.qameta.allure.Description; +import io.qameta.allure.Feature; import org.openqa.selenium.WebElement; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -27,16 +29,20 @@ import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.tabs.AssignDeviceTabHelper; import org.thingsboard.server.msa.ui.utils.EntityPrototypes; +import java.util.List; + import static org.assertj.core.api.Assertions.assertThat; import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; +@Feature("Assign to customer") public class AssignToCustomerTest extends AbstractDeviceTest { private AssignDeviceTabHelper assignDeviceTab; private CustomerPageHelper customerPage; private CustomerId customerId; private Device device; + private Device device1; private String customerName; @BeforeClass @@ -46,12 +52,14 @@ public class AssignToCustomerTest extends AbstractDeviceTest { Customer customer = testRestClient.postCustomer(EntityPrototypes.defaultCustomerPrototype(ENTITY_NAME + random())); customerId = customer.getId(); customerName = customer.getName(); + device1 = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype("Device " + random())); } @AfterClass public void deleteCustomer() { deleteCustomerById(customerId); deleteCustomerByName("Public"); + deleteDeviceByName(device1.getName()); } @BeforeMethod @@ -60,7 +68,8 @@ public class AssignToCustomerTest extends AbstractDeviceTest { deviceName = device.getName(); } - @Test + @Test(groups = "smoke") + @Description("Assign to customer by right side of device btn") public void assignToCustomerByRightSideBtn() { sideBarMenuView.goToDevicesPage(); devicePage.assignBtn(deviceName).click(); @@ -74,7 +83,8 @@ public class AssignToCustomerTest extends AbstractDeviceTest { assertIsDisplayed(devicePage.device(deviceName)); } - @Test + @Test(groups = "smoke") + @Description("Assign to customer by 'Assign to customer' btn on details tab") public void assignToCustomerFromDetailsTab() { sideBarMenuView.goToDevicesPage(); devicePage.device(deviceName).click(); @@ -93,7 +103,8 @@ public class AssignToCustomerTest extends AbstractDeviceTest { assertIsDisplayed(devicePage.device(deviceName)); } - @Test + @Test(groups = "smoke") + @Description("Assign marked device by btn on the top") public void assignToCustomerMarkedDevice() { sideBarMenuView.goToDevicesPage(); devicePage.assignMarkedDevices(deviceName); @@ -107,7 +118,8 @@ public class AssignToCustomerTest extends AbstractDeviceTest { assertIsDisplayed(devicePage.device(deviceName)); } - @Test + @Test(groups = "smoke") + @Description("Unassign from customer by right side of device btn") public void unassignedFromCustomerByRightSideBtn() { device.setCustomerId(customerId); testRestClient.postDevice("", device); @@ -122,7 +134,8 @@ public class AssignToCustomerTest extends AbstractDeviceTest { devicePage.assertEntityIsNotPresent(deviceName); } - @Test + @Test(groups = "smoke") + @Description("Unassign from customer by 'Unassign from customer' btn on details tab") public void unassignedFromCustomerFromDetailsTab() { device.setCustomerId(customerId); testRestClient.postDevice("", device); @@ -141,7 +154,8 @@ public class AssignToCustomerTest extends AbstractDeviceTest { devicePage.assertEntityIsNotPresent(deviceName); } - @Test + @Test(groups = "smoke") + @Description("Can't assign device on several customer") public void assignToSeveralCustomer() { device.setCustomerId(customerId); testRestClient.postDevice("", device); @@ -150,11 +164,30 @@ public class AssignToCustomerTest extends AbstractDeviceTest { assertIsDisable(devicePage.assignBtnVisible(deviceName)); } - @Test + @Test(groups = "smoke") + @Description("Can't assign public device") public void assignPublicDevice() { testRestClient.setDevicePublic(device.getId()); sideBarMenuView.goToDevicesPage(); assertIsDisable(devicePage.assignBtnVisible(deviceName)); } + + @Test(groups = "smoke") + @Description("Assign several devices by btn on the top") + public void assignSeveralDevices() { + sideBarMenuView.goToDevicesPage(); + devicePage.assignMarkedDevices(deviceName, device1.getName()); + assignDeviceTab.assignOnCustomer(customerName); + assertIsDisplayed(devicePage.deviceCustomerOnPage(deviceName)); + assertThat(devicePage.deviceCustomerOnPage(deviceName).getText()) + .as("Customer added correctly").isEqualTo(customerName); + assertThat(devicePage.deviceCustomerOnPage(device1.getName()).getText()) + .as("Customer added correctly").isEqualTo(customerName); + + sideBarMenuView.customerBtn().click(); + customerPage.manageCustomersDevicesBtn(customerName).click(); + List.of(deviceName, device1.getName()). + forEach(d -> assertIsDisplayed(devicePage.device(d))); + } }