add tests on create and import device profiles

This commit is contained in:
Serafym Tuhai 2022-12-26 17:19:20 +02:00
parent d629151266
commit 3b891e5d10
2 changed files with 19 additions and 5 deletions

View File

@ -34,7 +34,7 @@ public class OtherPageElements extends AbstractBasePage {
private static final String WARNING_DELETE_POPUP_YES = "//tb-confirm-dialog//button[2]"; private static final String WARNING_DELETE_POPUP_YES = "//tb-confirm-dialog//button[2]";
private static final String WARNING_DELETE_POPUP_TITLE = "//tb-confirm-dialog/h2"; private static final String WARNING_DELETE_POPUP_TITLE = "//tb-confirm-dialog/h2";
private static final String REFRESH_BTN = "//mat-icon[contains(text(),'refresh')]/.."; private static final String REFRESH_BTN = "//mat-icon[contains(text(),'refresh')]/..";
private static final String HELP_BTN = "//mat-icon[contains(text(),'help')]/.."; private static final String HELP_BTN = "//mat-icon[contains(text(),'help')]/ancestor::button";
private static final String CHECKBOX = "//mat-row//span[contains(text(),'%s')]/../..//mat-checkbox"; private static final String CHECKBOX = "//mat-row//span[contains(text(),'%s')]/../..//mat-checkbox";
private static final String CHECKBOXES = "//tbody//mat-checkbox"; private static final String CHECKBOXES = "//tbody//mat-checkbox";
private static final String DELETE_SELECTED_BTN = "//span[contains(text(),'selected')]//..//mat-icon/../.."; private static final String DELETE_SELECTED_BTN = "//span[contains(text(),'selected')]//..//mat-icon/../..";

View File

@ -9,12 +9,13 @@ import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest;
import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper;
import org.thingsboard.server.msa.ui.pages.ProfilesPageHelper; import org.thingsboard.server.msa.ui.pages.ProfilesPageHelper;
import org.thingsboard.server.msa.ui.pages.SideBarMenuViewHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewHelper;
import org.thingsboard.server.msa.ui.utils.EntityPrototypes;
import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_IMPORT_MESSAGE; import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_IMPORT_MESSAGE;
import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_DEVICE_PROFILE_FILE_NAME; import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_DEVICE_PROFILE_FILE_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_DEVICE_PROFILE_NAME; import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_DEVICE_PROFILE_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_TXT_FILE_NAME; import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_TXT_FILE_NAME;
import static org.thingsboard.server.msa.ui.utils.Const.SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL;
import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD;
@ -82,16 +83,29 @@ public class CreateDeviceProfileImportTest extends AbstractDriverBaseTest {
@Test @Test
public void importDeviceProfileWithSameName() { public void importDeviceProfileWithSameName() {
String name = ENTITY_NAME; String name = IMPORT_DEVICE_PROFILE_NAME;
testRestClient.postDeviceProfile() testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name));
this.name = name;
sideBarMenuView.openDeviceProfiles(); sideBarMenuView.openDeviceProfiles();
profilesPage.openImportDeviceProfileView(); profilesPage.openImportDeviceProfileView();
profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile); profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile);
profilesPage.importBrowseFileBtn().click(); profilesPage.importBrowseFileBtn().click();
this.name = IMPORT_DEVICE_PROFILE_NAME;
profilesPage.refreshBtn().click(); profilesPage.refreshBtn().click();
Assert.assertNotNull(profilesPage.warningMessage());
Assert.assertTrue(profilesPage.warningMessage().isDisplayed());
Assert.assertEquals(profilesPage.warningMessage().getText(), SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE);
}
@Test
public void importDeviceProfileWithoutRefresh() {
sideBarMenuView.openDeviceProfiles();
profilesPage.openImportDeviceProfileView();
profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile);
profilesPage.importBrowseFileBtn().click();
name = IMPORT_DEVICE_PROFILE_NAME;
Assert.assertNotNull(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME)); Assert.assertNotNull(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME));
Assert.assertTrue(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME).isDisplayed()); Assert.assertTrue(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME).isDisplayed());
} }