add tests on make default device profile

This commit is contained in:
Serafym Tuhai 2023-01-04 18:28:35 +02:00
parent 4c58de7949
commit 70a7b2c938
4 changed files with 82 additions and 1 deletions

View File

@ -315,6 +315,13 @@ public class TestRestClient {
.statusCode(HTTP_OK);
}
public void setDefaultDeviceProfile(DeviceProfileId deviceProfileId) {
given().spec(requestSpec)
.post("/api/deviceProfile/{deviceProfileId}/default", deviceProfileId.getId())
.then()
.statusCode(HTTP_OK);
}
public Customer postCustomer(Customer customer) {
return given().spec(requestSpec)
.body(customer)

View File

@ -37,6 +37,9 @@ public class ProfilesPageElements extends OtherPageElementsHelper {
private static final String ADD_DEVICE_PROFILE_ADD_BTN = ADD_DEVICE_PROFILE_VIEW + "//span[text() = 'Add']/..";
private static final String DEVISE_PROFILE_VIEW_DELETE_BTN = "//tb-device-profile//span[contains(text(),'Delete')]";
private static final String PROFILE_NAMES = "//tbody/mat-row/mat-cell[contains(@class,'name')]";
private static final String MAKE_DEFAULT_BTN = ENTITY + "/../..//mat-icon[contains(text(),' flag')]/../..";
private static final String DEFAULT = ENTITY + "/../..//mat-icon[text() = 'check_box']";
private static final String PROFILE_VIEW_MAKE_DEFAULT_BTN = "//span[text() = ' Make device profile default ']/..";
protected String getDeviseProfileViewDeleteBtn() {
return DEVISE_PROFILE_VIEW_DELETE_BTN;
@ -105,4 +108,16 @@ public class ProfilesPageElements extends OtherPageElementsHelper {
public List<WebElement> profileNames() {
return waitUntilElementsToBeClickable(PROFILE_NAMES);
}
public WebElement makeProfileDefaultBtn(String profileName) {
return waitUntilElementToBeClickable(String.format(MAKE_DEFAULT_BTN, profileName));
}
public WebElement defaultCheckbox(String profileName) {
return waitUntilElementToBeClickable(String.format(DEFAULT, profileName));
}
public WebElement profileViewMakeDefaultBtn() {
return waitUntilElementToBeClickable(PROFILE_VIEW_MAKE_DEFAULT_BTN);
}
}

View File

@ -16,7 +16,6 @@
package org.thingsboard.server.msa.ui.pages;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;

View File

@ -0,0 +1,60 @@
package org.thingsboard.server.msa.ui.tests.deviceProfileSmoke;
import io.qameta.allure.Description;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
import org.thingsboard.server.msa.ui.pages.LoginPageHelper;
import org.thingsboard.server.msa.ui.pages.ProfilesPageHelper;
import org.thingsboard.server.msa.ui.pages.SideBarMenuViewHelper;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD;
public class MakeDeviceProfileDefaultTest extends AbstractDriverBaseTest {
private SideBarMenuViewHelper sideBarMenuView;
private ProfilesPageHelper profilesPage;
@BeforeMethod
public void login() {
openLocalhost();
new LoginPageHelper(driver).authorizationTenant();
testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD);
sideBarMenuView = new SideBarMenuViewHelper(driver);
profilesPage = new ProfilesPageHelper(driver);
}
@AfterMethod
public void delete() {
testRestClient.setDefaultDeviceProfile(getDeviceProfileByName("default").getId());
}
@Test(priority = 10, groups = "smoke")
@Description
public void makeRuleChainRootByRightCornerBtn() {
sideBarMenuView.openDeviceProfiles();
profilesPage.setProfileName();
String profile = profilesPage.getProfileName();
profilesPage.makeProfileDefaultBtn(profile).click();
profilesPage.warningPopUpYesBtn().click();
Assert.assertTrue(profilesPage.defaultCheckbox(profile).isDisplayed());
}
@Test(priority = 20, groups = "smoke")
@Description
public void makeRuleChainRootFromView() {
sideBarMenuView.openDeviceProfiles();
profilesPage.setProfileName();
String profile = profilesPage.getProfileName();
profilesPage.entity(profile).click();
profilesPage.profileViewMakeDefaultBtn().click();
profilesPage.warningPopUpYesBtn().click();
profilesPage.closeEntityViewBtn().click();
Assert.assertTrue(profilesPage.defaultCheckbox(profile).isDisplayed());
}
}