diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestProperties.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestProperties.java index b5d91647c1..aac6748781 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestProperties.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestProperties.java @@ -43,7 +43,7 @@ public class TestProperties { if (instance.isActive()) { return "https://host.docker.internal"; } - return getProperties().getProperty("tb.baseUrl"); + return getProperties().getProperty("tb.baseUiUrl"); } public static String getWebSocketUrl() { diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestRestClient.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestRestClient.java index 46fed2c870..acf87f8b29 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestRestClient.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestRestClient.java @@ -29,6 +29,8 @@ 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.asset.AssetProfile; +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; @@ -278,6 +280,18 @@ public class TestRestClient { .as(JsonNode.class); } + public PageData getDeviceProfiles(PageLink pageLink) { + Map params = new HashMap<>(); + addPageLinkToParam(params, pageLink); + return given().spec(requestSpec).queryParams(params) + .get("/api/deviceProfiles") + .then() + .statusCode(HTTP_OK) + .extract() + .as(new TypeRef>() { + }); + } + public DeviceProfile getDeviceProfileById(DeviceProfileId deviceProfileId) { return given().spec(requestSpec).get("/api/deviceProfile/{deviceProfileId}", deviceProfileId.getId()) .then() @@ -296,6 +310,55 @@ public class TestRestClient { .as(DeviceProfile.class); } + public void deleteDeviseProfile(DeviceProfileId deviceProfileId) { + given().spec(requestSpec) + .delete("/api/deviceProfile/{deviceProfileId}", deviceProfileId.getId()) + .then() + .statusCode(HTTP_OK); + } + + public void setDefaultDeviceProfile(DeviceProfileId deviceProfileId) { + given().spec(requestSpec) + .post("/api/deviceProfile/{deviceProfileId}/default", deviceProfileId.getId()) + .then() + .statusCode(HTTP_OK); + } + + public AssetProfile postAssetProfile(AssetProfile assetProfile) { + return given().spec(requestSpec).body(assetProfile) + .post("/api/assetProfile") + .then() + .statusCode(HTTP_OK) + .extract() + .as(AssetProfile.class); + } + + public PageData getAssetProfiles(PageLink pageLink) { + Map params = new HashMap<>(); + addPageLinkToParam(params, pageLink); + return given().spec(requestSpec).queryParams(params) + .get("/api/assetProfiles") + .then() + .statusCode(HTTP_OK) + .extract() + .as(new TypeRef>() { + }); + } + + public void deleteAssetProfile(AssetProfileId assetProfileId) { + given().spec(requestSpec) + .delete("/api/assetProfile/{assetProfileId}", assetProfileId.getId()) + .then() + .statusCode(HTTP_OK); + } + + public void setDefaultAssetProfile(AssetProfileId assetProfileId) { + given().spec(requestSpec) + .post("/api/assetProfile/{assetProfileId}/default", assetProfileId.getId()) + .then() + .statusCode(HTTP_OK); + } + public Customer postCustomer(Customer customer) { return given().spec(requestSpec) .body(customer) diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractBasePage.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractBasePage.java index 9e32d6e917..0cccc9d37e 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractBasePage.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractBasePage.java @@ -18,6 +18,7 @@ package org.thingsboard.server.msa.ui.base; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.openqa.selenium.By; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.WebElement; @@ -29,17 +30,22 @@ import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; @Slf4j abstract public class AbstractBasePage { protected WebDriver driver; protected WebDriverWait wait; protected Actions actions; + protected JavascriptExecutor js; + public AbstractBasePage(WebDriver driver) { this.driver = driver; - this.wait = new WebDriverWait(driver, Duration.ofMillis(5000)); + this.wait = new WebDriverWait(driver, Duration.ofMillis(8000)); this.actions = new Actions(driver); + this.js = (JavascriptExecutor) driver; } @SneakyThrows @@ -56,6 +62,15 @@ abstract public class AbstractBasePage { } } + protected WebElement waitUntilPresenceOfElementLocated(String locator) { + try { + return wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(locator))); + } catch (WebDriverException e) { + log.error("No presence element: " + locator); + return null; + } + } + protected WebElement waitUntilElementToBeClickable(String locator) { try { return wait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator))); @@ -125,14 +140,47 @@ abstract public class AbstractBasePage { } } + public void jsClick(WebElement element) { + js.executeScript("arguments[0].click();", element); + } + + public void enterText(WebElement element, CharSequence keysToEnter) { + element.click(); + element.sendKeys(keysToEnter); + if (element.getAttribute("value").isEmpty()) { + element.sendKeys(keysToEnter); + } + } + + public void scrollToElement(WebElement element) { + js.executeScript("arguments[0].scrollIntoView(true);", element); + } + + public void waitUntilAttributeContains(WebElement element, String attribute, String value) { + wait.until(ExpectedConditions.attributeContains(element, attribute, value)); + } + public void goToNextTab(int tabNumber) { waitUntilNumberOfTabToBe(tabNumber); ArrayList tabs = new ArrayList<>(driver.getWindowHandles()); driver.switchTo().window(tabs.get(tabNumber - 1)); } - public static long getRandomNumber() { - return System.currentTimeMillis(); + public static String getRandomNumber() { + StringBuilder random = new StringBuilder(); + for (int i = 0; i < 5; i++) { + random.append(ThreadLocalRandom.current().nextInt(0, 100)); + } + return random.toString(); + } + + public static String randomUUID() { + UUID randomUUID = UUID.randomUUID(); + return randomUUID.toString().replaceAll("_", ""); + } + + public static String random() { + return getRandomNumber() + randomUUID().substring(0, 6); } public static char getRandomSymbol() { diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java index 121acb4e92..663d1bc640 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java @@ -22,10 +22,12 @@ import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.openqa.selenium.Dimension; +import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; 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.remote.LocalFileDetector; @@ -35,6 +37,8 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.thingsboard.server.common.data.Customer; +import org.thingsboard.server.common.data.DeviceProfile; +import org.thingsboard.server.common.data.asset.AssetProfile; import org.thingsboard.server.common.data.page.PageLink; import org.thingsboard.server.common.data.rule.RuleChain; import org.thingsboard.server.msa.AbstractContainerTest; @@ -46,6 +50,8 @@ import java.time.Duration; import java.util.stream.Collectors; import static org.thingsboard.server.msa.TestProperties.getBaseUiUrl; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; @Slf4j abstract public class AbstractDriverBaseTest extends AbstractContainerTest { @@ -57,11 +63,13 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { private static final String REMOTE_WEBDRIVER_HOST = "http://localhost:4444"; protected static final PageLink pageLink = new PageLink(10); private static final ContainerTestSuite instance = ContainerTestSuite.getInstance(); + private JavascriptExecutor js; @SneakyThrows @BeforeMethod public void openBrowser() { log.info("===>>> Setup driver"); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); ChromeOptions options = new ChromeOptions(); options.setAcceptInsecureCerts(true); if (instance.isActive()) { @@ -73,6 +81,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { driver = new ChromeDriver(options); } driver.manage().window().setSize(dimension); + openLocalhost(); } @AfterMethod @@ -103,14 +112,49 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { return driver.getCurrentUrl().contains(urlPath); } + public void jsClick(WebElement element) { + js = (JavascriptExecutor) driver; + js.executeScript("arguments[0].click();", element); + } + public static RuleChain getRuleChainByName(String name) { - return testRestClient.getRuleChains(pageLink).getData().stream() - .filter(s -> s.getName().equals(name)).collect(Collectors.toList()).get(0); + try { + return testRestClient.getRuleChains(pageLink).getData().stream() + .filter(s -> s.getName().equals(name)).collect(Collectors.toList()).get(0); + } catch (Exception e) { + log.error("No such rule chain with name: " + name); + return null; + } } public static Customer getCustomerByName(String name) { - return testRestClient.getCustomers(pageLink).getData().stream() - .filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0); + try { + return testRestClient.getCustomers(pageLink).getData().stream() + .filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0); + } catch (Exception e) { + log.error("No such customer with name: " + name); + return null; + } + } + + public static DeviceProfile getDeviceProfileByName(String name) { + try { + return testRestClient.getDeviceProfiles(pageLink).getData().stream() + .filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0); + } catch (Exception e) { + log.error("No such device profile with name: " + name); + return null; + } + } + + public static AssetProfile getAssetProfileByName(String name) { + try { + return testRestClient.getAssetProfiles(pageLink).getData().stream() + .filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0); + } catch (Exception e) { + log.error("No such asset profile with name: " + name); + return null; + } } @SneakyThrows diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageHelper.java index 9956966a16..73c912662c 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageHelper.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageHelper.java @@ -30,7 +30,7 @@ public class CustomerPageHelper extends CustomerPageElements { private String country; private String dashboard; private String dashboardFromView; - + private String description; private String customerEmail; private String customerCountry; private String customerCity; @@ -63,6 +63,11 @@ public class CustomerPageHelper extends CustomerPageElements { this.dashboardFromView = editMenuDashboardField().getAttribute("value"); } + public void setDescription() { + scrollToElement(descriptionEntityView()); + this.description = descriptionEntityView().getAttribute("value"); + } + public String getDashboard() { return dashboard; } @@ -71,6 +76,10 @@ public class CustomerPageHelper extends CustomerPageElements { return dashboardFromView; } + public String getDescription() { + return description; + } + public void setCustomerEmail(String title) { this.customerEmail = email(title).getText(); } @@ -96,6 +105,7 @@ public class CustomerPageHelper extends CustomerPageElements { } public void changeTitleEditMenu(String newTitle) { + titleFieldEntityView().click(); titleFieldEntityView().clear(); wait.until(ExpectedConditions.textToBe(By.xpath(String.format(INPUT_FIELD, INPUT_FIELD_NAME_TITLE)), "")); titleFieldEntityView().sendKeys(newTitle); @@ -142,4 +152,8 @@ public class CustomerPageHelper extends CustomerPageElements { public void sortByNameDown() { doubleClick(sortByTitleBtn()); } + + public void addCustomerViewEnterName(CharSequence keysToEnter) { + enterText(titleFieldAddEntityView(), keysToEnter); + } } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElements.java index b6ffd2a14e..f1714eec06 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElements.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElements.java @@ -15,6 +15,7 @@ */ package org.thingsboard.server.msa.ui.pages; +import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.thingsboard.server.msa.ui.base.AbstractBasePage; @@ -33,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_TITLE = "//tb-confirm-dialog/h2"; 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 CHECKBOXES = "//tbody//mat-checkbox"; private static final String DELETE_SELECTED_BTN = "//span[contains(text(),'selected')]//..//mat-icon/../.."; @@ -62,9 +63,14 @@ public class OtherPageElements extends AbstractBasePage { private static final String ERROR_MESSAGE = "//mat-error"; private static final String ENTITY_VIEW_TITLE = "//div[@class='tb-details-title']//span"; private static final String LIST_OF_ENTITY = "//div[@role='listbox']/mat-option"; + private static final String ENTITY_FROM_LIST = "//div[@role='listbox']/mat-option//span[contains(text(),'%s')]"; protected static final String ADD_ENTITY_VIEW = "//tb-add-entity-dialog"; protected static final String STATE_CONTROLLER = "//tb-entity-state-controller"; private static final String SEARCH_FIELD = "//input[contains (@data-placeholder,'Search')]"; + private static final String BROWSE_FILE = "//input[@class='file-input']"; + private static final String IMPORT_BROWSE_FILE = "//mat-dialog-container//span[contains(text(),'Import')]/.."; + private static final String IMPORTING_FILE = "//div[contains(text(),'%s')]"; + private static final String CLEAR_IMPORT_FILE_BTN = "//div[@class='tb-file-clear-container']//button"; public String getEntity(String entityName) { return String.format(ENTITY, entityName); @@ -110,6 +116,10 @@ public class OtherPageElements extends AbstractBasePage { return waitUntilElementToBeClickable(String.format(CHECKBOX, entityName)); } + public WebElement presentCheckBox(String name) { + return waitUntilPresenceOfElementLocated(getCheckbox(name)); + } + public WebElement deleteSelectedBtn() { return waitUntilElementToBeClickable(DELETE_SELECTED_BTN); } @@ -235,6 +245,10 @@ public class OtherPageElements extends AbstractBasePage { return waitUntilElementsToBeClickable(LIST_OF_ENTITY); } + public WebElement entityFromList(String entityName) { + return waitUntilVisibilityOfElementLocated(String.format(ENTITY_FROM_LIST, entityName)); + } + public WebElement addEntityView() { return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW); } @@ -246,4 +260,21 @@ public class OtherPageElements extends AbstractBasePage { public WebElement searchField() { return waitUntilElementToBeClickable(SEARCH_FIELD); } + + public WebElement browseFile() { + waitUntilElementToBeClickable(BROWSE_FILE + "/preceding-sibling::button"); + return driver.findElement(By.xpath(BROWSE_FILE)); + } + + public WebElement importBrowseFileBtn() { + return waitUntilElementToBeClickable(IMPORT_BROWSE_FILE); + } + + public WebElement importingFile(String fileName) { + return waitUntilVisibilityOfElementLocated(String.format(IMPORTING_FILE, fileName)); + } + + public WebElement clearImportFileBtn() { + return waitUntilElementToBeClickable(CLEAR_IMPORT_FILE_BTN); + } } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElementsHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElementsHelper.java index dbef06e7fe..33a3d34798 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElementsHelper.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElementsHelper.java @@ -49,13 +49,15 @@ public class OtherPageElementsHelper extends OtherPageElements { } } - public void changeNameEditMenu(String newName) { - nameFieldEditMenu().sendKeys(Keys.CONTROL + "a" + Keys.BACK_SPACE); - nameFieldEditMenu().sendKeys(newName); + public void changeNameEditMenu(CharSequence keysToSend) { + nameFieldEditMenu().click(); + nameFieldEditMenu().clear(); + nameFieldEditMenu().sendKeys(keysToSend); } public void changeDescription(String newDescription) { - descriptionEntityView().sendKeys(Keys.CONTROL + "a" + Keys.BACK_SPACE); + descriptionEntityView().click(); + descriptionEntityView().clear(); descriptionEntityView().sendKeys(newDescription); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/ProfilesPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/ProfilesPageElements.java new file mode 100644 index 0000000000..df7510d886 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/ProfilesPageElements.java @@ -0,0 +1,177 @@ +/** + * Copyright © 2016-2022 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; +import org.openqa.selenium.WebElement; + +import java.util.List; + +public class ProfilesPageElements extends OtherPageElementsHelper { + public ProfilesPageElements(WebDriver driver) { + super(driver); + } + + private static final String CREATE_DEVICE_PROFILE_BTN = "//span[text()='Create new device profile']"; + private static final String CREATE_ASSET_PROFILE_BTN = "//span[text()='Create new asset profile']"; + private static final String IMPORT_DEVICE_PROFILE_BTN = "//span[text()='Import device profile']"; + private static final String IMPORT_ASSET_PROFILE_BTN = "//span[text()='Import asset profile']"; + private static final String ADD_DEVICE_PROFILE_VIEW = "//tb-add-device-profile-dialog"; + private static final String ADD_ASSET_PROFILE_VIEW = "//tb-add-entity-dialog"; + private static final String DEVICE_PROFILE_VIEW = "//tb-entity-details-panel"; + private static final String NAME_FIELD = "//input[@formcontrolname='name']"; + private static final String RULE_CHAIN_FIELD = "//input[@formcontrolname='ruleChainId']"; + private static final String DASHBOARD_FIELD = "//input[@formcontrolname='dashboard']"; + private static final String QUEUE_FIELD = "//input[@formcontrolname='queueName']"; + private static final String DESCRIPTION_FIELD = "//textarea[@formcontrolname='description']"; + private static final String ADD_DEVICE_PROFILE_ADD_BTN = "//span[text()='Add']"; + private static final String ADD_ASSET_PROFILE_ADD_BTN = "//button[@type='submit']"; + private static final String DEVICE_PROFILE_VIEW_DELETE_BTN = "//tb-device-profile//span[contains(text(),'Delete')]"; + private static final String ASSET_PROFILE_VIEW_DELETE_BTN = "//tb-entity-details-panel//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 DEVICE_PROFILE_VIEW_MAKE_DEFAULT_BTN = "//span[text() = ' Make device profile default ']/.."; + private static final String ASSET_PROFILE_VIEW_MAKE_DEFAULT_BTN = "//span[text() = ' Make asset profile default ']/.."; + + protected String getDeviseProfileViewDeleteBtn() { + return DEVICE_PROFILE_VIEW_DELETE_BTN; + } + + protected String getAssetProfileViewDeleteBtn() { + return ASSET_PROFILE_VIEW_DELETE_BTN; + } + + public WebElement createNewDeviceProfileBtn() { + return waitUntilElementToBeClickable(CREATE_DEVICE_PROFILE_BTN); + } + + public WebElement createNewAssetProfileBtn() { + return waitUntilElementToBeClickable(CREATE_ASSET_PROFILE_BTN); + } + + public WebElement importDeviceProfileBtn() { + return waitUntilElementToBeClickable(IMPORT_DEVICE_PROFILE_BTN); + } + + public WebElement importAssetProfileBtn() { + return waitUntilElementToBeClickable(IMPORT_ASSET_PROFILE_BTN); + } + + public WebElement addDeviceProfileView() { + return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW); + } + + public WebElement addAssetProfileView() { + return waitUntilElementToBeClickable(ADD_ASSET_PROFILE_VIEW); + } + + public WebElement addDeviceProfileNameField() { + return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + NAME_FIELD); + } + + public WebElement addAssetProfileNameField() { + return waitUntilElementToBeClickable(ADD_ASSET_PROFILE_VIEW + NAME_FIELD); + } + + public WebElement profileViewNameField() { + return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + NAME_FIELD); + } + + public WebElement addDeviceProfileRuleChainField() { + return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + RULE_CHAIN_FIELD); + } + + public WebElement addAssetProfileRuleChainField() { + return waitUntilElementToBeClickable(ADD_ASSET_PROFILE_VIEW + RULE_CHAIN_FIELD); + } + + public WebElement profileViewRuleChainField() { + return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + RULE_CHAIN_FIELD); + } + + public WebElement addDeviceProfileMobileDashboardField() { + return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + DASHBOARD_FIELD); + } + + public WebElement addAssetProfileMobileDashboardField() { + return waitUntilElementToBeClickable(ADD_ASSET_PROFILE_VIEW + DASHBOARD_FIELD); + } + + public WebElement profileViewMobileDashboardField() { + return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + DASHBOARD_FIELD); + } + + public WebElement addDeviceProfileQueueField() { + return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + QUEUE_FIELD); + } + + public WebElement addAssetProfileQueueField() { + return waitUntilElementToBeClickable(ADD_ASSET_PROFILE_VIEW + QUEUE_FIELD); + } + + public WebElement profileViewQueueField() { + return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + QUEUE_FIELD); + } + + public WebElement addDeviceDescriptionField() { + return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_VIEW + DESCRIPTION_FIELD); + } + + public WebElement addAssetDescriptionField() { + return waitUntilElementToBeClickable(ADD_ASSET_PROFILE_VIEW + DESCRIPTION_FIELD); + } + + public WebElement profileViewDescriptionField() { + return waitUntilVisibilityOfElementLocated(DEVICE_PROFILE_VIEW + DESCRIPTION_FIELD); + } + + public WebElement addDeviceProfileAddBtn() { + return waitUntilElementToBeClickable(ADD_DEVICE_PROFILE_ADD_BTN); + } + + public WebElement addAssetProfileAddBtn() { + return waitUntilElementToBeClickable(ADD_ASSET_PROFILE_ADD_BTN); + } + + public WebElement deviceProfileViewDeleteBtn() { + return waitUntilElementToBeClickable(DEVICE_PROFILE_VIEW_DELETE_BTN); + } + + public WebElement assetProfileViewDeleteBtn() { + return waitUntilElementToBeClickable(ASSET_PROFILE_VIEW_DELETE_BTN); + } + + public List 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 deviceProfileViewMakeDefaultBtn() { + return waitUntilElementToBeClickable(DEVICE_PROFILE_VIEW_MAKE_DEFAULT_BTN); + } + + public WebElement assetProfileViewMakeDefaultBtn() { + return waitUntilElementToBeClickable(ASSET_PROFILE_VIEW_MAKE_DEFAULT_BTN); + } +} \ No newline at end of file diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/ProfilesPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/ProfilesPageHelper.java new file mode 100644 index 0000000000..afc25c75c9 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/ProfilesPageHelper.java @@ -0,0 +1,181 @@ +/** + * Copyright © 2016-2022 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.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; + +public class ProfilesPageHelper extends ProfilesPageElements { + public ProfilesPageHelper(WebDriver driver) { + super(driver); + } + + private String name; + private String ruleChain; + private String mobileDashboard; + private String queue; + private String description; + private String profile; + + public void setName() { + this.name = profileViewNameField().getAttribute("value"); + } + + public void setRuleChain() { + this.ruleChain = profileViewRuleChainField().getAttribute("value"); + } + + public void setMobileDashboard() { + this.mobileDashboard = profileViewMobileDashboardField().getAttribute("value"); + } + + public void setQueue() { + this.queue = profileViewQueueField().getAttribute("value"); + } + + public void setDescription() { + scrollToElement(profileViewDescriptionField()); + this.description = profileViewDescriptionField().getAttribute("value"); + } + + public void setProfileName() { + this.profile = profileNames().get(0).getText(); + } + + public void setProfileName(int number) { + this.profile = profileNames().get(number).getText(); + } + + public String getName() { + return this.name; + } + + public String getRuleChain() { + return this.ruleChain; + } + + public String getMobileDashboard() { + return this.mobileDashboard; + } + + public String getQueue() { + return this.queue; + } + + public String getDescription() { + return this.description; + } + + public String getProfileName() { + return this.profile; + } + + public void createDeviceProfileEnterName(CharSequence keysToEnter) { + enterText(addDeviceProfileNameField(), keysToEnter); + } + + public void addDeviceProfileViewChooseRuleChain(String ruleChain) { + addDeviceProfileRuleChainField().click(); + entityFromList(ruleChain).click(); + } + + public void addAssetProfileViewChooseRuleChain(String ruleChain) { + addAssetProfileRuleChainField().click(); + entityFromList(ruleChain).click(); + } + + public void addDeviceProfileViewChooseMobileDashboard(String mobileDashboard) { + addDeviceProfileMobileDashboardField().click(); + entityFromList(mobileDashboard).click(); + } + + public void addAssetProfileViewChooseMobileDashboard(String mobileDashboard) { + addAssetProfileMobileDashboardField().click(); + entityFromList(mobileDashboard).click(); + } + + public void addDeviceProfileViewChooseQueue(String queue) { + addDeviceProfileQueueField().click(); + entityFromList(queue).click(); + waitUntilAttributeContains(addDeviceProfileQueueField(), "aria-expanded", "false"); + } + + public void addAssetsProfileViewChooseQueue(String queue) { + addAssetProfileQueueField().click(); + entityFromList(queue).click(); + waitUntilAttributeContains(addAssetProfileQueueField(), "aria-expanded", "false"); + } + + public void addDeviceProfileViewEnterDescription(String description) { + addDeviceDescriptionField().sendKeys(description); + } + + public void addAssetProfileViewEnterDescription(String description) { + addAssetDescriptionField().sendKeys(description); + } + + public void openCreateDeviceProfileView() { + plusBtn().click(); + createNewDeviceProfileBtn().click(); + } + + public void openCreateAssetProfileView() { + plusBtn().click(); + createNewAssetProfileBtn().click(); + } + + public void addAssetProfileViewEnterName(String name) { + addAssetProfileNameField().click(); + addAssetProfileNameField().sendKeys(name); + } + + public void openImportDeviceProfileView() { + plusBtn().click(); + importDeviceProfileBtn().click(); + } + + public void openImportAssetProfileView() { + plusBtn().click(); + importAssetProfileBtn().click(); + } + + public boolean deleteDeviceProfileFromViewBtnIsNotDisplayed() { + return wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(getDeviseProfileViewDeleteBtn()))); + } + + public boolean deleteAssetProfileFromViewBtnIsNotDisplayed() { + return wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(getAssetProfileViewDeleteBtn()))); + } + + public void goToProfileHelpPage() { + jsClick(helpBtn()); + goToNextTab(2); + } + + public void sortByNameDown() { + doubleClick(sortByNameBtn()); + } + + public boolean profileIsNotPresent(String name) { + return elementsIsNotPresent(getEntity(name)); + } + + public boolean checkBoxIsDisplayed(String name) { + return waitUntilPresenceOfElementLocated(getCheckbox(name)).isDisplayed(); + } +} + diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageElements.java index eee95edcae..fff8a98c8e 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageElements.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageElements.java @@ -15,7 +15,6 @@ */ package org.thingsboard.server.msa.ui.pages; -import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; @@ -35,11 +34,6 @@ public class RuleChainsPageElements extends OtherPageElementsHelper { private static final String RULE_CHAINS_NAMES_WITHOUT_ROOT = "//mat-icon[contains(text(),'check_box_outline_blank')]/../../../mat-cell[contains(@class,'name')]/span"; private static final String DELETE_RULE_CHAIN_FROM_VIEW_BTN = "//span[contains(text(),' Delete')]"; private static final String IMPORT_RULE_CHAIN_BTN = "//span[contains(text(),'Import rule chain')]"; - private static final String BROWSE_FILE = "//input[@class='file-input']"; - private static final String IMPORT_BROWSE_FILE = "//mat-dialog-container//span[contains(text(),'Import')]/.."; - private static final String IMPORTING_FILE = "//div[contains(text(),'%s')]"; - private static final String CLEAR_IMPORT_FILE_BTN = "//div[@class='tb-file-clear-container']//button"; - private static final String OPEN_RULE_CHAIN = ENTITY + "/../..//mat-icon[contains(text(),' settings_ethernet')]"; private static final String OPEN_RULE_CHAIN_FROM_VIEW = "//span[contains(text(),'Open rule chain')]"; private static final String MAKE_ROOT_FROM_VIEW = "(//span[contains(text(),' Make rule chain root ')]/..)[1]"; private static final String ROOT_ACTIVE_CHECKBOXES = "//mat-icon[text() = 'check_box']"; @@ -85,31 +79,10 @@ public class RuleChainsPageElements extends OtherPageElementsHelper { return waitUntilElementToBeClickable(DELETE_RULE_CHAIN_FROM_VIEW_BTN); } - public WebElement browseFile() { - waitUntilElementToBeClickable(BROWSE_FILE + "/preceding-sibling::button"); - return driver.findElement(By.xpath(BROWSE_FILE)); - } - - public WebElement importBrowseFileBtn() { - return waitUntilElementToBeClickable(IMPORT_BROWSE_FILE); - } - - public WebElement importingFile(String fileName) { - return waitUntilVisibilityOfElementLocated(String.format(IMPORTING_FILE, fileName)); - } - - public WebElement clearImportFileBtn() { - return waitUntilElementToBeClickable(CLEAR_IMPORT_FILE_BTN); - } - public WebElement openRuleChainFromViewBtn() { return waitUntilElementToBeClickable(OPEN_RULE_CHAIN_FROM_VIEW); } - public WebElement openRuleChainBtn(String name) { - return waitUntilElementToBeClickable(String.format(OPEN_RULE_CHAIN, name)); - } - public List entities(String name) { return waitUntilVisibilityOfElementsLocated(String.format(ENTITY, name)); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageHelper.java index a6a7148bc4..d887b3571e 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageHelper.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageHelper.java @@ -47,6 +47,7 @@ public class RuleChainsPageHelper extends RuleChainsPageElements { } private String ruleChainName; + private String description; public void setRuleChainNameWithoutRoot() { this.ruleChainName = notRootRuleChainsNames().get(getRandomNumberFromRuleChainsCount()).getText(); @@ -56,6 +57,11 @@ public class RuleChainsPageHelper extends RuleChainsPageElements { this.ruleChainName = notRootRuleChainsNames().get(number).getText(); } + public void setDescription() { + scrollToElement(descriptionEntityView()); + this.description = descriptionEntityView().getAttribute("value"); + } + public void setRuleChainName(int number) { this.ruleChainName = allNames().get(number).getText(); } @@ -64,6 +70,10 @@ public class RuleChainsPageHelper extends RuleChainsPageElements { return this.ruleChainName; } + public String getDescription() { + return description; + } + public String deleteRuleChainFromView(String ruleChainName) { String s = ""; if (deleteBtnFromView() != null) { @@ -101,10 +111,6 @@ public class RuleChainsPageHelper extends RuleChainsPageElements { return elementsIsNotPresent(getEntity(ruleChainName)); } - public void doubleClickOnRuleChain(String ruleChainName) { - doubleClick(entity(ruleChainName)); - } - public void sortByNameDown() { doubleClick(sortByNameBtn()); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewElements.java index 902966a1ac..f84cdaac65 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewElements.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewElements.java @@ -27,6 +27,9 @@ public class SideBarMenuViewElements extends AbstractBasePage { private static final String RULE_CHAINS_BTN = "//mat-toolbar//a[@href='/ruleChains']"; private static final String CUSTOMER_BTN = "//mat-toolbar//a[@href='/customers']"; private static final String DASHBOARD_BTN = "//mat-toolbar//a[@href='/dashboards']"; + private static final String PROFILES_BTN = "//mat-toolbar//a[@href='/profiles']"; + private static final String DEVICE_PROFILE_BTN = "//mat-toolbar//a[@href='/profiles/deviceProfiles']"; + private static final String ASSET_PROFILE_BTN = "//mat-toolbar//a[@href='/profiles/assetProfiles']"; public WebElement ruleChainsBtn() { return waitUntilElementToBeClickable(RULE_CHAINS_BTN); @@ -39,4 +42,16 @@ public class SideBarMenuViewElements extends AbstractBasePage { public WebElement dashboardBtn() { return waitUntilElementToBeClickable(DASHBOARD_BTN); } + + public WebElement profilesBtn() { + return waitUntilElementToBeClickable(PROFILES_BTN); + } + + public WebElement deviceProfileBtn() { + return waitUntilElementToBeClickable(DEVICE_PROFILE_BTN); + } + + public WebElement assetProfileBtn() { + return waitUntilElementToBeClickable(ASSET_PROFILE_BTN); + } } \ No newline at end of file diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewHelper.java new file mode 100644 index 0000000000..bf5e925a17 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewHelper.java @@ -0,0 +1,34 @@ +/** + * Copyright © 2016-2022 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; + +public class SideBarMenuViewHelper extends SideBarMenuViewElements { + public SideBarMenuViewHelper(WebDriver driver) { + super(driver); + } + + public void openDeviceProfiles() { + profilesBtn().click(); + deviceProfileBtn().click(); + } + + public void openAssetProfiles() { + profilesBtn().click(); + assetProfileBtn().click(); + } +} \ No newline at end of file diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/AssetProfileEditMenuTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/AssetProfileEditMenuTest.java new file mode 100644 index 0000000000..2527e1a28c --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/AssetProfileEditMenuTest.java @@ -0,0 +1,129 @@ +/** + * Copyright © 2016-2022 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.assetProfileSmoke; + +import io.qameta.allure.Description; +import org.openqa.selenium.Keys; +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 org.thingsboard.server.msa.ui.utils.DataProviderCredential; +import org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_ASSET_PROFILE_MESSAGE; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; + +public class AssetProfileEditMenuTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteAssetProfile(getAssetProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description + public void changeName() { + String name = ENTITY_NAME + random(); + String newName = "Changed" + getRandomNumber(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.entity(name).click(); + profilesPage.setHeaderName(); + String nameBefore = profilesPage.getHeaderName(); + jsClick(profilesPage.editPencilBtn()); + profilesPage.changeNameEditMenu(newName); + profilesPage.doneBtnEditView().click(); + this.name = newName; + profilesPage.setHeaderName(); + String nameAfter = profilesPage.getHeaderName(); + + Assert.assertNotEquals(nameBefore, nameAfter); + Assert.assertEquals(nameAfter, newName); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void deleteName() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.entity(name).click(); + jsClick(profilesPage.editPencilBtn()); + profilesPage.changeNameEditMenu(""); + + Assert.assertFalse(profilesPage.doneBtnEditViewVisible().isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void saveWithOnlySpaceInName() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.entity(name).click(); + jsClick(profilesPage.editPencilBtn()); + profilesPage.changeNameEditMenu(Keys.SPACE); + profilesPage.doneBtnEditView().click(); + + Assert.assertNotNull(profilesPage.warningMessage()); + Assert.assertTrue(profilesPage.warningMessage().isDisplayed()); + Assert.assertEquals(profilesPage.warningMessage().getText(), EMPTY_ASSET_PROFILE_MESSAGE); + } + + @Test(priority = 30, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "editMenuDescription") + @Description + public void editDescription(String description, String newDescription, String finalDescription) { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name, description)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.entity(name).click(); + jsClick(profilesPage.editPencilBtn()); + profilesPage.profileViewDescriptionField().sendKeys(newDescription); + profilesPage.doneBtnEditView().click(); + profilesPage.setDescription(); + + Assert.assertEquals(profilesPage.getDescription(), finalDescription); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/CreateAssetProfileImportTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/CreateAssetProfileImportTest.java new file mode 100644 index 0000000000..ac4cf8683a --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/CreateAssetProfileImportTest.java @@ -0,0 +1,126 @@ +/** + * Copyright © 2016-2022 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.assetProfileSmoke; + +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 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.IMPORT_ASSET_PROFILE_FILE_NAME; +import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_ASSET_PROFILE_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_ASSET_PROFILE_MESSAGE; + +public class CreateAssetProfileImportTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private final String absolutePathToFileImportAssetProfile = getClass().getClassLoader().getResource(IMPORT_ASSET_PROFILE_FILE_NAME).getPath(); + private final String absolutePathToFileImportTxt = getClass().getClassLoader().getResource(IMPORT_TXT_FILE_NAME).getPath(); + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteAssetProfile(getAssetProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 20, groups = "smoke") + @Description + public void importAssetProfile() { + sideBarMenuView.openAssetProfiles(); + profilesPage.openImportAssetProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportAssetProfile); + profilesPage.importBrowseFileBtn().click(); + name = IMPORT_ASSET_PROFILE_NAME; + profilesPage.refreshBtn().click(); + + Assert.assertNotNull(profilesPage.entity(IMPORT_ASSET_PROFILE_NAME)); + Assert.assertTrue(profilesPage.entity(IMPORT_ASSET_PROFILE_NAME).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void importTxtFile() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.openImportDeviceProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportTxt); + + Assert.assertNotNull(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE)); + Assert.assertTrue(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void addFileToImportAndRemove() { + sideBarMenuView.openAssetProfiles(); + profilesPage.openImportAssetProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportAssetProfile); + profilesPage.clearImportFileBtn().click(); + + Assert.assertNotNull(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE)); + Assert.assertTrue(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed()); + Assert.assertTrue(profilesPage.entityIsNotPresent(IMPORT_ASSET_PROFILE_NAME)); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void importAssetProfileWithSameName() { + String name = IMPORT_ASSET_PROFILE_NAME; + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.openImportAssetProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportAssetProfile); + profilesPage.importBrowseFileBtn().click(); + profilesPage.refreshBtn().click(); + + Assert.assertNotNull(profilesPage.warningMessage()); + Assert.assertTrue(profilesPage.warningMessage().isDisplayed()); + Assert.assertEquals(profilesPage.warningMessage().getText(), SAME_NAME_WARNING_ASSET_PROFILE_MESSAGE); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void importAssetProfileWithoutRefresh() { + sideBarMenuView.openAssetProfiles(); + profilesPage.openImportAssetProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportAssetProfile); + profilesPage.importBrowseFileBtn().click(); + name = IMPORT_ASSET_PROFILE_NAME; + + Assert.assertNotNull(profilesPage.entity(IMPORT_ASSET_PROFILE_NAME)); + Assert.assertTrue(profilesPage.entity(IMPORT_ASSET_PROFILE_NAME).isDisplayed()); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/CreateAssetProfileTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/CreateAssetProfileTest.java new file mode 100644 index 0000000000..2fbce0ecf2 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/CreateAssetProfileTest.java @@ -0,0 +1,175 @@ +/** + * Copyright © 2016-2022 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.assetProfileSmoke; + +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 org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_ASSET_PROFILE_MESSAGE; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; +import static org.thingsboard.server.msa.ui.utils.Const.SAME_NAME_WARNING_ASSET_PROFILE_MESSAGE; + +public class CreateAssetProfileTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteAssetProfile(getAssetProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description + public void createAssetProfile() { + String name = ENTITY_NAME + random(); + + sideBarMenuView.openAssetProfiles(); + profilesPage.openCreateAssetProfileView(); + profilesPage.addAssetProfileViewEnterName(name); + profilesPage.addAssetProfileAddBtn().click(); + this.name = name; + profilesPage.refreshBtn().click(); + + Assert.assertNotNull(profilesPage.entity(name)); + Assert.assertTrue(profilesPage.entity(name).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createAssetProfileWithDetails() { + String name = ENTITY_NAME + random(); + String ruleChain = "Root Rule Chain"; + String mobileDashboard = "Firmware"; + String queue = "Main"; + String description = "Description"; + + sideBarMenuView.openAssetProfiles(); + profilesPage.openCreateAssetProfileView(); + profilesPage.addAssetProfileViewEnterName(name); + profilesPage.addAssetProfileViewChooseRuleChain(ruleChain); + profilesPage.addAssetProfileViewChooseMobileDashboard(mobileDashboard); + profilesPage.addAssetsProfileViewChooseQueue(queue); + profilesPage.addAssetProfileViewEnterDescription(description); + profilesPage.addAssetProfileAddBtn().click(); + this.name = name; + profilesPage.refreshBtn().click(); + profilesPage.entity(name).click(); + profilesPage.setName(); + profilesPage.setRuleChain(); + profilesPage.setMobileDashboard(); + profilesPage.setQueue(); + profilesPage.setDescription(); + + Assert.assertNotNull(profilesPage.entity(name)); + Assert.assertTrue(profilesPage.entity(name).isDisplayed()); + Assert.assertEquals(name, profilesPage.getName()); + Assert.assertEquals(ruleChain, profilesPage.getRuleChain()); + Assert.assertEquals(mobileDashboard, profilesPage.getMobileDashboard()); + Assert.assertEquals(queue, profilesPage.getQueue()); + Assert.assertEquals(description, profilesPage.getDescription()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createAssetProfileWithSameName() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.openCreateAssetProfileView(); + profilesPage.addAssetProfileViewEnterName(name); + profilesPage.addAssetProfileAddBtn().click(); + + Assert.assertNotNull(profilesPage.warningMessage()); + Assert.assertTrue(profilesPage.warningMessage().isDisplayed()); + Assert.assertEquals(profilesPage.warningMessage().getText(), SAME_NAME_WARNING_ASSET_PROFILE_MESSAGE); + Assert.assertNotNull(profilesPage.addAssetProfileView()); + Assert.assertTrue(profilesPage.addAssetProfileView().isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createAssetProfileWithoutName() { + sideBarMenuView.openAssetProfiles(); + profilesPage.openCreateAssetProfileView(); + + Assert.assertFalse(profilesPage.addBtnV().isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createAssetProfileWithOnlySpaceInName() { + sideBarMenuView.openAssetProfiles(); + profilesPage.openCreateAssetProfileView(); + profilesPage.addAssetProfileViewEnterName(" "); + profilesPage.addAssetProfileAddBtn().click(); + + Assert.assertNotNull(profilesPage.warningMessage()); + Assert.assertTrue(profilesPage.warningMessage().isDisplayed()); + Assert.assertEquals(profilesPage.warningMessage().getText(), EMPTY_ASSET_PROFILE_MESSAGE); + Assert.assertNotNull(profilesPage.addAssetProfileView()); + Assert.assertTrue(profilesPage.addAssetProfileView().isDisplayed()); + } + + @Test(priority = 30, groups = "smoke") + @Description + public void createAssetProfileWithoutRefresh() { + String name = ENTITY_NAME + random(); + + sideBarMenuView.openAssetProfiles(); + profilesPage.openCreateAssetProfileView(); + profilesPage.addAssetProfileViewEnterName(name); + profilesPage.addAssetProfileAddBtn().click(); + this.name = name; + + Assert.assertNotNull(profilesPage.entity(name)); + Assert.assertTrue(profilesPage.entity(name).isDisplayed()); + } + + @Test(priority = 40, groups = "smoke") + @Description + public void documentation() { + String urlPath = "docs/user-guide/asset-profiles/"; + + sideBarMenuView.openAssetProfiles(); + profilesPage.allEntity().get(0).click(); + profilesPage.goToProfileHelpPage(); + + Assert.assertTrue(urlContains(urlPath)); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/DeleteAssetProfileTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/DeleteAssetProfileTest.java new file mode 100644 index 0000000000..d998f9d235 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/DeleteAssetProfileTest.java @@ -0,0 +1,125 @@ +/** + * Copyright © 2016-2022 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.assetProfileSmoke; + +import io.qameta.allure.Description; +import org.testng.Assert; +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 org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; + +public class DeleteAssetProfileTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void removeAssetProfile() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + + sideBarMenuView.openAssetProfiles(); + profilesPage.deleteBtn(name).click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn(); + + Assert.assertTrue(profilesPage.entityIsNotPresent(name)); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void removeAssetProfileFromView() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + + sideBarMenuView.openAssetProfiles(); + profilesPage.entity(name).click(); + profilesPage.assetProfileViewDeleteBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn(); + + Assert.assertTrue(profilesPage.entityIsNotPresent(name)); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void removeSelectedAssetProfile() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + + sideBarMenuView.openAssetProfiles(); + profilesPage.checkBox(name).click(); + profilesPage.deleteSelectedBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn(); + + Assert.assertTrue(profilesPage.entityIsNotPresent(name)); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeDefaultAssetProfile() { + sideBarMenuView.openAssetProfiles(); + + Assert.assertFalse(profilesPage.deleteBtn("default").isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeDefaultAssetProfileFromView() { + sideBarMenuView.openAssetProfiles(); + profilesPage.entity("default").click(); + + Assert.assertTrue(profilesPage.deleteAssetProfileFromViewBtnIsNotDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeSelectedDefaultAssetProfile() { + sideBarMenuView.openAssetProfiles(); + + Assert.assertNotNull(profilesPage.presentCheckBox("default")); + Assert.assertFalse(profilesPage.presentCheckBox("default").isDisplayed()); + } + + @Test(priority = 30, groups = "smoke") + @Description + public void removeAssetProfileWithoutRefresh() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + + sideBarMenuView.openAssetProfiles(); + profilesPage.deleteBtn(name).click(); + profilesPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(profilesPage.entityIsNotPresent(name)); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/DeleteSeveralAssetProfilesTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/DeleteSeveralAssetProfilesTest.java new file mode 100644 index 0000000000..8b937c5106 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/DeleteSeveralAssetProfilesTest.java @@ -0,0 +1,104 @@ +/** + * Copyright © 2016-2022 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.assetProfileSmoke; + +import io.qameta.allure.Description; +import org.testng.Assert; +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 org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; + +public class DeleteSeveralAssetProfilesTest extends AbstractDriverBaseTest { + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void canDeleteSeveralAssetProfilesByTopBtn() { + String name1 = ENTITY_NAME + random() + "1"; + String name2 = ENTITY_NAME + random() + "2"; + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name1)); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name2)); + + sideBarMenuView.openAssetProfiles(); + profilesPage.clickOnCheckBoxes(2); + profilesPage.deleteSelectedBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn().click(); + + Assert.assertTrue(profilesPage.profileIsNotPresent(name1)); + Assert.assertTrue(profilesPage.profileIsNotPresent(name2)); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void selectAllDAssetProfiles() { + String name1 = ENTITY_NAME + random() + "1"; + String name2 = ENTITY_NAME + random() +"2"; + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name1)); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name2)); + + sideBarMenuView.openAssetProfiles(); + profilesPage.selectAllCheckBox().click(); + profilesPage.deleteSelectedBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn().click(); + + Assert.assertTrue(profilesPage.profileIsNotPresent(name1)); + Assert.assertTrue(profilesPage.profileIsNotPresent(name2)); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeDefaultAssetProfile() { + sideBarMenuView.openAssetProfiles(); + profilesPage.selectAllCheckBox().click(); + + Assert.assertFalse(profilesPage.checkBoxIsDisplayed("default")); + Assert.assertFalse(profilesPage.deleteBtn("default").isEnabled()); + } + + @Test(priority = 30, groups = "smoke") + @Description + public void deleteSeveralAssetProfilesByTopBtnWithoutRefresh() { + String name1 = ENTITY_NAME + random() + "1"; + String name2 = ENTITY_NAME + random() + "2"; + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name1)); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name2)); + + sideBarMenuView.openAssetProfiles(); + profilesPage.clickOnCheckBoxes(2); + profilesPage.deleteSelectedBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(profilesPage.profileIsNotPresent(name1)); + Assert.assertTrue(profilesPage.profileIsNotPresent(name2)); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/MakeAssetProfileDefaultTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/MakeAssetProfileDefaultTest.java new file mode 100644 index 0000000000..b3b82cfbf2 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/MakeAssetProfileDefaultTest.java @@ -0,0 +1,79 @@ +/** + * Copyright © 2016-2022 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.assetProfileSmoke; + +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 org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; + +public class MakeAssetProfileDefaultTest extends AbstractDriverBaseTest { + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void makeProfileDefault() { + testRestClient.setDefaultAssetProfile(getAssetProfileByName("default").getId()); + testRestClient.deleteAssetProfile(getAssetProfileByName(name).getId()); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void makeDeviceProfileDefaultByRightCornerBtn() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.makeProfileDefaultBtn(name).click(); + profilesPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(profilesPage.defaultCheckbox(name).isDisplayed()); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void makeDeviceProfileDefaultFromView() { + String name = ENTITY_NAME + random(); + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.entity(name).click(); + profilesPage.assetProfileViewMakeDefaultBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.closeEntityViewBtn().click(); + + Assert.assertTrue(profilesPage.defaultCheckbox(name).isDisplayed()); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/SearchAssetProfileTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/SearchAssetProfileTest.java new file mode 100644 index 0000000000..03d89572a4 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/SearchAssetProfileTest.java @@ -0,0 +1,62 @@ +/** + * Copyright © 2016-2022 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.assetProfileSmoke; + +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 org.thingsboard.server.msa.ui.utils.DataProviderCredential; +import org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +public class SearchAssetProfileTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteAssetProfile(getAssetProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "assetProfileSearch") + @Description + public void searchFirstWord(String name, String namePath) { + testRestClient.postAssetProfile(EntityPrototypes.defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.searchEntity(namePath); + + profilesPage.allEntity().forEach(x -> Assert.assertTrue(x.getText().contains(namePath))); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/SortByNameTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/SortByNameTest.java new file mode 100644 index 0000000000..a9e7473cba --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/assetProfileSmoke/SortByNameTest.java @@ -0,0 +1,127 @@ +/** + * Copyright © 2016-2022 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.assetProfileSmoke; + +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 org.thingsboard.server.msa.ui.utils.DataProviderCredential; + +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultAssetProfile; + +public class SortByNameTest extends AbstractDriverBaseTest { + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteAssetProfile(getAssetProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") + @Description + public void specialCharacterUp(String name) { + testRestClient.postAssetProfile(defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.sortByNameBtn().click(); + profilesPage.setProfileName(); + + Assert.assertEquals(profilesPage.getProfileName(), name); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") + @Description + public void allSortUp(String assetProfile, String assetProfileSymbol, String assetProfileNumber) { + testRestClient.postAssetProfile(defaultAssetProfile(assetProfileSymbol)); + testRestClient.postAssetProfile(defaultAssetProfile(assetProfile)); + testRestClient.postAssetProfile(defaultAssetProfile(assetProfileNumber)); + + sideBarMenuView.openAssetProfiles(); + profilesPage.sortByNameBtn().click(); + profilesPage.setProfileName(0); + String firstAssetProfile = profilesPage.getProfileName(); + profilesPage.setProfileName(1); + String secondAssetProfile = profilesPage.getProfileName(); + profilesPage.setProfileName(2); + String thirdAssetProfile = profilesPage.getProfileName(); + + testRestClient.deleteAssetProfile(getAssetProfileByName(assetProfile).getId()); + testRestClient.deleteAssetProfile(getAssetProfileByName(assetProfileNumber).getId()); + testRestClient.deleteAssetProfile(getAssetProfileByName(assetProfileSymbol).getId()); + + Assert.assertEquals(firstAssetProfile, assetProfileSymbol); + Assert.assertEquals(secondAssetProfile, assetProfileNumber); + Assert.assertEquals(thirdAssetProfile, assetProfile); + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") + @Description + public void specialCharacterDown(String name) { + testRestClient.postAssetProfile(defaultAssetProfile(name)); + this.name = name; + + sideBarMenuView.openAssetProfiles(); + profilesPage.sortByNameDown(); + profilesPage.setProfileName(profilesPage.allEntity().size() - 1); + + Assert.assertEquals(profilesPage.getProfileName(), name); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") + @Description + public void allSortDown(String assetProfile, String assetProfileSymbol, String assetProfileNumber) { + testRestClient.postAssetProfile(defaultAssetProfile(assetProfileSymbol)); + testRestClient.postAssetProfile(defaultAssetProfile(assetProfile)); + testRestClient.postAssetProfile(defaultAssetProfile(assetProfileNumber)); + + sideBarMenuView.openAssetProfiles(); + int lastIndex = profilesPage.allEntity().size() - 1; + profilesPage.sortByNameDown(); + profilesPage.setProfileName(lastIndex); + String firstAssetProfile = profilesPage.getProfileName(); + profilesPage.setProfileName(lastIndex - 1); + String secondAssetProfile = profilesPage.getProfileName(); + profilesPage.setProfileName(lastIndex - 2); + String thirdAssetProfile = profilesPage.getProfileName(); + + testRestClient.deleteAssetProfile(getAssetProfileByName(assetProfile).getId()); + testRestClient.deleteAssetProfile(getAssetProfileByName(assetProfileNumber).getId()); + testRestClient.deleteAssetProfile(getAssetProfileByName(assetProfileSymbol).getId()); + + Assert.assertEquals(firstAssetProfile, assetProfileSymbol); + Assert.assertEquals(secondAssetProfile, assetProfileNumber); + Assert.assertEquals(thirdAssetProfile, assetProfile); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CreateCustomerTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CreateCustomerTest.java index 50aac8de11..f2a2933a8e 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CreateCustomerTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CreateCustomerTest.java @@ -16,6 +16,7 @@ package org.thingsboard.server.msa.ui.tests.customerSmoke; import io.qameta.allure.Description; +import org.openqa.selenium.Keys; import org.testng.Assert; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; @@ -25,11 +26,10 @@ import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_CUSTOMER_MESSAGE; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; import static org.thingsboard.server.msa.ui.utils.Const.SAME_NAME_WARNING_CUSTOMER_MESSAGE; -import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; -import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; public class CreateCustomerTest extends AbstractDriverBaseTest { @@ -39,9 +39,7 @@ public class CreateCustomerTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); } @@ -57,11 +55,11 @@ public class CreateCustomerTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void createCustomer() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); - customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.addCustomerViewEnterName(customerName); customerPage.addBtnC().click(); this.customerName = customerName; customerPage.refreshBtn().click(); @@ -73,14 +71,14 @@ public class CreateCustomerTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void createCustomerWithFullInformation() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); String text = "Text"; String email = "email@mail.com"; String number = "12015550123"; sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); - customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.addCustomerViewEnterName(customerName); customerPage.selectCountryAddEntityView(); customerPage.descriptionAddEntityView().sendKeys(text); customerPage.cityAddEntityView().sendKeys(text); @@ -128,7 +126,7 @@ public class CreateCustomerTest extends AbstractDriverBaseTest { public void createCustomerWithOnlySpace() { sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); - customerPage.titleFieldAddEntityView().sendKeys(" "); + customerPage.addCustomerViewEnterName(Keys.SPACE); customerPage.addBtnC().click(); Assert.assertNotNull(customerPage.warningMessage()); @@ -145,7 +143,7 @@ public class CreateCustomerTest extends AbstractDriverBaseTest { customerPage.setCustomerName(); String customerName = customerPage.getCustomerName(); customerPage.plusBtn().click(); - customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.addCustomerViewEnterName(customerName); customerPage.addBtnC().click(); Assert.assertNotNull(customerPage.warningMessage()); @@ -158,11 +156,11 @@ public class CreateCustomerTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void createCustomerWithoutRefresh() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); - customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.addCustomerViewEnterName(customerName); customerPage.addBtnC().click(); this.customerName = customerName; diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CustomerEditMenuTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CustomerEditMenuTest.java index 66a5bd5004..d2c82fb9ab 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CustomerEditMenuTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CustomerEditMenuTest.java @@ -26,13 +26,13 @@ import org.thingsboard.server.msa.ui.pages.DashboardPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import org.thingsboard.server.msa.ui.utils.DataProviderCredential; +import org.thingsboard.server.msa.ui.utils.EntityPrototypes; import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_CUSTOMER_MESSAGE; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; import static org.thingsboard.server.msa.ui.utils.Const.PHONE_NUMBER_ERROR_MESSAGE; -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.EntityPrototypes.defaultCustomerPrototype; public class CustomerEditMenuTest extends AbstractDriverBaseTest { @@ -42,12 +42,9 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { private DashboardPageHelper dashboardPage; private String customerName; - @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); dashboardPage = new DashboardPageHelper(driver); @@ -65,7 +62,7 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { @Description public void changeTitle() { String customerName = "Changed" + getRandomNumber(); - testRestClient.postCustomer(defaultCustomerPrototype(ENTITY_NAME)); + testRestClient.postCustomer(defaultCustomerPrototype(ENTITY_NAME + random())); this.customerName = customerName; sideBarMenuView.customerBtn().click(); @@ -110,37 +107,27 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { Assert.assertEquals(customerPage.getCustomerName(), customerPage.getHeaderName()); } - @Test(priority = 20, groups = "smoke") + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "editMenuDescription") @Description - public void editDescription() { - String customerName = ENTITY_NAME; - testRestClient.postCustomer(defaultCustomerPrototype(customerName)); - this.customerName = customerName; - String description = "Description"; + public void editDescription(String description, String newDescription, String finalDescription) { + String name = ENTITY_NAME + random(); + testRestClient.postCustomer(EntityPrototypes.defaultCustomerPrototype(name, description)); + customerName = name; sideBarMenuView.customerBtn().click(); - customerPage.entityTitles().get(0).click(); - customerPage.editPencilBtn().click(); - customerPage.descriptionEntityView().sendKeys(description); - customerPage.doneBtnEditView().click(); - String description1 = customerPage.descriptionEntityView().getAttribute("value"); - customerPage.editPencilBtn().click(); - customerPage.descriptionEntityView().sendKeys(description); - customerPage.doneBtnEditView().click(); - String description2 = customerPage.descriptionEntityView().getAttribute("value"); + customerPage.entity(name).click(); customerPage.editPencilBtn().click(); - customerPage.changeDescription(""); + customerPage.descriptionEntityView().sendKeys(newDescription); customerPage.doneBtnEditView().click(); + customerPage.setDescription(); - Assert.assertEquals(description, description1); - Assert.assertEquals(description + description, description2); - Assert.assertTrue(customerPage.descriptionEntityView().getAttribute("value").isEmpty()); + Assert.assertEquals(customerPage.getDescription(), finalDescription); } @Test(priority = 20, groups = "smoke") @Description public void assignedDashboardFromDashboard() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customerName)); this.customerName = customerName; @@ -167,7 +154,7 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void assignedDashboard() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customerName)); this.customerName = customerName; @@ -193,7 +180,7 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void assignedDashboardWithoutHide() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customerName)); this.customerName = customerName; @@ -226,7 +213,7 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void addPhoneNumber() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customerName)); this.customerName = customerName; String number = "2015550123"; @@ -259,7 +246,7 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 30, groups = "smoke") @Description public void addAllInformation() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customerName)); this.customerName = customerName; String text = "Text"; diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteCustomerTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteCustomerTest.java index 43c6fc8c27..a80b643f00 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteCustomerTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteCustomerTest.java @@ -25,9 +25,8 @@ import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; -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.EntityPrototypes.defaultCustomerPrototype; public class DeleteCustomerTest extends AbstractDriverBaseTest { @@ -38,9 +37,7 @@ public class DeleteCustomerTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); ruleChainsPage = new RuleChainsPageHelper(driver); @@ -49,7 +46,7 @@ public class DeleteCustomerTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void removeCustomerByRightSideBtn() { - String customer = ENTITY_NAME; + String customer = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customer)); sideBarMenuView.customerBtn().click(); @@ -62,7 +59,7 @@ public class DeleteCustomerTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void removeSelectedCustomer() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customerName)); sideBarMenuView.customerBtn().click(); @@ -75,7 +72,7 @@ public class DeleteCustomerTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void removeFromCustomerView() { - String customerName = ENTITY_NAME; + String customerName = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customerName)); sideBarMenuView.customerBtn().click(); @@ -90,7 +87,7 @@ public class DeleteCustomerTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void removeCustomerByRightSideBtnWithoutRefresh() { - String customer = ENTITY_NAME; + String customer = ENTITY_NAME + random(); testRestClient.postCustomer(defaultCustomerPrototype(customer)); sideBarMenuView.customerBtn().click(); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteSeveralCustomerTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteSeveralCustomerTest.java index 06005075c3..7e3ea7ad76 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteSeveralCustomerTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteSeveralCustomerTest.java @@ -24,9 +24,8 @@ import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; -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.EntityPrototypes.defaultCustomerPrototype; public class DeleteSeveralCustomerTest extends AbstractDriverBaseTest { @@ -36,9 +35,7 @@ public class DeleteSeveralCustomerTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); } @@ -46,8 +43,8 @@ public class DeleteSeveralCustomerTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void canDeleteSeveralCustomersByTopBtn() { - String title1 = ENTITY_NAME + "1"; - String title2 = ENTITY_NAME + "2"; + String title1 = ENTITY_NAME + random() + "1"; + String title2 = ENTITY_NAME + random() + "2"; testRestClient.postCustomer(defaultCustomerPrototype(title1)); testRestClient.postCustomer(defaultCustomerPrototype(title2)); @@ -76,8 +73,8 @@ public class DeleteSeveralCustomerTest extends AbstractDriverBaseTest { @Test(priority = 30, groups = "smoke") @Description public void deleteSeveralCustomersByTopBtnWithoutRefresh() { - String title1 = ENTITY_NAME + "1"; - String title2 = ENTITY_NAME + "2"; + String title1 = ENTITY_NAME + random() + "1"; + String title2 = ENTITY_NAME + random() + "2"; testRestClient.postCustomer(defaultCustomerPrototype(title1)); testRestClient.postCustomer(defaultCustomerPrototype(title2)); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersAssetsTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersAssetsTest.java index cfcf80c664..3b5e089494 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersAssetsTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersAssetsTest.java @@ -32,7 +32,6 @@ public class ManageCustomersAssetsTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDashboardsTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDashboardsTest.java index 50b6e895c8..3e29142a65 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDashboardsTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDashboardsTest.java @@ -31,7 +31,6 @@ public class ManageCustomersDashboardsTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDevicesTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDevicesTest.java index 6b5d3b80fd..8c944396d0 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDevicesTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDevicesTest.java @@ -31,7 +31,6 @@ public class ManageCustomersDevicesTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersEdgesTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersEdgesTest.java index 051658eb00..9f1000b967 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersEdgesTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersEdgesTest.java @@ -32,7 +32,6 @@ public class ManageCustomersEdgesTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersUsersTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersUsersTest.java index 509bacefc0..87266e56f3 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersUsersTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersUsersTest.java @@ -32,7 +32,6 @@ public class ManageCustomersUsersTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SearchCustomerTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SearchCustomerTest.java index 7a1a4694bc..848a1cccc5 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SearchCustomerTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SearchCustomerTest.java @@ -25,8 +25,6 @@ import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import org.thingsboard.server.msa.ui.utils.DataProviderCredential; -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.EntityPrototypes.defaultCustomerPrototype; public class SearchCustomerTest extends AbstractDriverBaseTest { @@ -36,9 +34,7 @@ public class SearchCustomerTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SortByNameTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SortByNameTest.java index 728696ac6f..96c881d6be 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SortByNameTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SortByNameTest.java @@ -26,8 +26,6 @@ import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import org.thingsboard.server.msa.ui.utils.DataProviderCredential; -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.EntityPrototypes.defaultCustomerPrototype; public class SortByNameTest extends AbstractDriverBaseTest { @@ -37,9 +35,7 @@ public class SortByNameTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); customerPage = new CustomerPageHelper(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/CreateDeviceProfileImportTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/CreateDeviceProfileImportTest.java new file mode 100644 index 0000000000..e66daf5a17 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/CreateDeviceProfileImportTest.java @@ -0,0 +1,126 @@ +/** + * Copyright © 2016-2022 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.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 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.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_TXT_FILE_NAME; +import static org.thingsboard.server.msa.ui.utils.Const.SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE; + +public class CreateDeviceProfileImportTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private final String absolutePathToFileImportDeviceProfile = getClass().getClassLoader().getResource(IMPORT_DEVICE_PROFILE_FILE_NAME).getPath(); + private final String absolutePathToFileImportTxt = getClass().getClassLoader().getResource(IMPORT_TXT_FILE_NAME).getPath(); + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteDeviseProfile(getDeviceProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description + public void importDeviceProfile() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.openImportDeviceProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile); + profilesPage.importBrowseFileBtn().click(); + name = IMPORT_DEVICE_PROFILE_NAME; + profilesPage.refreshBtn().click(); + + Assert.assertNotNull(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME)); + Assert.assertTrue(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void importTxtFile() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.openImportDeviceProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportTxt); + + Assert.assertNotNull(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE)); + Assert.assertTrue(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void addFileTiImportAndRemove() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.openImportDeviceProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile); + profilesPage.clearImportFileBtn().click(); + + Assert.assertNotNull(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE)); + Assert.assertTrue(profilesPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed()); + Assert.assertTrue(profilesPage.entityIsNotPresent(IMPORT_DEVICE_PROFILE_NAME)); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void importDeviceProfileWithSameName() { + String name = IMPORT_DEVICE_PROFILE_NAME; + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.openImportDeviceProfileView(); + profilesPage.browseFile().sendKeys(absolutePathToFileImportDeviceProfile); + profilesPage.importBrowseFileBtn().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(priority = 30, groups = "smoke") + @Description + 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.assertTrue(profilesPage.entity(IMPORT_DEVICE_PROFILE_NAME).isDisplayed()); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/CreateDeviceProfileTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/CreateDeviceProfileTest.java new file mode 100644 index 0000000000..02d41a61b8 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/CreateDeviceProfileTest.java @@ -0,0 +1,182 @@ +/** + * Copyright © 2016-2022 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.deviceProfileSmoke; + +import io.qameta.allure.Description; +import org.openqa.selenium.Keys; +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 org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_DEVICE_PROFILE_MESSAGE; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; +import static org.thingsboard.server.msa.ui.utils.Const.NAME_IS_REQUIRED_MESSAGE; +import static org.thingsboard.server.msa.ui.utils.Const.SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE; + +public class CreateDeviceProfileTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteDeviseProfile(getDeviceProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description + public void createDeviceProfile() { + String name = ENTITY_NAME + random(); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.openCreateDeviceProfileView(); + profilesPage.createDeviceProfileEnterName(name); + profilesPage.addDeviceProfileAddBtn().click(); + profilesPage.refreshBtn().click(); + this.name = name; + + Assert.assertNotNull(profilesPage.entity(name)); + Assert.assertTrue(profilesPage.entity(name).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createDeviceProfileWithDetails() { + String name = ENTITY_NAME + random(); + String ruleChain = "Root Rule Chain"; + String mobileDashboard = "Firmware"; + String queue = "Main"; + String description = "Description"; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.openCreateDeviceProfileView(); + profilesPage.createDeviceProfileEnterName(name); + profilesPage.addDeviceProfileViewChooseRuleChain(ruleChain); + profilesPage.addDeviceProfileViewChooseMobileDashboard(mobileDashboard); + profilesPage.addDeviceProfileViewChooseQueue(queue); + profilesPage.addDeviceProfileViewEnterDescription(description); + profilesPage.addDeviceProfileAddBtn().click(); + profilesPage.refreshBtn().click(); + this.name = name; + profilesPage.entity(name).click(); + profilesPage.setName(); + profilesPage.setRuleChain(); + profilesPage.setMobileDashboard(); + profilesPage.setQueue(); + profilesPage.setDescription(); + + Assert.assertNotNull(profilesPage.entity(name)); + Assert.assertTrue(profilesPage.entity(name).isDisplayed()); + Assert.assertEquals(name, profilesPage.getName()); + Assert.assertEquals(ruleChain, profilesPage.getRuleChain()); + Assert.assertEquals(mobileDashboard, profilesPage.getMobileDashboard()); + Assert.assertEquals(queue, profilesPage.getQueue()); + Assert.assertEquals(description, profilesPage.getDescription()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createDeviseProfileWithSameName() { + String name = ENTITY_NAME + random(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.openCreateDeviceProfileView(); + profilesPage.createDeviceProfileEnterName(name); + profilesPage.addDeviceProfileAddBtn().click(); + + Assert.assertNotNull(profilesPage.warningMessage()); + Assert.assertTrue(profilesPage.warningMessage().isDisplayed()); + Assert.assertEquals(profilesPage.warningMessage().getText(), SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE); + Assert.assertNotNull(profilesPage.addDeviceProfileView()); + Assert.assertTrue(profilesPage.addDeviceProfileView().isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createDeviceProfileWithoutName() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.openCreateDeviceProfileView(); + profilesPage.addDeviceProfileAddBtn().click(); + + Assert.assertNotNull(profilesPage.addDeviceProfileView()); + Assert.assertTrue(profilesPage.addDeviceProfileView().isDisplayed()); + Assert.assertNotNull(profilesPage.errorMessage()); + Assert.assertEquals(profilesPage.errorMessage().getText(), NAME_IS_REQUIRED_MESSAGE); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createDeviseProfileWithOnlySpaceInName() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.openCreateDeviceProfileView(); + profilesPage.createDeviceProfileEnterName(Keys.SPACE); + profilesPage.addDeviceProfileAddBtn().click(); + + Assert.assertNotNull(profilesPage.warningMessage()); + Assert.assertTrue(profilesPage.warningMessage().isDisplayed()); + Assert.assertEquals(profilesPage.warningMessage().getText(), EMPTY_DEVICE_PROFILE_MESSAGE); + Assert.assertNotNull(profilesPage.addDeviceProfileView()); + Assert.assertTrue(profilesPage.addDeviceProfileView().isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void createDeviceProfileWithoutRefresh() { + String name = ENTITY_NAME + random(); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.openCreateDeviceProfileView(); + profilesPage.createDeviceProfileEnterName(name); + profilesPage.addDeviceProfileAddBtn().click(); + this.name = name; + + Assert.assertNotNull(profilesPage.entity(name)); + Assert.assertTrue(profilesPage.entity(name).isDisplayed()); + } + + @Test(priority = 30, groups = "smoke") + @Description + public void documentation() { + String urlPath = "docs/user-guide/device-profiles/"; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.allEntity().get(0).click(); + profilesPage.goToProfileHelpPage(); + + Assert.assertTrue(urlContains(urlPath)); + } +} + diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeleteDeviceProfileTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeleteDeviceProfileTest.java new file mode 100644 index 0000000000..283796d48e --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeleteDeviceProfileTest.java @@ -0,0 +1,125 @@ +/** + * Copyright © 2016-2022 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.deviceProfileSmoke; + +import io.qameta.allure.Description; +import org.testng.Assert; +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 org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; + +public class DeleteDeviceProfileTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void removeDeviceProfile() { + String name = ENTITY_NAME + random(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.deleteBtn(name).click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn(); + + Assert.assertTrue(profilesPage.entityIsNotPresent(name)); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeDeviceProfileFromView() { + String name = ENTITY_NAME + random(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.entity(name).click(); + profilesPage.deviceProfileViewDeleteBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn(); + + Assert.assertTrue(profilesPage.entityIsNotPresent(name)); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeSelectedDeviceProfile() { + String name = ENTITY_NAME + random(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.checkBox(name).click(); + profilesPage.deleteSelectedBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn(); + + Assert.assertTrue(profilesPage.entityIsNotPresent(name)); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeDefaultDeviceProfile() { + sideBarMenuView.openDeviceProfiles(); + + Assert.assertFalse(profilesPage.deleteBtn("default").isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeDefaultDeviceProfileFromView() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.entity("default").click(); + + Assert.assertTrue(profilesPage.deleteDeviceProfileFromViewBtnIsNotDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeSelectedDefaultDeviceProfile() { + sideBarMenuView.openDeviceProfiles(); + + Assert.assertNotNull(profilesPage.presentCheckBox("default")); + Assert.assertFalse(profilesPage.presentCheckBox("default").isDisplayed()); + } + + @Test(priority = 30, groups = "smoke") + @Description + public void removeDeviceProfileWithoutRefresh() { + String name = ENTITY_NAME + random(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.deleteBtn(name).click(); + profilesPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(profilesPage.entityIsNotPresent(name)); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeleteSeveralDeviceProfilesTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeleteSeveralDeviceProfilesTest.java new file mode 100644 index 0000000000..a5ee858903 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeleteSeveralDeviceProfilesTest.java @@ -0,0 +1,98 @@ +/** + * Copyright © 2016-2022 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.deviceProfileSmoke; + +import io.qameta.allure.Description; +import org.testng.Assert; +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.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultDeviceProfile; + +public class DeleteSeveralDeviceProfilesTest extends AbstractDriverBaseTest { + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void canDeleteSeveralDeviceProfilesByTopBtn() { + String name1 = ENTITY_NAME + random() + "1"; + String name2 = ENTITY_NAME + random() + "2"; + testRestClient.postDeviceProfile(defaultDeviceProfile(name1)); + testRestClient.postDeviceProfile(defaultDeviceProfile(name2)); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.clickOnCheckBoxes(2); + profilesPage.deleteSelectedBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.refreshBtn().click(); + + Assert.assertTrue(profilesPage.profileIsNotPresent(name1)); + Assert.assertTrue(profilesPage.profileIsNotPresent(name2)); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void selectAllDeviceProfiles() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.selectAllCheckBox().click(); + profilesPage.deleteSelectedBtn().click(); + + Assert.assertNotNull(profilesPage.warningPopUpTitle()); + Assert.assertTrue(profilesPage.warningPopUpTitle().isDisplayed()); + Assert.assertTrue(profilesPage.warningPopUpTitle().getText().contains(String.valueOf(profilesPage.markCheckbox().size()))); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void removeDefaultDeviceProfile() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.selectAllCheckBox().click(); + + Assert.assertFalse(profilesPage.checkBoxIsDisplayed("default")); + Assert.assertFalse(profilesPage.deleteBtn("default").isEnabled()); + } + + @Test(priority = 30, groups = "smoke") + @Description + public void deleteSeveralDeviceProfilesByTopBtnWithoutRefresh() { + String name1 = ENTITY_NAME + random() + "1"; + String name2 = ENTITY_NAME + random() + "2"; + testRestClient.postDeviceProfile(defaultDeviceProfile(name1)); + testRestClient.postDeviceProfile(defaultDeviceProfile(name2)); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.clickOnCheckBoxes(2); + profilesPage.deleteSelectedBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(profilesPage.profileIsNotPresent(name1)); + Assert.assertTrue(profilesPage.profileIsNotPresent(name2)); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeviceProfileEditMenuTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeviceProfileEditMenuTest.java new file mode 100644 index 0000000000..eb8cba6d8d --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/DeviceProfileEditMenuTest.java @@ -0,0 +1,129 @@ +/** + * Copyright © 2016-2022 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.deviceProfileSmoke; + +import io.qameta.allure.Description; +import org.openqa.selenium.Keys; +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 org.thingsboard.server.msa.ui.utils.DataProviderCredential; +import org.thingsboard.server.msa.ui.utils.EntityPrototypes; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; +import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_DEVICE_PROFILE_MESSAGE; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; + +public class DeviceProfileEditMenuTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteDeviseProfile(getDeviceProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description + public void changeName() { + String name = ENTITY_NAME + random(); + String newName = "Changed" + getRandomNumber(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.entity(name).click(); + profilesPage.setHeaderName(); + String titleBefore = profilesPage.getHeaderName(); + jsClick(profilesPage.editPencilBtn()); + profilesPage.changeNameEditMenu(newName); + profilesPage.doneBtnEditView().click(); + this.name = newName; + profilesPage.setHeaderName(); + String titleAfter = profilesPage.getHeaderName(); + + Assert.assertNotEquals(titleBefore, titleAfter); + Assert.assertEquals(titleAfter, newName); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void deleteName() { + String name = ENTITY_NAME + random(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.entity(name).click(); + jsClick(profilesPage.editPencilBtn()); + profilesPage.changeNameEditMenu(""); + + Assert.assertFalse(profilesPage.doneBtnEditViewVisible().isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void saveWithOnlySpaceInName() { + String name = ENTITY_NAME + random(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.entity(name).click(); + jsClick(profilesPage.editPencilBtn()); + profilesPage.changeNameEditMenu(Keys.SPACE); + profilesPage.doneBtnEditView().click(); + + Assert.assertNotNull(profilesPage.warningMessage()); + Assert.assertTrue(profilesPage.warningMessage().isDisplayed()); + Assert.assertEquals(profilesPage.warningMessage().getText(), EMPTY_DEVICE_PROFILE_MESSAGE); + } + + @Test(priority = 30, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "editMenuDescription") + @Description + public void editDescription(String description, String newDescription, String finalDescription) { + String name = ENTITY_NAME + random(); + testRestClient.postDeviceProfile(EntityPrototypes.defaultDeviceProfile(name, description)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.entity(name).click(); + jsClick(profilesPage.editPencilBtn()); + profilesPage.profileViewDescriptionField().sendKeys(newDescription); + profilesPage.doneBtnEditView().click(); + profilesPage.setDescription(); + + Assert.assertEquals(profilesPage.getDescription(), finalDescription); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/MakeDeviceProfileDefaultTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/MakeDeviceProfileDefaultTest.java new file mode 100644 index 0000000000..6b52dfd1db --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/MakeDeviceProfileDefaultTest.java @@ -0,0 +1,69 @@ +/** + * Copyright © 2016-2022 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.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; + +public class MakeDeviceProfileDefaultTest extends AbstractDriverBaseTest { + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void makeProfileDefault() { + testRestClient.setDefaultDeviceProfile(getDeviceProfileByName("default").getId()); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void makeDeviceProfileDefaultByRightCornerBtn() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.setProfileName(); + String profile = profilesPage.getProfileName(); + profilesPage.makeProfileDefaultBtn(profile).click(); + profilesPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(profilesPage.defaultCheckbox(profile).isDisplayed()); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void makeDeviceProfileDefaultFromView() { + sideBarMenuView.openDeviceProfiles(); + profilesPage.setProfileName(); + String profile = profilesPage.getProfileName(); + profilesPage.entity(profile).click(); + profilesPage.deviceProfileViewMakeDefaultBtn().click(); + profilesPage.warningPopUpYesBtn().click(); + profilesPage.closeEntityViewBtn().click(); + + Assert.assertTrue(profilesPage.defaultCheckbox(profile).isDisplayed()); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/SearchDeviceProfileTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/SearchDeviceProfileTest.java new file mode 100644 index 0000000000..a8706f42ee --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/SearchDeviceProfileTest.java @@ -0,0 +1,63 @@ +/** + * Copyright © 2016-2022 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.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 org.thingsboard.server.msa.ui.utils.DataProviderCredential; + +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultDeviceProfile; + +public class SearchDeviceProfileTest extends AbstractDriverBaseTest { + + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteDeviseProfile(getDeviceProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "deviceProfileSearch") + @Description + public void searchFirstWord(String name, String namePath) { + testRestClient.postDeviceProfile(defaultDeviceProfile(name)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.searchEntity(namePath); + + profilesPage.allEntity().forEach(x -> Assert.assertTrue(x.getText().contains(namePath))); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/SortByNameTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/SortByNameTest.java new file mode 100644 index 0000000000..bc5ff155ab --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/deviceProfileSmoke/SortByNameTest.java @@ -0,0 +1,127 @@ +/** + * Copyright © 2016-2022 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.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 org.thingsboard.server.msa.ui.utils.DataProviderCredential; + +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultDeviceProfile; + +public class SortByNameTest extends AbstractDriverBaseTest { + private SideBarMenuViewHelper sideBarMenuView; + private ProfilesPageHelper profilesPage; + private String name; + + @BeforeMethod + public void login() { + new LoginPageHelper(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewHelper(driver); + profilesPage = new ProfilesPageHelper(driver); + } + + @AfterMethod + public void delete() { + if (name != null) { + testRestClient.deleteDeviseProfile(getDeviceProfileByName(name).getId()); + name = null; + } + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") + @Description + public void specialCharacterUp(String name) { + testRestClient.postDeviceProfile(defaultDeviceProfile(name)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.sortByNameBtn().click(); + profilesPage.setProfileName(); + + Assert.assertEquals(profilesPage.getProfileName(), name); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") + @Description + public void allSortUp(String deviceProfile, String deviceProfileSymbol, String deviceProfileNumber) { + testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfileSymbol)); + testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfile)); + testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfileNumber)); + + sideBarMenuView.openDeviceProfiles(); + profilesPage.sortByNameBtn().click(); + profilesPage.setProfileName(0); + String firstDeviceProfile = profilesPage.getProfileName(); + profilesPage.setProfileName(1); + String secondDeviceProfile = profilesPage.getProfileName(); + profilesPage.setProfileName(2); + String thirdDeviceProfile = profilesPage.getProfileName(); + + testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfile).getId()); + testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfileNumber).getId()); + testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfileSymbol).getId()); + + Assert.assertEquals(firstDeviceProfile, deviceProfileSymbol); + Assert.assertEquals(secondDeviceProfile, deviceProfileNumber); + Assert.assertEquals(thirdDeviceProfile, deviceProfile); + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") + @Description + public void specialCharacterDown(String name) { + testRestClient.postDeviceProfile(defaultDeviceProfile(name)); + this.name = name; + + sideBarMenuView.openDeviceProfiles(); + profilesPage.sortByNameDown(); + profilesPage.setProfileName(profilesPage.allEntity().size() - 1); + + Assert.assertEquals(profilesPage.getProfileName(), name); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") + @Description + public void allSortDown(String deviceProfile, String deviceProfileSymbol, String deviceProfileNumber) { + testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfileSymbol)); + testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfile)); + testRestClient.postDeviceProfile(defaultDeviceProfile(deviceProfileNumber)); + + sideBarMenuView.openDeviceProfiles(); + int lastIndex = profilesPage.allEntity().size() - 1; + profilesPage.sortByNameDown(); + profilesPage.setProfileName(lastIndex); + String firstDeviceProfile = profilesPage.getProfileName(); + profilesPage.setProfileName(lastIndex - 1); + String secondDeviceProfile = profilesPage.getProfileName(); + profilesPage.setProfileName(lastIndex - 2); + String thirdDeviceProfile = profilesPage.getProfileName(); + + testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfile).getId()); + testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfileNumber).getId()); + testRestClient.deleteDeviseProfile(getDeviceProfileByName(deviceProfileSymbol).getId()); + + Assert.assertEquals(firstDeviceProfile, deviceProfileSymbol); + Assert.assertEquals(secondDeviceProfile, deviceProfileNumber); + Assert.assertEquals(thirdDeviceProfile, deviceProfile); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainImportTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainImportTest.java index 27a4ea2ecb..58afd758c9 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainImportTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainImportTest.java @@ -32,8 +32,6 @@ import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_IMPORT_MESSAGE; import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_RULE_CHAIN_FILE_NAME; import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_RULE_CHAIN_NAME; import static org.thingsboard.server.msa.ui.utils.Const.IMPORT_TXT_FILE_NAME; -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.EntityPrototypes.defaultRuleChainPrototype; public class CreateRuleChainImportTest extends AbstractDriverBaseTest { @@ -46,9 +44,7 @@ public class CreateRuleChainImportTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); openRuleChainPage = new OpenRuleChainPageHelper(driver); @@ -83,7 +79,7 @@ public class CreateRuleChainImportTest extends AbstractDriverBaseTest { Assert.assertNotNull(ruleChainsPage.importingFile(EMPTY_IMPORT_MESSAGE)); Assert.assertTrue(ruleChainsPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed()); - Assert.assertTrue(ruleChainsPage.entityIsNotPresent(IMPORT_TXT_FILE_NAME)); + Assert.assertTrue(ruleChainsPage.entityIsNotPresent(IMPORT_RULE_CHAIN_FILE_NAME)); } @Test(priority = 20, groups = "smoke") diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainTest.java index b60b4a4a52..2daabdb012 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainTest.java @@ -28,10 +28,9 @@ import org.thingsboard.server.msa.ui.utils.EntityPrototypes; import java.util.ArrayList; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_RULE_CHAIN_MESSAGE; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; -import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; -import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; public class CreateRuleChainTest extends AbstractDriverBaseTest { @@ -41,9 +40,7 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); } @@ -59,7 +56,7 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void createRuleChain() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); @@ -76,16 +73,16 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void createRuleChainWithDescription() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); ruleChainsPage.nameField().sendKeys(ruleChainName); - ruleChainsPage.descriptionAddEntityView().sendKeys(ENTITY_NAME); + ruleChainsPage.descriptionAddEntityView().sendKeys(ruleChainName); ruleChainsPage.addBtnC().click(); ruleChainsPage.refreshBtn().click(); this.ruleChainName = ruleChainName; - ruleChainsPage.detailsBtn(ENTITY_NAME).click(); + ruleChainsPage.detailsBtn(ruleChainName).click(); ruleChainsPage.setHeaderName(); Assert.assertEquals(ruleChainsPage.getHeaderName(), ruleChainName); @@ -119,7 +116,7 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void createRuleChainWithSameName() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(ruleChainName)); this.ruleChainName = ruleChainName; @@ -144,7 +141,7 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 30, groups = "smoke") @Description public void createRuleChainWithoutRefresh() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteRuleChainTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteRuleChainTest.java index d605b6c0e9..698b28b3e3 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteRuleChainTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteRuleChainTest.java @@ -24,11 +24,10 @@ import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.DELETE_RULE_CHAIN_WITH_PROFILE_MESSAGE; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; import static org.thingsboard.server.msa.ui.utils.Const.ROOT_RULE_CHAIN_NAME; -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.EntityPrototypes.defaultRuleChainPrototype; public class DeleteRuleChainTest extends AbstractDriverBaseTest { @@ -37,9 +36,7 @@ public class DeleteRuleChainTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); } @@ -47,7 +44,7 @@ public class DeleteRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void removeRuleChainByRightSideBtn() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); @@ -60,7 +57,7 @@ public class DeleteRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void removeSelectedRuleChain() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); @@ -73,7 +70,7 @@ public class DeleteRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void removeFromRuleChainView() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); @@ -160,7 +157,7 @@ public class DeleteRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 30, groups = "smoke") @Description public void removeRuleChainByRightSideBtnWithoutRefresh() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteSeveralRuleChainsTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteSeveralRuleChainsTest.java index bd6b8f73da..c37cf2d5ec 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteSeveralRuleChainsTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteSeveralRuleChainsTest.java @@ -24,10 +24,9 @@ import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; import static org.thingsboard.server.msa.ui.utils.Const.ROOT_RULE_CHAIN_NAME; -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.EntityPrototypes.defaultRuleChainPrototype; public class DeleteSeveralRuleChainsTest extends AbstractDriverBaseTest { @@ -37,9 +36,7 @@ public class DeleteSeveralRuleChainsTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); } @@ -47,7 +44,7 @@ public class DeleteSeveralRuleChainsTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void canDeleteSeveralRuleChainsByTopBtn() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName + 1)); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); @@ -63,7 +60,7 @@ public class DeleteSeveralRuleChainsTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void selectAllRuleChain() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName + 1)); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); @@ -97,7 +94,7 @@ public class DeleteSeveralRuleChainsTest extends AbstractDriverBaseTest { @Test(priority = 30, groups = "smoke") @Description public void deleteSeveralRuleChainsByTopBtnWithoutRefresh() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName + 1)); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/MakeRuleChainRootTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/MakeRuleChainRootTest.java index f63e65cc25..89e9756678 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/MakeRuleChainRootTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/MakeRuleChainRootTest.java @@ -25,9 +25,6 @@ import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; -import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; -import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; - public class MakeRuleChainRootTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; @@ -35,9 +32,7 @@ public class MakeRuleChainRootTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/OpenRuleChainTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/OpenRuleChainTest.java index 2f23fd8b74..70609242e1 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/OpenRuleChainTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/OpenRuleChainTest.java @@ -27,9 +27,8 @@ import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import org.thingsboard.server.msa.ui.utils.EntityPrototypes; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; -import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; -import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; public class OpenRuleChainTest extends AbstractDriverBaseTest { @@ -40,16 +39,14 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); openRuleChainPage = new OpenRuleChainPageHelper(driver); } @AfterMethod - public void delete(){ + public void delete() { if (ruleChainName != null) { testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); ruleChainName = null; @@ -59,8 +56,8 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void openRuleChainByRightCornerBtn() { - String ruleChainName = ENTITY_NAME; - testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(ENTITY_NAME)); + String ruleChainName = ENTITY_NAME + random(); + testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(ruleChainName)); this.ruleChainName = ruleChainName; sideBarMenuView.ruleChainsBtn().click(); @@ -76,7 +73,7 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void openRuleChainByViewBtn() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(ruleChainName)); this.ruleChainName = ruleChainName; diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/RuleChainEditMenuTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/RuleChainEditMenuTest.java index 3a7ea071bb..045a006837 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/RuleChainEditMenuTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/RuleChainEditMenuTest.java @@ -24,11 +24,13 @@ import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; +import org.thingsboard.server.msa.ui.utils.DataProviderCredential; +import org.thingsboard.server.msa.ui.utils.EntityPrototypes; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.EMPTY_RULE_CHAIN_MESSAGE; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; -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.EntityPrototypes.defaultRuleChainPrototype; public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @@ -39,9 +41,7 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); } @@ -57,8 +57,8 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void changeName() { - String newRuleChainName = "Changed"; - String ruleChainName = ENTITY_NAME; + String newRuleChainName = "Changed" + getRandomNumber(); + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); this.ruleChainName = ruleChainName; @@ -80,7 +80,7 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void deleteName() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); this.ruleChainName = ruleChainName; @@ -95,7 +95,7 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void saveOnlyWithSpace() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME +random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); this.ruleChainName = ruleChainName; @@ -110,37 +110,27 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { Assert.assertEquals(ruleChainsPage.warningMessage().getText(), EMPTY_RULE_CHAIN_MESSAGE); } - @Test(priority = 20, groups = "smoke") + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "editMenuDescription") @Description - public void editDescription() { - String ruleChainName = ENTITY_NAME; - testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); - this.ruleChainName = ruleChainName; - String description = "Description"; + public void editDescription(String description, String newDescription, String finalDescription) { + String name = ENTITY_NAME + random(); + testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(name, description)); + ruleChainName = name; sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.detailsBtn(ruleChainName).click(); - ruleChainsPage.editPencilBtn().click(); - ruleChainsPage.descriptionEntityView().sendKeys(description); - ruleChainsPage.doneBtnEditView().click(); - String description1 = ruleChainsPage.descriptionEntityView().getAttribute("value"); - ruleChainsPage.editPencilBtn().click(); - ruleChainsPage.descriptionEntityView().sendKeys(description); - ruleChainsPage.doneBtnEditView().click(); - String description2 = ruleChainsPage.descriptionEntityView().getAttribute("value"); + ruleChainsPage.detailsBtn(name).click(); ruleChainsPage.editPencilBtn().click(); - ruleChainsPage.changeDescription(""); + ruleChainsPage.descriptionEntityView().sendKeys(newDescription); ruleChainsPage.doneBtnEditView().click(); + ruleChainsPage.setDescription(); - Assert.assertTrue(ruleChainsPage.descriptionEntityView().getAttribute("value").isEmpty()); - Assert.assertEquals(description, description1); - Assert.assertEquals(description + description, description2); + Assert.assertEquals(ruleChainsPage.getDescription(), finalDescription); } @Test(priority = 20, groups = "smoke") @Description public void debugMode() { - String ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME + random(); testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); this.ruleChainName = ruleChainName; diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SearchRuleChainTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SearchRuleChainTest.java index 8594147c99..374c7085f5 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SearchRuleChainTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SearchRuleChainTest.java @@ -25,8 +25,6 @@ import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import org.thingsboard.server.msa.ui.utils.DataProviderCredential; -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.EntityPrototypes.defaultRuleChainPrototype; public class SearchRuleChainTest extends AbstractDriverBaseTest { @@ -36,9 +34,7 @@ public class SearchRuleChainTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByNameTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByNameTest.java index 6b9de5d1d1..04dead029a 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByNameTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByNameTest.java @@ -26,8 +26,6 @@ import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import org.thingsboard.server.msa.ui.utils.DataProviderCredential; -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.EntityPrototypes.defaultRuleChainPrototype; public class SortByNameTest extends AbstractDriverBaseTest { @@ -38,9 +36,7 @@ public class SortByNameTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByTimeTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByTimeTest.java index 4d08ccc42c..2919dcd6b3 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByTimeTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByTimeTest.java @@ -26,8 +26,6 @@ import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; -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.EntityPrototypes.defaultRuleChainPrototype; public class SortByTimeTest extends AbstractDriverBaseTest { @@ -38,9 +36,7 @@ public class SortByTimeTest extends AbstractDriverBaseTest { @BeforeMethod public void login() { - openLocalhost(); new LoginPageHelper(driver).authorizationTenant(); - testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); ruleChainsPage = new RuleChainsPageHelper(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/Const.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/Const.java index 8868d53768..fa9e7b8ab1 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/Const.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/Const.java @@ -23,15 +23,24 @@ public class Const { public static final String URL = getBaseUrl(); public static final String TENANT_EMAIL = "tenant@thingsboard.org"; public static final String TENANT_PASSWORD = "tenant"; - public static final String ENTITY_NAME = "Az!@#$%^&*()_-+=~`" + getRandomNumber(); + public static final String ENTITY_NAME = "Az!@#$%^&*()_-+=~`"; public static final String ROOT_RULE_CHAIN_NAME = "Root Rule Chain"; - public static final String IMPORT_RULE_CHAIN_NAME = "Rule Chain from Import"; - public static final String IMPORT_RULE_CHAIN_FILE_NAME = "forImport.json"; + public static final String IMPORT_RULE_CHAIN_NAME = "Rule Chain For Import"; + public static final String IMPORT_DEVICE_PROFILE_NAME = "Device Profile For Import"; + public static final String IMPORT_ASSET_PROFILE_NAME = "Asset Profile For Import"; + public static final String IMPORT_RULE_CHAIN_FILE_NAME = "ruleChainForImport.json"; + public static final String IMPORT_DEVICE_PROFILE_FILE_NAME = "deviceProfileForImport.json"; + public static final String IMPORT_ASSET_PROFILE_FILE_NAME = "assetProfileForImport.json"; public static final String IMPORT_TXT_FILE_NAME = "forImport.txt"; public static final String EMPTY_IMPORT_MESSAGE = "No file selected"; public static final String EMPTY_RULE_CHAIN_MESSAGE = "Rule chain name should be specified!"; public static final String EMPTY_CUSTOMER_MESSAGE = "Customer title should be specified!"; + public static final String EMPTY_DEVICE_PROFILE_MESSAGE = "Device profile name should be specified!"; + public static final String EMPTY_ASSET_PROFILE_MESSAGE = "Asset profile name should be specified!"; public static final String DELETE_RULE_CHAIN_WITH_PROFILE_MESSAGE = "The rule chain referenced by the device profiles cannot be deleted!"; public static final String SAME_NAME_WARNING_CUSTOMER_MESSAGE = "Customer with such title already exists!"; + public static final String SAME_NAME_WARNING_DEVICE_PROFILE_MESSAGE = "Device profile with such name already exists!"; + public static final String SAME_NAME_WARNING_ASSET_PROFILE_MESSAGE = "Asset profile with such name already exists!"; public static final String PHONE_NUMBER_ERROR_MESSAGE = "Phone number is invalid or not possible"; + public static final String NAME_IS_REQUIRED_MESSAGE = "Name is required."; } \ No newline at end of file diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/DataProviderCredential.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/DataProviderCredential.java index 5536338fe5..22830966ec 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/DataProviderCredential.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/DataProviderCredential.java @@ -15,15 +15,18 @@ */ package org.thingsboard.server.msa.ui.utils; +import org.openqa.selenium.Keys; import org.testng.annotations.DataProvider; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomSymbol; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random; import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; public class DataProviderCredential { - private static final String SYMBOL = String.valueOf(getRandomSymbol()); private static final String NAME = ENTITY_NAME; + private static final String SYMBOL = String.valueOf(getRandomSymbol()); private static final String NUMBER = "1"; private static final String LONG_PHONE_NUMBER = "20155501231"; private static final String SHORT_PHONE_NUMBER = "201555011"; @@ -31,6 +34,8 @@ public class DataProviderCredential { private static final String CUSTOMER_SECOND_WORD_NAME_PATH = "Customer"; private static final String RULE_CHAIN_FIRST_WORD_NAME_PATH = "Root"; private static final String CUSTOMER_FIRST_WORD_NAME_PATH = "A"; + private static final String DEFAULT_DEVICE_PROFILE_NAME = "Device Profile"; + private static final String DEFAULT_ASSET_PROFILE_NAME = "Asset Profile"; @DataProvider public static Object[][] ruleChainNameForSearchByFirstAndSecondWord() { @@ -41,15 +46,29 @@ public class DataProviderCredential { @DataProvider public static Object[][] nameForSearchBySymbolAndNumber() { + String name = ENTITY_NAME + random(); return new Object[][]{ - {NAME, ENTITY_NAME.split("`")[1]}, - {NAME, String.valueOf(getRandomSymbol())}}; + {name, name.split("`")[1]}, + {NAME + getRandomNumber(), "~"}, + {NAME + getRandomNumber(), "`"}, + {NAME + getRandomNumber(), "!"}, + {NAME + getRandomNumber(), "@"}, + {NAME + getRandomNumber(), "#"}, + {NAME + getRandomNumber(), "$"}, + {NAME + getRandomNumber(), "^"}, + {NAME + getRandomNumber(), "&"}, + {NAME + getRandomNumber(), "*"}, + {NAME + getRandomNumber(), "("}, + {NAME + getRandomNumber(), ")"}, + {NAME + getRandomNumber(), "+"}, + {NAME + getRandomNumber(), "="}, + {NAME + getRandomNumber(), "-"}}; } @DataProvider public static Object[][] nameForSort() { return new Object[][]{ - {NAME}, + {NAME + getRandomNumber()}, {SYMBOL}, {NUMBER}}; } @@ -57,7 +76,7 @@ public class DataProviderCredential { @DataProvider public static Object[][] nameForAllSort() { return new Object[][]{ - {NAME, SYMBOL, NUMBER}}; + {NAME + getRandomNumber(), SYMBOL, NUMBER}}; } @DataProvider @@ -65,7 +84,7 @@ public class DataProviderCredential { return new Object[][]{ {LONG_PHONE_NUMBER}, {SHORT_PHONE_NUMBER}, - {ENTITY_NAME}}; + {ENTITY_NAME + getRandomNumber()}}; } @DataProvider @@ -74,4 +93,60 @@ public class DataProviderCredential { {CUSTOMER_FIRST_WORD_NAME_PATH}, {CUSTOMER_SECOND_WORD_NAME_PATH}}; } + + @DataProvider + public static Object[][] deviceProfileSearch() { + String name = NAME + getRandomNumber(); + return new Object[][]{ + {DEFAULT_DEVICE_PROFILE_NAME, DEFAULT_DEVICE_PROFILE_NAME.split(" ")[0]}, + {DEFAULT_DEVICE_PROFILE_NAME, DEFAULT_DEVICE_PROFILE_NAME.split(" ")[1]}, + {name, name.split("`")[1]}, + {NAME + getRandomNumber(), "~"}, + {NAME + getRandomNumber(), "`"}, + {NAME + getRandomNumber(), "!"}, + {NAME + getRandomNumber(), "@"}, + {NAME + getRandomNumber(), "#"}, + {NAME + getRandomNumber(), "$"}, + {NAME + getRandomNumber(), "^"}, + {NAME + getRandomNumber(), "&"}, + {NAME + getRandomNumber(), "*"}, + {NAME + getRandomNumber(), "("}, + {NAME + getRandomNumber(), ")"}, + {NAME + getRandomNumber(), "+"}, + {NAME + getRandomNumber(), "="}, + {NAME + getRandomNumber(), "-"}}; + } + + @DataProvider + public static Object[][] assetProfileSearch() { + String name = NAME + getRandomNumber(); + return new Object[][]{ + {DEFAULT_ASSET_PROFILE_NAME, DEFAULT_ASSET_PROFILE_NAME.split(" ")[0]}, + {DEFAULT_ASSET_PROFILE_NAME, DEFAULT_ASSET_PROFILE_NAME.split(" ")[1]}, + {name, name.split("`")[1]}, + {NAME + getRandomNumber(), "~"}, + {NAME + getRandomNumber(), "`"}, + {NAME + getRandomNumber(), "!"}, + {NAME + getRandomNumber(), "@"}, + {NAME + getRandomNumber(), "#"}, + {NAME + getRandomNumber(), "$"}, + {NAME + getRandomNumber(), "^"}, + {NAME + getRandomNumber(), "&"}, + {NAME + getRandomNumber(), "*"}, + {NAME + getRandomNumber(), "("}, + {NAME + getRandomNumber(), ")"}, + {NAME + getRandomNumber(), "+"}, + {NAME + getRandomNumber(), "="}, + {NAME + getRandomNumber(), "-"}}; + } + + @DataProvider + public static Object[][] editMenuDescription() { + String newDescription = "Description" + getRandomNumber(); + String description = "Description"; + return new Object[][]{ + {"", newDescription, newDescription}, + {description, newDescription, description + newDescription}, + {description, Keys.CONTROL + "A" + Keys.BACK_SPACE, ""}}; + } } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/EntityPrototypes.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/EntityPrototypes.java index 5fcfe8f4f9..0f32768af8 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/EntityPrototypes.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/EntityPrototypes.java @@ -15,20 +15,86 @@ */ package org.thingsboard.server.msa.ui.utils; +import org.thingsboard.common.util.JacksonUtil; import org.thingsboard.server.common.data.Customer; +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.asset.AssetProfile; +import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileConfiguration; +import org.thingsboard.server.common.data.device.profile.DefaultDeviceProfileTransportConfiguration; +import org.thingsboard.server.common.data.device.profile.DeviceProfileData; +import org.thingsboard.server.common.data.device.profile.DisabledDeviceProfileProvisionConfiguration; import org.thingsboard.server.common.data.rule.RuleChain; public class EntityPrototypes { - public static Customer defaultCustomerPrototype(String entityName){ + public static Customer defaultCustomerPrototype(String entityName) { Customer customer = new Customer(); customer.setTitle(entityName); return customer; } - public static RuleChain defaultRuleChainPrototype(String entityName){ + public static Customer defaultCustomerPrototype(String entityName, String description) { + Customer customer = new Customer(); + customer.setTitle(entityName); + customer.setAdditionalInfo(JacksonUtil.newObjectNode().put("description", description)); + return customer; + } + + public static RuleChain defaultRuleChainPrototype(String entityName) { + RuleChain ruleChain = new RuleChain(); + ruleChain.setName(entityName); + return ruleChain; + } + + public static RuleChain defaultRuleChainPrototype(String entityName, String description) { RuleChain ruleChain = new RuleChain(); ruleChain.setName(entityName); + ruleChain.setAdditionalInfo(JacksonUtil.newObjectNode().put("description", description)); return ruleChain; } + + public static DeviceProfile defaultDeviceProfile(String entityName) { + DeviceProfile deviceProfile = new DeviceProfile(); + deviceProfile.setName(entityName); + deviceProfile.setType(DeviceProfileType.DEFAULT); + deviceProfile.setTransportType(DeviceTransportType.DEFAULT); + deviceProfile.setProvisionType(DeviceProfileProvisionType.DISABLED); + DeviceProfileData deviceProfileData = new DeviceProfileData(); + deviceProfileData.setConfiguration(new DefaultDeviceProfileConfiguration()); + deviceProfileData.setProvisionConfiguration(new DisabledDeviceProfileProvisionConfiguration(null)); + deviceProfileData.setTransportConfiguration(new DefaultDeviceProfileTransportConfiguration()); + deviceProfile.setProfileData(deviceProfileData); + return deviceProfile; + } + + public static DeviceProfile defaultDeviceProfile(String entityName, String description) { + DeviceProfile deviceProfile = new DeviceProfile(); + deviceProfile.setName(entityName); + deviceProfile.setDescription(description); + deviceProfile.setType(DeviceProfileType.DEFAULT); + deviceProfile.setTransportType(DeviceTransportType.DEFAULT); + deviceProfile.setProvisionType(DeviceProfileProvisionType.DISABLED); + DeviceProfileData deviceProfileData = new DeviceProfileData(); + deviceProfileData.setConfiguration(new DefaultDeviceProfileConfiguration()); + deviceProfileData.setProvisionConfiguration(new DisabledDeviceProfileProvisionConfiguration(null)); + deviceProfileData.setTransportConfiguration(new DefaultDeviceProfileTransportConfiguration()); + deviceProfile.setProfileData(deviceProfileData); + return deviceProfile; + } + + public static AssetProfile defaultAssetProfile(String entityName) { + AssetProfile assetProfile = new AssetProfile(); + assetProfile.setName(entityName); + return assetProfile; + } + + public static AssetProfile defaultAssetProfile(String entityName, String description) { + AssetProfile assetProfile = new AssetProfile(); + assetProfile.setName(entityName); + assetProfile.setDescription(description); + return assetProfile; + } } diff --git a/msa/black-box-tests/src/test/resources/all.xml b/msa/black-box-tests/src/test/resources/all.xml index fe8b908a86..e308b2854d 100644 --- a/msa/black-box-tests/src/test/resources/all.xml +++ b/msa/black-box-tests/src/test/resources/all.xml @@ -47,4 +47,24 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/assetProfileForImport.json b/msa/black-box-tests/src/test/resources/assetProfileForImport.json new file mode 100644 index 0000000000..b42d77f998 --- /dev/null +++ b/msa/black-box-tests/src/test/resources/assetProfileForImport.json @@ -0,0 +1,10 @@ +{ + "name": "Asset Profile For Import", + "description": null, + "image": null, + "defaultRuleChainId": null, + "defaultDashboardId": null, + "defaultQueueName": null, + "externalId": null, + "default": false +} \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/config.properties b/msa/black-box-tests/src/test/resources/config.properties index 419c73185d..4d8a0880a9 100644 --- a/msa/black-box-tests/src/test/resources/config.properties +++ b/msa/black-box-tests/src/test/resources/config.properties @@ -1,2 +1,3 @@ tb.baseUrl=http://localhost:8080 -tb.wsUrl=ws://localhost:8080 +tb.baseUiUrl=http://localhost:8080 +tb.wsUrl=ws://localhost:8080 \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/deviceProfileForImport.json b/msa/black-box-tests/src/test/resources/deviceProfileForImport.json new file mode 100644 index 0000000000..b2e1107945 --- /dev/null +++ b/msa/black-box-tests/src/test/resources/deviceProfileForImport.json @@ -0,0 +1,29 @@ +{ + "name": "Device Profile For Import", + "description": "", + "image": null, + "type": "DEFAULT", + "transportType": "DEFAULT", + "provisionType": "DISABLED", + "defaultRuleChainId": null, + "defaultDashboardId": null, + "defaultQueueName": null, + "profileData": { + "configuration": { + "type": "DEFAULT" + }, + "transportConfiguration": { + "type": "DEFAULT" + }, + "provisionConfiguration": { + "type": "DISABLED", + "provisionDeviceSecret": null + }, + "alarms": null + }, + "provisionDeviceKey": null, + "firmwareId": null, + "softwareId": null, + "externalId": null, + "default": false +} \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/forImport.json b/msa/black-box-tests/src/test/resources/ruleChainForImport.json similarity index 90% rename from msa/black-box-tests/src/test/resources/forImport.json rename to msa/black-box-tests/src/test/resources/ruleChainForImport.json index 40367d7609..79d70375fe 100644 --- a/msa/black-box-tests/src/test/resources/forImport.json +++ b/msa/black-box-tests/src/test/resources/ruleChainForImport.json @@ -3,7 +3,7 @@ "additionalInfo": { "description": "" }, - "name": "Rule Chain from Import", + "name": "Rule Chain For Import", "type": "CORE", "firstRuleNodeId": null, "root": false, diff --git a/msa/black-box-tests/src/test/resources/smokesProfiles.xml b/msa/black-box-tests/src/test/resources/smokesProfiles.xml new file mode 100644 index 0000000000..3d9400f8df --- /dev/null +++ b/msa/black-box-tests/src/test/resources/smokesProfiles.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/uiTests.xml b/msa/black-box-tests/src/test/resources/uiTests.xml index bd163de930..1a52096ce1 100644 --- a/msa/black-box-tests/src/test/resources/uiTests.xml +++ b/msa/black-box-tests/src/test/resources/uiTests.xml @@ -42,4 +42,24 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file