From be1acd219b588e55ebef79f84fbe6577f8fa00f2 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 22 Nov 2022 13:17:01 +0200 Subject: [PATCH 01/44] add ui tests --- msa/black-box-tests/pom.xml | 24 ++ .../server/msa/ui/base/AbstractBasePage.java | 129 +++++++++ .../msa/ui/base/AbstractDiverBaseTest.java | 74 +++++ .../msa/ui/listeners/RetryAnalyzer.java | 20 ++ .../msa/ui/listeners/RetryTestListener.java | 18 ++ .../server/msa/ui/listeners/TestListener.java | 62 ++++ .../msa/ui/pages/CustomerPageElements.java | 262 +++++++++++++++++ .../msa/ui/pages/CustomerPageHelper.java | 161 +++++++++++ .../msa/ui/pages/DashboardPageElements.java | 38 +++ .../msa/ui/pages/DashboardPageHelper.java | 25 ++ .../msa/ui/pages/LoginPageElements.java | 28 ++ .../server/msa/ui/pages/LoginPageHelper.java | 16 ++ .../ui/pages/OpenRuleChainPageElements.java | 33 +++ .../msa/ui/pages/OpenRuleChainPageHelper.java | 23 ++ .../msa/ui/pages/OtherPageElements.java | 228 +++++++++++++++ .../msa/ui/pages/OtherPageElementsHelper.java | 98 +++++++ .../msa/ui/pages/RuleChainsPageElements.java | 113 ++++++++ .../msa/ui/pages/RuleChainsPageHelper.java | 180 ++++++++++++ .../msa/ui/pages/SideBarMenuViewElements.java | 27 ++ .../customerSmoke/CreateCustomerTest.java | 164 +++++++++++ .../customerSmoke/CustomerEditMenuTest.java | 270 ++++++++++++++++++ .../customerSmoke/DeleteCustomerTest.java | 83 ++++++ .../DeleteSeveralCustomerTest.java | 81 ++++++ .../ManageCustomersAssetsTest.java | 54 ++++ .../ManageCustomersDashboardsTest.java | 53 ++++ .../ManageCustomersDevicesTest.java | 53 ++++ .../ManageCustomersEdgesTest.java | 54 ++++ .../ManageCustomersUsersTest.java | 54 ++++ .../customerSmoke/SearchCustomerTest.java | 56 ++++ .../tests/customerSmoke/SortByNameTest.java | 121 ++++++++ .../CreateRuleChainImportTest.java | 110 +++++++ .../ruleChainsSmoke/CreateRuleChainTest.java | 139 +++++++++ .../ruleChainsSmoke/DeleteRuleChainTest.java | 148 ++++++++++ .../DeleteSeveralRuleChainsTest.java | 92 ++++++ .../MakeRuleChainRootTest.java | 75 +++++ .../ruleChainsSmoke/OpenRuleChainTest.java | 71 +++++ .../RuleChainEditMenuTest.java | 130 +++++++++ .../ruleChainsSmoke/SearchRuleChainTest.java | 52 ++++ .../tests/ruleChainsSmoke/SortByNameTest.java | 122 ++++++++ .../tests/ruleChainsSmoke/SortByTimeTest.java | 70 +++++ .../server/msa/ui/utils/Const.java | 21 ++ .../msa/ui/utils/DataProviderCredential.java | 62 ++++ .../server/msa/ui/utils/EntityPrototypes.java | 19 ++ .../src/test/resources/connectivity.xml | 0 .../src/test/resources/forImport.json | 20 ++ .../src/test/resources/forImport.txt | 0 .../src/test/resources/smokeTests.xml | 26 ++ .../src/test/resources/smokesCustomer.xml | 137 +++++++++ .../src/test/resources/smokesRuleChain.xml | 138 +++++++++ 49 files changed, 4034 insertions(+) create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractBasePage.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryTestListener.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageHelper.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageElements.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageHelper.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageElements.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageHelper.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageElements.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageHelper.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElements.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElementsHelper.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageElements.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageHelper.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewElements.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CreateCustomerTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CustomerEditMenuTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteCustomerTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteSeveralCustomerTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersAssetsTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDashboardsTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDevicesTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersEdgesTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersUsersTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SearchCustomerTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SortByNameTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainImportTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteRuleChainTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteSeveralRuleChainsTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/MakeRuleChainRootTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/OpenRuleChainTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/RuleChainEditMenuTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SearchRuleChainTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByNameTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByTimeTest.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/Const.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/DataProviderCredential.java create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/EntityPrototypes.java create mode 100644 msa/black-box-tests/src/test/resources/connectivity.xml create mode 100644 msa/black-box-tests/src/test/resources/forImport.json create mode 100644 msa/black-box-tests/src/test/resources/forImport.txt create mode 100644 msa/black-box-tests/src/test/resources/smokeTests.xml create mode 100644 msa/black-box-tests/src/test/resources/smokesCustomer.xml create mode 100644 msa/black-box-tests/src/test/resources/smokesRuleChain.xml diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml index 49f4c959e9..c6952f05ba 100644 --- a/msa/black-box-tests/pom.xml +++ b/msa/black-box-tests/pom.xml @@ -160,7 +160,31 @@ snmp docker-info + + org.seleniumhq.selenium + selenium-java + 4.5.3 + + + io.github.bonigarcia + webdrivermanager + 5.3.0 + + + io.qameta.allure + allure-testng + 2.19.0 + + + + + com.google.guava + guava + 31.0.1-jre + + + 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 new file mode 100644 index 0000000000..8e8a15c5af --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractBasePage.java @@ -0,0 +1,129 @@ +package org.thingsboard.server.msa.ui.base; + +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebDriverException; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.thingsboard.rest.client.RestClient; +import org.thingsboard.server.common.data.page.PageLink; +import org.thingsboard.server.msa.ui.utils.Const; + +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +@Slf4j +abstract public class BasePage extends Base { + protected WebDriver driver; + protected WebDriverWait wait; + protected Actions actions; + protected RestClient client; + protected PageLink pageLink; + + public BasePage(WebDriver driver) { + this.driver = driver; + this.wait = new WebDriverWait(driver, Duration.ofMillis(5000)); + this.actions = new Actions(driver); + try { + client = new RestClient(Const.URL); + client.login(Const.TENANT_EMAIL, Const.TENANT_PASSWORD); + pageLink = new PageLink(10); + } catch (Exception e) { + log.info("Can't login"); + } + } + + @SneakyThrows + protected static void sleep(double second) { + Thread.sleep((long) (second * 1000L)); + } + + protected WebElement waitUntilVisibilityOfElementLocated(String locator) { + try { + return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator))); + } catch (WebDriverException e) { + log.error("No visibility element: " + locator); + return null; + } + } + + protected WebElement waitUntilElementToBeClickable(String locator) { + try { + return wait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator))); + } catch (WebDriverException e) { + log.error("No clickable element: " + locator); + return null; + } + } + + protected List waitUntilVisibilityOfElementsLocated(String locator) { + try { + wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator))); + return driver.findElements(By.xpath(locator)); + } catch (WebDriverException e) { + log.error("No visibility elements: " + locator); + return null; + } + } + + protected List waitUntilElementsToBeClickable(String locator) { + try { + wait.until(ExpectedConditions.elementToBeClickable(By.xpath(locator))); + return driver.findElements(By.xpath(locator)); + } catch (WebDriverException e) { + log.error("No clickable elements: " + locator); + return null; + } + } + + public void waitUntilUrlContainsText(String urlPath) { + try { + wait.until(ExpectedConditions.urlContains(urlPath)); + } catch (WebDriverException e) { + log.error("This URL path is missing"); + } + } + + protected void moveCursor(WebElement element) { + actions.moveToElement(element).perform(); + } + + protected void doubleClick(WebElement element) { + actions.doubleClick(element).build().perform(); + } + + public boolean elementIsNotPresent(String locator) { + try { + return wait.until(ExpectedConditions.not(ExpectedConditions.visibilityOfElementLocated(By.xpath(locator)))); + } catch (WebDriverException e) { + throw new AssertionError("Element is present"); + } + } + + public boolean elementsIsNotPresent(String locator) { + try { + return wait.until(ExpectedConditions.not(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(locator)))); + } catch (WebDriverException e) { + throw new AssertionError("Elements is present"); + } + } + + public void waitUntilNumberOfTabToBe(int tabNumber) { + try { + wait.until(ExpectedConditions.numberOfWindowsToBe(tabNumber)); + } catch (WebDriverException e) { + log.error("No tabs with this number"); + } + } + + public void goToNextTab(int tabNumber) { + waitUntilNumberOfTabToBe(tabNumber); + ArrayList tabs = new ArrayList<>(driver.getWindowHandles()); + driver.switchTo().window(tabs.get(tabNumber - 1)); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java new file mode 100644 index 0000000000..4e5d0d5ead --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java @@ -0,0 +1,74 @@ +package org.thingsboard.server.msa.ui.base; + +import io.github.bonigarcia.wdm.WebDriverManager; +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebDriverException; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Listeners; +import org.thingsboard.server.msa.TestListener; +import org.thingsboard.server.msa.ui.listeners.RetryTestListener; + +import java.time.Duration; + +@Slf4j +@Listeners({TestListener.class, RetryTestListener.class}) +abstract public class DiverBaseTest extends Base { + protected WebDriver driver; + + private final Dimension dimension = new Dimension(WIDTH, HEIGHT); + private static final int WIDTH = 1680; + private static final int HEIGHT = 1050; + private static final boolean HEADLESS = false; + + @BeforeMethod + public void openBrowser() { + log.info("*----------------------* Setup driver *----------------------*"); + if (HEADLESS == true) { + ChromeOptions options = new ChromeOptions(); + options.addArguments("--no-sandbox"); + options.addArguments("--disable-dev-shm-usage"); + options.addArguments("--headless"); + WebDriverManager.chromedriver().setup(); + driver = new ChromeDriver(options); + } else { + WebDriverManager.chromedriver().setup(); + driver = new ChromeDriver(); + } + driver.manage().window().setSize(dimension); + } + + @AfterMethod + public void closeBrowser() { + log.info("*----------------------* Teardown *----------------------*"); + driver.quit(); + } + + public void openUrl(String url) { + driver.get(url); + } + + public String getUrl() { + return driver.getCurrentUrl(); + } + + public WebDriver getDriver() { + return driver; + } + + protected boolean urlContains(String urlPath) { + WebDriverWait wait = new WebDriverWait(driver, Duration.ofMillis(10000)); + try { + wait.until(ExpectedConditions.urlContains(urlPath)); + } catch (WebDriverException e) { + log.error("This URL path is missing"); + } + return driver.getCurrentUrl().contains(urlPath); + } +} \ No newline at end of file diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java new file mode 100644 index 0000000000..30b157f13d --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java @@ -0,0 +1,20 @@ +package listeners; + +import org.testng.IRetryAnalyzer; +import org.testng.ITestResult; + +public class RetryAnalyzer implements IRetryAnalyzer { + + private int retryCount = 0; + private static final int MAX_RETRY_COUNT = 2; + + @Override + public boolean retry(ITestResult result) { + if (retryCount < MAX_RETRY_COUNT) { + System.out.printf("Retrying test %s for the %d time(s).%n", result.getName(), retryCount + 1); + retryCount++; + return true; + } + return false; + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryTestListener.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryTestListener.java new file mode 100644 index 0000000000..6083781820 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryTestListener.java @@ -0,0 +1,18 @@ +package listeners; + +import org.testng.IAnnotationTransformer; +import org.testng.annotations.ITestAnnotation; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; + +public class RetryTestListener implements IAnnotationTransformer { + + @Override + public void transform(ITestAnnotation annotation, + Class testClass, + Constructor testConstructor, + Method testMethod) { + annotation.setRetryAnalyzer(RetryAnalyzer.class); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java new file mode 100644 index 0000000000..dec83f374b --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java @@ -0,0 +1,62 @@ +package listeners; + +import base.Base; +import base.TestInit; +import io.qameta.allure.Allure; +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.WebDriver; +import org.testng.ITestContext; +import org.testng.ITestListener; +import org.testng.ITestResult; + +@Slf4j +public class TestListener extends Base implements ITestListener { + + WebDriver driver; + + public void onTestSuccess(ITestResult tr) { + String str = "Test " + tr.getMethod().getMethodName() + " success"; + log.info("*----------------------* " + str + " *----------------------*"); + Allure.getLifecycle().updateTestCase((t) -> { + t.setStatusDetails(t.getStatusDetails().setMessage(str)); + }); + driver = ((TestInit) tr.getInstance()).getDriver(); + captureScreen(driver, "success"); + } + + public void onTestFailure(ITestResult tr) { + String str = "Test " + tr.getMethod().getMethodName() + " failure"; + String str1 = "Failed because of - " + tr.getThrowable(); + log.info("*----------------------* " + str + " *----------------------*"); + log.info("*----------------------* " + str1 + " *----------------------*"); + Allure.getLifecycle().updateTestCase((t) -> { + t.setStatusDetails(t.getStatusDetails().setMessage(str)); + t.setStatusDetails(t.getStatusDetails().setMessage(str1)); + }); + driver = ((TestInit) tr.getInstance()).getDriver(); + captureScreen(driver, "failure"); + } + + public void onTestSkipped(ITestResult tr) { + String str = "Test " + tr.getMethod().getMethodName() + " skipped"; + String str1 = "Skipped because of - " + tr.getThrowable(); + log.info("*----------------------* " + str + " *----------------------*"); + log.info("*----------------------* " + str1 + " *----------------------*"); + Allure.getLifecycle().updateTestCase((t) -> { + t.setStatusDetails(t.getStatusDetails().setMessage(str)); + t.setStatusDetails(t.getStatusDetails().setMessage(str1)); + }); + driver = ((TestInit) tr.getInstance()).getDriver(); + captureScreen(driver, "skipped"); + } + + public void onStart(ITestContext testContext) { + String str = "Test " + testContext.getCurrentXmlTest().getName() + " start"; + log.info("*----------------------* " + str + " *----------------------*"); + } + + public void onFinish(ITestContext testContext) { + String str = "Test " + testContext.getCurrentXmlTest().getName() + " finish"; + log.info("*----------------------* " + str + " *----------------------*"); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java new file mode 100644 index 0000000000..dcb513ab71 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java @@ -0,0 +1,262 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; + +public class CustomerPageElementsAbstract extends OtherPageElementsHelperAbstract { + public CustomerPageElementsAbstract(WebDriver driver) { + super(driver); + } + + private static final String CUSTOMER = "//mat-row//span[contains(text(),'%s')]"; + private static final String EMAIL = ENTITY + "/../..//mat-cell[contains(@class,'email')]/span"; + private static final String COUNTRY = ENTITY + "/../..//mat-cell[contains(@class,'country')]/span"; + private static final String CITY = ENTITY + "/../..//mat-cell[contains(@class,'city')]/span"; + private static final String TITLES = "//mat-cell[contains(@class,'cdk-column-title')]/span"; + protected static final String EDIT_MENU_DASHBOARD_FIELD = "//input[@formcontrolname='dashboard']"; + private static final String EDIT_MENU_DASHBOARD = "//div[@class='cdk-overlay-pane']//span/span"; + private static final String MANAGE_CUSTOMERS_USERS_BTN = ENTITY + "/../..//mat-icon[contains(text(),' account_circle')]/../.."; + private static final String MANAGE_CUSTOMERS_ASSETS_BTN = ENTITY + "/../..//mat-icon[contains(text(),' domain')]/../.."; + private static final String MANAGE_CUSTOMERS_DEVICES_BTN = ENTITY + "/../..//mat-icon[contains(text(),' devices_other')]/../.."; + private static final String MANAGE_CUSTOMERS_DASHBOARDS_BTN = ENTITY + "/../..//mat-icon[contains(text(),' dashboard')]/../.."; + private static final String MANAGE_CUSTOMERS_EDGE_BTN = ENTITY + "/../..//mat-icon[contains(text(),' router')]/../.."; + private static final String ADD_USER_EMAIL = "//tb-add-user-dialog//input[@formcontrolname='email']"; + private static final String ACTIVATE_WINDOW_OK_BTN = "//span[contains(text(),'OK')]"; + private static final String USER_LOGIN_BTN = "//mat-icon[@data-mat-icon-name='login']"; + private static final String USERS_WIDGET = "//tb-widget"; + private static final String SELECT_COUNTRY_MENU = "//mat-form-field//mat-select[@formcontrolname='country']"; + private static final String COUNTRIES = "//span[@class='mat-option-text']"; + protected static final String INPUT_FIELD = "//input[@formcontrolname='%s']"; + protected static final String INPUT_FIELD_NAME_TITLE = "title"; + private static final String INPUT_FIELD_NAME_CITY = "city"; + private static final String INPUT_FIELD_NAME_STATE = "state"; + private static final String INPUT_FIELD_NAME_ZIP = "zip"; + private static final String INPUT_FIELD_NAME_ADDRESS = "address"; + private static final String INPUT_FIELD_NAME_ADDRESS2 = "address2"; + private static final String INPUT_FIELD_NAME_EMAIL = "email"; + private static final String INPUT_FIELD_NAME_NUMBER = "phoneNumber"; + private static final String INPUT_FIELD_NAME_ASSIGNED_LIST = "entity"; + private static final String ASSIGNED_BTN = "//button[@type='submit']"; + private static final String HIDE_HOME_DASHBOARD_TOOLBAR = "//mat-checkbox[@formcontrolname='homeDashboardHideToolbar']/label"; + private static final String FILTER_BTN = "//tb-filters-edit"; + private static final String TIME_BTN = "//tb-timewindow"; + private static final String CUSTOMER_ICON_HEADER = "//tb-breadcrumb//span[contains(text(),'Customer %s')]"; + private static final String CUSTOMER_USER_ICON_HEADER = "Users"; + private static final String CUSTOMER_ASSETS_ICON_HEADER = "Assets"; + private static final String CUSTOMER_DEVICES_ICON_HEADER = "Devices"; + private static final String CUSTOMER_DASHBOARD_ICON_HEADER = "Dashboards"; + private static final String CUSTOMER_EDGE_ICON_HEADER = "edge instances"; + private static final String CUSTOMER_USER_ICON_HEAD = "(//mat-drawer-content//span[contains(@class,'tb-entity-table')])[1]"; + private static final String MANAGE_BTN_VIEW = "//span[contains(text(),'%s')]"; + private static final String MANAGE_CUSTOMERS_USERS_BTN_VIEW = "Manage users"; + private static final String MANAGE_CUSTOMERS_ASSETS_BTN_VIEW = "Manage assets"; + private static final String MANAGE_CUSTOMERS_DEVICE_BTN_VIEW = "Manage devices"; + private static final String MANAGE_CUSTOMERS_DASHBOARD_BTN_VIEW = "Manage dashboards"; + private static final String MANAGE_CUSTOMERS_EDGE_BTN_VIEW = "Manage edges "; + + public WebElement titleFieldAddEntityView() { + return waitUntilElementToBeClickable(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_TITLE)); + } + + public WebElement titleFieldEntityView() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_TITLE)); + } + + public WebElement customer(String entityName) { + return waitUntilElementToBeClickable(String.format(CUSTOMER, entityName)); + } + + public WebElement email(String entityName) { + return waitUntilVisibilityOfElementLocated(String.format(EMAIL, entityName)); + } + + public WebElement country(String entityName) { + return waitUntilVisibilityOfElementLocated(String.format(COUNTRY, entityName)); + } + + public WebElement city(String entityName) { + return waitUntilVisibilityOfElementLocated(String.format(CITY, entityName)); + } + + public List entityTitles() { + return waitUntilVisibilityOfElementsLocated(TITLES); + } + + public WebElement editMenuDashboardField() { + return waitUntilVisibilityOfElementLocated(EDIT_MENU_DASHBOARD_FIELD); + } + + public WebElement editMenuDashboard() { + return waitUntilElementToBeClickable(EDIT_MENU_DASHBOARD); + } + + public WebElement phoneNumberEntityView() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_NUMBER)); + } + + public WebElement phoneNumberAddEntityView() { + return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_NUMBER)); + } + + public WebElement manageCustomersUserBtn(String title) { + return waitUntilElementToBeClickable(String.format(MANAGE_CUSTOMERS_USERS_BTN, title)); + } + + public WebElement manageCustomersAssetsBtn(String title) { + return waitUntilElementToBeClickable(String.format(MANAGE_CUSTOMERS_ASSETS_BTN, title)); + } + + public WebElement manageCustomersDevicesBtn(String title) { + return waitUntilElementToBeClickable(String.format(MANAGE_CUSTOMERS_DEVICES_BTN, title)); + } + + public WebElement manageCustomersDashboardsBtn(String title) { + return waitUntilElementToBeClickable(String.format(MANAGE_CUSTOMERS_DASHBOARDS_BTN, title)); + } + + public WebElement manageCustomersEdgeBtn(String title) { + return waitUntilElementToBeClickable(String.format(MANAGE_CUSTOMERS_EDGE_BTN, title)); + } + + public WebElement addUserEmailField() { + return waitUntilElementToBeClickable(ADD_USER_EMAIL); + } + + public WebElement activateWindowOkBtn() { + return waitUntilElementToBeClickable(ACTIVATE_WINDOW_OK_BTN); + } + + public WebElement userLoginBtn() { + return waitUntilElementToBeClickable(USER_LOGIN_BTN); + } + + public WebElement usersWidget() { + return waitUntilVisibilityOfElementLocated(USERS_WIDGET); + } + + public WebElement countrySelectMenuEntityView() { + return waitUntilElementToBeClickable(SELECT_COUNTRY_MENU); + } + + public WebElement countrySelectMenuAddEntityView() { + return waitUntilElementToBeClickable(ADD_ENTITY_VIEW + SELECT_COUNTRY_MENU); + } + + public List countries() { + return waitUntilElementsToBeClickable(COUNTRIES); + } + + public WebElement cityEntityView() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_CITY)); + } + + public WebElement cityAddEntityView() { + return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_CITY)); + } + + public WebElement stateEntityView() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_STATE)); + } + + public WebElement stateAddEntityView() { + return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_STATE)); + } + + public WebElement zipEntityView() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_ZIP)); + } + + public WebElement zipAddEntityView() { + return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_ZIP)); + } + + public WebElement addressEntityView() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_ADDRESS)); + } + + public WebElement addressAddEntityView() { + return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_ADDRESS)); + } + + public WebElement address2EntityView() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_ADDRESS2)); + } + + public WebElement address2AddEntityView() { + return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_ADDRESS2)); + } + + public WebElement emailEntityView() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_EMAIL)); + } + + public WebElement emailAddEntityView() { + return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_EMAIL)); + } + + public WebElement assignedField() { + return waitUntilVisibilityOfElementLocated(String.format(INPUT_FIELD, INPUT_FIELD_NAME_ASSIGNED_LIST)); + } + + public WebElement submitAssignedBtn() { + return waitUntilElementToBeClickable(ASSIGNED_BTN); + } + + public WebElement hideHomeDashboardToolbarCheckbox() { + return waitUntilElementToBeClickable(HIDE_HOME_DASHBOARD_TOOLBAR); + } + + public WebElement filterBtn() { + return waitUntilVisibilityOfElementLocated(FILTER_BTN); + } + + public WebElement timeBtn() { + return waitUntilVisibilityOfElementLocated(TIME_BTN); + } + + public WebElement customerUserIconHeader() { + return waitUntilVisibilityOfElementLocated(String.format(CUSTOMER_ICON_HEADER, CUSTOMER_USER_ICON_HEADER)); + } + + public WebElement customerAssetsIconHeader() { + return waitUntilVisibilityOfElementLocated(String.format(CUSTOMER_ICON_HEADER, CUSTOMER_ASSETS_ICON_HEADER)); + } + + public WebElement customerDevicesIconHeader() { + return waitUntilVisibilityOfElementLocated(String.format(CUSTOMER_ICON_HEADER, CUSTOMER_DEVICES_ICON_HEADER)); + } + + public WebElement customerDashboardIconHeader() { + return waitUntilVisibilityOfElementLocated(String.format(CUSTOMER_ICON_HEADER, CUSTOMER_DASHBOARD_ICON_HEADER)); + } + + public WebElement customerEdgeIconHeader() { + return waitUntilVisibilityOfElementLocated(String.format(CUSTOMER_ICON_HEADER, CUSTOMER_EDGE_ICON_HEADER)); + } + + public WebElement customerManageWindowIconHead() { + return waitUntilVisibilityOfElementLocated(CUSTOMER_USER_ICON_HEAD); + } + + public WebElement manageCustomersUserBtnView() { + return waitUntilElementToBeClickable(String.format(MANAGE_BTN_VIEW, MANAGE_CUSTOMERS_USERS_BTN_VIEW)); + } + + public WebElement manageCustomersAssetsBtnView() { + return waitUntilElementToBeClickable(String.format(MANAGE_BTN_VIEW, MANAGE_CUSTOMERS_ASSETS_BTN_VIEW)); + } + + public WebElement manageCustomersDeviceBtnView() { + return waitUntilElementToBeClickable(String.format(MANAGE_BTN_VIEW, MANAGE_CUSTOMERS_DEVICE_BTN_VIEW)); + } + + public WebElement manageCustomersDashboardsBtnView() { + return waitUntilElementToBeClickable(String.format(MANAGE_BTN_VIEW, MANAGE_CUSTOMERS_DASHBOARD_BTN_VIEW)); + } + + public WebElement manageCustomersEdgeBtnView() { + return waitUntilElementToBeClickable(String.format(MANAGE_BTN_VIEW, MANAGE_CUSTOMERS_EDGE_BTN_VIEW)); + } +} 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 new file mode 100644 index 0000000000..13d6a26077 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageHelper.java @@ -0,0 +1,161 @@ +package org.thingsboard.server.msa.ui.pages; + +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.thingsboard.server.common.data.Customer; +import org.thingsboard.server.common.data.page.PageData; + +import java.util.stream.Collectors; + +@Slf4j +public class CustomerPageHelperAbstract extends CustomerPageElementsAbstract { + public CustomerPageHelperAbstract(WebDriver driver) { + super(driver); + } + + private String customerName; + private String country; + private String dashboard; + private String dashboardFromView; + + private String customerEmail; + private String customerCountry; + private String customerCity; + + public void setCustomerName() { + this.customerName = entityTitles().get(0).getText(); + } + + public void setCustomerName(int number) { + this.customerName = entityTitles().get(number).getText(); + } + + public String getCustomerName() { + return customerName; + } + + public void setCountry() { + this.country = countries().get(0).getText(); + } + + public String getCountry() { + return country; + } + + public void setDashboard() { + this.dashboard = listOfEntity().get(0).getText(); + } + + public void setDashboardFromView() { + this.dashboardFromView = editMenuDashboardField().getAttribute("value"); + } + + public String getDashboard() { + return dashboard; + } + + public String getDashboardFromView() { + return dashboardFromView; + } + + public void setCustomerEmail(String title) { + this.customerEmail = email(title).getText(); + } + + public String getCustomerEmail() { + return customerEmail; + } + + public void setCustomerCountry(String title) { + this.customerCountry = country(title).getText(); + } + + public String getCustomerCountry() { + return customerCountry; + } + + public void setCustomerCity(String title) { + this.customerCity = city(title).getText(); + } + + public String getCustomerCity() { + return customerCity; + } + + public void createCustomer(String entityName) { + try { + PageData tenantCustomer; + tenantCustomer = client.getCustomers(pageLink); + Customer customer = new Customer(); + customer.setTitle(entityName); + client.saveCustomer(customer); + tenantCustomer.getData().add(customer); + } catch (Exception e) { + log.info("Can't create!"); + } + } + + public void deleteCustomer(String entityName) { + try { + PageData tenantRuleChains; + tenantRuleChains = client.getCustomers(pageLink); + try { + client.deleteCustomer(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(0).getId()); + } catch (Exception e) { + client.deleteCustomer(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(1).getId()); + } + } catch (Exception e) { + log.info("Can't delete!"); + } + } + + public void changeTitleEditMenu(String newTitle) { + titleFieldEntityView().clear(); + wait.until(ExpectedConditions.textToBe(By.xpath(String.format(INPUT_FIELD, INPUT_FIELD_NAME_TITLE)), "")); + titleFieldEntityView().sendKeys(newTitle); + } + + public void chooseDashboard() { + editMenuDashboardField().click(); + sleep(0.5); + editMenuDashboard().click(); + sleep(0.5); + } + + public void createCustomersUser() { + plusBtn().click(); + addUserEmailField().sendKeys(getRandomNumber() + "@gmail.com"); + addBtnC().click(); + activateWindowOkBtn().click(); + } + + public void selectCountryEntityView() { + countrySelectMenuEntityView().click(); + setCountry(); + countries().get(0).click(); + } + + public void selectCountryAddEntityView() { + countrySelectMenuAddEntityView().click(); + setCountry(); + countries().get(0).click(); + } + + public void assignedDashboard() { + plusBtn().click(); + assignedField().click(); + setDashboard(); + listOfEntity().get(0).click(); + submitAssignedBtn().click(); + } + + public boolean customerIsNotPresent(String title) { + return elementsIsNotPresent(getEntity(title)); + } + + public void sortByNameDown() { + doubleClick(sortByTitleBtn()); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageElements.java new file mode 100644 index 0000000000..9e2595ed3c --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageElements.java @@ -0,0 +1,38 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; + +public class DashboardPageElementsAbstract extends OtherPageElementsHelperAbstract { + public DashboardPageElementsAbstract(WebDriver driver) { + super(driver); + } + + private static final String TITLES = "//mat-cell[contains(@class,'cdk-column-title')]/span"; + private static final String ASSIGNED_BTN = ENTITY + "/../..//mat-icon[contains(text(),' assignment_ind')]/../.."; + private static final String MANAGE_ASSIGNED_ENTITY_LIST_FIELD = "//input[@formcontrolname='entity']"; + private static final String MANAGE_ASSIGNED_ENTITY = "//mat-option//span[contains(text(),'%s')]"; + private static final String MANAGE_ASSIGNED_UPDATE_BTN = "//button[@type='submit']"; + + public List entityTitles() { + return waitUntilVisibilityOfElementsLocated(TITLES); + } + + public WebElement assignedBtn(String title) { + return waitUntilElementToBeClickable(String.format(ASSIGNED_BTN, title)); + } + + public WebElement manageAssignedEntityListField() { + return waitUntilElementToBeClickable(MANAGE_ASSIGNED_ENTITY_LIST_FIELD); + } + + public WebElement manageAssignedEntity(String title) { + return waitUntilElementToBeClickable(String.format(MANAGE_ASSIGNED_ENTITY, title)); + } + + public WebElement manageAssignedUpdateBtn() { + return waitUntilElementToBeClickable(MANAGE_ASSIGNED_UPDATE_BTN); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageHelper.java new file mode 100644 index 0000000000..7bf8956542 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageHelper.java @@ -0,0 +1,25 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.WebDriver; + +public class DashboardPageHelperAbstract extends DashboardPageElementsAbstract { + public DashboardPageHelperAbstract(WebDriver driver) { + super(driver); + } + + private String dashboardTitle; + + public void setDashboardTitle() { + this.dashboardTitle = entityTitles().get(0).getText(); + } + + public String getDashboardTitle() { + return dashboardTitle; + } + + public void assignedCustomer(String title) { + manageAssignedEntityListField().click(); + manageAssignedEntity(title).click(); + manageAssignedUpdateBtn().click(); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageElements.java new file mode 100644 index 0000000000..54239e2971 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageElements.java @@ -0,0 +1,28 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.thingsboard.server.msa.ui.base.AbstractBasePage; + +public class LoginPageElementsAbstract extends AbstractBasePage { + public LoginPageElementsAbstract(WebDriver driver) { + super(driver); + } + + private static final String EMAIL_FIELD = "//input[@id='username-input']"; + private static final String PASSWORD_FIELD = "//input[@id='password-input']"; + private static final String SUBMIT_BTN = "//button[@type='submit']"; + + public WebElement emailField() { + return waitUntilElementToBeClickable(EMAIL_FIELD); + } + + public WebElement passwordField() { + return waitUntilElementToBeClickable(PASSWORD_FIELD); + } + + public WebElement submitBtn() { + return waitUntilElementToBeClickable(SUBMIT_BTN); + } + +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageHelper.java new file mode 100644 index 0000000000..a39b507882 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageHelper.java @@ -0,0 +1,16 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.WebDriver; +import org.thingsboard.server.msa.ui.utils.Const; + +public class LoginPageHelperAbstract extends LoginPageElementsAbstract { + public LoginPageHelperAbstract(WebDriver driver) { + super(driver); + } + + public void authorizationTenant() { + emailField().sendKeys(Const.TENANT_EMAIL); + passwordField().sendKeys(Const.TENANT_PASSWORD); + submitBtn().click(); + } +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageElements.java new file mode 100644 index 0000000000..521758ea41 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageElements.java @@ -0,0 +1,33 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.thingsboard.server.msa.ui.base.AbstractBasePage; + +public class OpenRuleChainPageElementsAbstract extends AbstractBasePage { + public OpenRuleChainPageElementsAbstract(WebDriver driver) { + super(driver); + } + + private static final String DONE_BTN = "//mat-icon[contains(text(),'done')]/../.."; + private static final String DONE_BTN_DISABLE = "//mat-icon[contains(text(),'done')]/../parent::button[@disabled='true']"; + private static final String INPUT_NODE = "//div[@class='tb-rule-node tb-input-type']"; + private static final String HEAD_RULE_CHAIN_NAME = "//div[@class='tb-breadcrumb']/span[2]"; + + public WebElement inputNode() { + return waitUntilVisibilityOfElementLocated(INPUT_NODE); + } + + public WebElement headRuleChainName() { + return waitUntilVisibilityOfElementLocated(HEAD_RULE_CHAIN_NAME); + } + + public String getDoneBtnDisable() { + return DONE_BTN_DISABLE; + } + + public WebElement doneBtn() { + return waitUntilElementToBeClickable(DONE_BTN); + } + +} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageHelper.java new file mode 100644 index 0000000000..ccaaedab28 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageHelper.java @@ -0,0 +1,23 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.WebDriver; + +public class OpenRuleChainPageHelperAbstract extends OpenRuleChainPageElementsAbstract { + public OpenRuleChainPageHelperAbstract(WebDriver driver) { + super(driver); + } + + private String headName; + + public void setHeadName() { + this.headName = headRuleChainName().getText().split(" ")[1]; + } + + public String getHeadName() { + return headName; + } + + public void waitUntilDoneBtnDisable() { + waitUntilVisibilityOfElementLocated(getDoneBtnDisable()); + } +} 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 new file mode 100644 index 0000000000..bf4be2dae2 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElements.java @@ -0,0 +1,228 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.thingsboard.server.msa.ui.base.AbstractBasePage; + +import java.util.List; + +public class OtherPageElementsAbstract extends AbstractBasePage { + public OtherPageElementsAbstract(WebDriver driver) { + super(driver); + } + + protected static final String ENTITY = "//mat-row//span[contains(text(),'%s')]"; + protected static final String DELETE_BTN = ENTITY + "/../..//mat-icon[contains(text(),' delete')]/../.."; + private static final String ENTITY_COUNT = "//div[@class='mat-paginator-range-label']"; + 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 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/../.."; + private static final String DELETE_BTNS = "//mat-icon[contains(text(),' delete')]/../.."; + private static final String MARKS_CHECKBOX = "//mat-row[contains (@class,'mat-selected')]//mat-checkbox[contains(@class, 'checked')]"; + private static final String SELECT_ALL_CHECKBOX = "//thead//mat-checkbox"; + private static final String ALL_ENTITY = "//mat-row[@class='mat-row cdk-row mat-row-select ng-star-inserted']"; + private static final String EDIT_PENCIL_BTN = "//mat-icon[contains(text(),'edit')]/ancestor::button"; + private static final String NAME_FIELD_EDIT_VIEW = "//input[@formcontrolname='name']"; + private static final String HEADER_NAME_VIEW = "//header//div[@class='tb-details-title']/span"; + private static final String DONE_BTN_EDIT_VIEW = "//mat-icon[contains(text(),'done')]/ancestor::button"; + private static final String DESCRIPTION_ENTITY_VIEW = "//textarea"; + private static final String DESCRIPTION_ADD_ENTITY_VIEW = "//tb-add-entity-dialog//textarea"; + private static final String DEBUG_CHECKBOX_EDIT = "//mat-checkbox[@formcontrolname='debugMode']"; + private static final String DEBUG_CHECKBOX_VIEW = "//mat-checkbox[@formcontrolname='debugMode']//input"; + private static final String CLOSE_ENTITY_VIEW_BTN = "//header//mat-icon[contains(text(),'close')]/../.."; + private static final String SEARCH_BTN = "//mat-toolbar//mat-icon[contains(text(),'search')]/.." + + "/parent::button[@class='mat-focus-indicator mat-tooltip-trigger mat-icon-button mat-button-base ng-star-inserted']"; + private static final String SORT_BY_NAME_BTN = "//div[contains(text(),'Name')]"; + private static final String SORT_BY_TITLE_BTN = "//div[contains(text(),'Title')]"; + private static final String SORT_BY_TIME_BTN = "//div[contains(text(),'Created time')]/.."; + private static final String CREATED_TIME = "//tbody[@role='rowgroup']//mat-cell[2]/span"; + private static final String PLUS_BTN = "//mat-icon[contains(text(),'add')]/../parent::button"; + private static final String CREATE_VIEW_ADD_BTN = "//span[contains(text(),'Add')]/.."; + private static final String WARNING_MESSAGE = "//tb-snack-bar-component/div/div"; + 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"; + 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')]"; + + public String getEntity(String entityName) { + return String.format(ENTITY, entityName); + } + + public String getWarningMessage() { + return WARNING_MESSAGE; + } + + public String getDeleteBtns() { + return DELETE_BTNS; + } + + public String getCheckbox(String entityName) { + return String.format(CHECKBOX, entityName); + } + + public String getCheckboxes() { + return String.format(CHECKBOXES); + } + + public WebElement warningPopUpYesBtn() { + return waitUntilElementToBeClickable(WARNING_DELETE_POPUP_YES); + } + + public WebElement warningPopUpTitle() { + return waitUntilElementToBeClickable(WARNING_DELETE_POPUP_TITLE); + } + + public WebElement entityCount() { + return waitUntilVisibilityOfElementLocated(ENTITY_COUNT); + } + + public WebElement refreshBtn() { + return waitUntilElementToBeClickable(REFRESH_BTN); + } + + public WebElement helpBtn() { + return waitUntilElementToBeClickable(HELP_BTN); + } + + public WebElement checkBox(String entityName) { + return waitUntilElementToBeClickable(String.format(CHECKBOX, entityName)); + } + + public WebElement deleteSelectedBtn() { + return waitUntilElementToBeClickable(DELETE_SELECTED_BTN); + } + + public WebElement selectAllCheckBox() { + return waitUntilElementToBeClickable(SELECT_ALL_CHECKBOX); + } + + public WebElement editPencilBtn() { + return waitUntilElementToBeClickable(EDIT_PENCIL_BTN); + } + + public WebElement nameFieldEditMenu() { + return waitUntilElementToBeClickable(NAME_FIELD_EDIT_VIEW); + } + + public WebElement headerNameView() { + return waitUntilVisibilityOfElementLocated(HEADER_NAME_VIEW); + } + + public WebElement doneBtnEditView() { + return waitUntilElementToBeClickable(DONE_BTN_EDIT_VIEW); + } + + public WebElement descriptionEntityView() { + return waitUntilVisibilityOfElementLocated(DESCRIPTION_ENTITY_VIEW); + } + + public WebElement descriptionAddEntityView() { + return waitUntilVisibilityOfElementLocated(DESCRIPTION_ADD_ENTITY_VIEW); + } + + public WebElement debugCheckboxEdit() { + return waitUntilElementToBeClickable(DEBUG_CHECKBOX_EDIT); + } + + public WebElement debugCheckboxView() { + return waitUntilVisibilityOfElementLocated(DEBUG_CHECKBOX_VIEW); + } + + public WebElement closeEntityViewBtn() { + return waitUntilElementToBeClickable(CLOSE_ENTITY_VIEW_BTN); + } + + public WebElement searchBtn() { + return waitUntilElementToBeClickable(SEARCH_BTN); + } + + public List deleteBtns() { + return waitUntilVisibilityOfElementsLocated(DELETE_BTNS); + } + + public List checkBoxes() { + return waitUntilElementsToBeClickable(CHECKBOXES); + } + + public List markCheckbox() { + return waitUntilVisibilityOfElementsLocated(MARKS_CHECKBOX); + } + + public List allEntity() { + return waitUntilVisibilityOfElementsLocated(ALL_ENTITY); + } + + public WebElement doneBtnEditViewVisible() { + return waitUntilVisibilityOfElementLocated(DONE_BTN_EDIT_VIEW); + } + + public WebElement sortByNameBtn() { + return waitUntilElementToBeClickable(SORT_BY_NAME_BTN); + } + + public WebElement sortByTitleBtn() { + return waitUntilElementToBeClickable(SORT_BY_TITLE_BTN); + } + + public WebElement sortByTimeBtn() { + return waitUntilElementToBeClickable(SORT_BY_TIME_BTN); + } + + public List createdTime() { + return waitUntilVisibilityOfElementsLocated(CREATED_TIME); + } + + public WebElement plusBtn() { + return waitUntilElementToBeClickable(PLUS_BTN); + } + + public WebElement addBtnC() { + return waitUntilElementToBeClickable(CREATE_VIEW_ADD_BTN); + } + + public WebElement addBtnV() { + return waitUntilVisibilityOfElementLocated(CREATE_VIEW_ADD_BTN); + } + + public WebElement warningMessage() { + return waitUntilVisibilityOfElementLocated(WARNING_MESSAGE); + } + + public WebElement deleteBtn(String entityName) { + return waitUntilVisibilityOfElementLocated(String.format(DELETE_BTN, entityName)); + } + + public WebElement entity(String entityName) { + return waitUntilElementToBeClickable(String.format(ENTITY, entityName)); + } + + public WebElement errorMessage() { + return waitUntilVisibilityOfElementLocated(ERROR_MESSAGE); + } + + public WebElement entityViewTitle() { + return waitUntilVisibilityOfElementLocated(ENTITY_VIEW_TITLE); + } + + public List listOfEntity() { + return waitUntilElementsToBeClickable(LIST_OF_ENTITY); + } + + public WebElement addEntityView() { + return waitUntilVisibilityOfElementLocated(ADD_ENTITY_VIEW); + } + + public WebElement stateController() { + return waitUntilVisibilityOfElementLocated(STATE_CONTROLLER); + } + + public WebElement searchField() { + return waitUntilElementToBeClickable(SEARCH_FIELD); + } +} 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 new file mode 100644 index 0000000000..dc4a41e9b9 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OtherPageElementsHelper.java @@ -0,0 +1,98 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; + +public class OtherPageElementsHelperAbstract extends OtherPageElementsAbstract { + public OtherPageElementsHelperAbstract(WebDriver driver) { + super(driver); + } + + private String headerName; + + public void setHeaderName() { + this.headerName = headerNameView().getText(); + } + + public String getHeaderName() { + return headerName; + } + + public boolean entityIsNotPresent(String entityName) { + return elementIsNotPresent(getEntity(entityName)); + } + + public void goToHelpPage() { + helpBtn().click(); + goToNextTab(2); + } + + public void clickOnCheckBoxes(int count) { + for (int i = 0; i < count; i++) { + checkBoxes().get(i).click(); + } + } + + public void changeNameEditMenu(String newName) { + nameFieldEditMenu().sendKeys(Keys.CONTROL + "a" + Keys.BACK_SPACE); + nameFieldEditMenu().sendKeys(newName); + } + + public void changeDescription(String newDescription) { + descriptionEntityView().sendKeys(Keys.CONTROL + "a" + Keys.BACK_SPACE); + descriptionEntityView().sendKeys(newDescription); + } + + public String deleteRuleChainTrash(String entityName) { + String s = ""; + if (deleteBtn(entityName) != null) { + deleteBtn(entityName).click(); + warningPopUpYesBtn().click(); + return entityName; + } else { + for (int i = 0; i < deleteBtns().size(); i++) { + if (deleteBtns().get(i).isEnabled()) { + deleteBtns().get(i).click(); + warningPopUpYesBtn().click(); + if (elementIsNotPresent(getWarningMessage())) { + s = driver.findElements(By.xpath(getDeleteBtns() + + "/../../../mat-cell/following-sibling::mat-cell/following-sibling::mat-cell[contains(@class,'cdk-column-name')]/span")).get(i).getText(); + break; + } + } + } + return s; + } + } + + public String deleteSelected(String entityName) { + String s = ""; + if (deleteBtn(entityName) != null) { + checkBox(entityName).click(); + deleteSelectedBtn().click(); + warningPopUpYesBtn().click(); + return entityName; + } else { + for (int i = 0; i < checkBoxes().size(); i++) { + if (checkBoxes().get(i).isDisplayed()) { + s = driver.findElements(By.xpath(getCheckboxes() + "/../../mat-cell/following-sibling::mat-cell/following-sibling::mat-cell[contains(@class,'cdk-column-name')]/span")).get(i).getText(); + checkBox(s).click(); + deleteSelectedBtn().click(); + warningPopUpYesBtn().click(); + if (elementIsNotPresent(getWarningMessage())) { + break; + } + } + } + return s; + } + } + + public void searchEntity(String namePath) { + searchBtn().click(); + searchField().sendKeys(namePath); + sleep(0.5); + } +} + 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 new file mode 100644 index 0000000000..4a378bb1c3 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageElements.java @@ -0,0 +1,113 @@ +package org.thingsboard.server.msa.ui.pages; + +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +import java.util.List; + +public class RuleChainsPageElementsAbstract extends OtherPageElementsHelperAbstract { + public RuleChainsPageElementsAbstract(WebDriver driver) { + super(driver); + } + + private static final String MAKE_ROOT_BTN = ENTITY + "/../..//mat-icon[contains(text(),' flag')]/../.."; + private static final String ROOT = ENTITY + "/../..//mat-icon[text() = 'check_box']"; + private static final String ROOT_DISABLE = ENTITY + "/../..//mat-icon[text() = 'check_box_outline_blank']"; + private static final String CREATED_TIME = ENTITY + "/../..//mat-cell/span[contains(text(),'%s')]"; + private static final String CREATE_RULE_CHAIN_BTN = "//span[contains(text(),'Create new rule chain')]"; + private static final String CREATE_RULE_CHAIN_NAME_FIELD = "//form[@class='ng-untouched ng-pristine ng-invalid']//input[@formcontrolname='name']"; + 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']"; + private static final String ALL_NAMES = "//mat-icon[contains(text(),'check')]/../../../mat-cell[contains(@class,'name')]/span"; + + public String getDeleteRuleChainFromViewBtn() { + return DELETE_RULE_CHAIN_FROM_VIEW_BTN; + } + + public WebElement makeRootBtn(String entityName) { + return waitUntilElementToBeClickable(String.format(MAKE_ROOT_BTN, entityName)); + } + + public List rootCheckBoxesEnable() { + return waitUntilVisibilityOfElementsLocated(ROOT_ACTIVE_CHECKBOXES); + } + + public WebElement rootCheckBoxEnable(String entityName) { + return waitUntilVisibilityOfElementLocated(String.format(ROOT, entityName)); + } + + public WebElement rootCheckBoxDisable(String entityName) { + return waitUntilVisibilityOfElementLocated(String.format(ROOT_DISABLE, entityName)); + } + + public WebElement createRuleChainBtn() { + return waitUntilElementToBeClickable(CREATE_RULE_CHAIN_BTN); + } + + public WebElement importRuleChainBtn() { + return waitUntilElementToBeClickable(IMPORT_RULE_CHAIN_BTN); + } + + public WebElement nameField() { + return waitUntilElementToBeClickable(CREATE_RULE_CHAIN_NAME_FIELD); + } + + public List notRootRuleChainsNames() { + return waitUntilVisibilityOfElementsLocated(RULE_CHAINS_NAMES_WITHOUT_ROOT); + } + + public WebElement deleteBtnFromView() { + 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)); + } + + public WebElement makeRootFromViewBtn() { + return waitUntilElementToBeClickable(MAKE_ROOT_FROM_VIEW); + } + + public List allNames() { + return waitUntilVisibilityOfElementsLocated(ALL_NAMES); + } + + public WebElement createdTimeEntity(String name, String time) { + return waitUntilElementToBeClickable(String.format(CREATED_TIME, name, time)); + } +} 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 new file mode 100644 index 0000000000..9d23660b11 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/RuleChainsPageHelper.java @@ -0,0 +1,180 @@ +package org.thingsboard.server.msa.ui.pages; + +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.testng.Assert; +import org.thingsboard.server.common.data.page.PageData; +import org.thingsboard.server.common.data.rule.RuleChain; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Random; +import java.util.stream.Collectors; + +@Slf4j +public class RuleChainsPageHelperAbstract extends RuleChainsPageElementsAbstract { + public RuleChainsPageHelperAbstract(WebDriver driver) { + super(driver); + } + + public void openCreateRuleChainView() { + plusBtn().click(); + createRuleChainBtn().click(); + } + + public void openImportRuleChainView() { + plusBtn().click(); + importRuleChainBtn().click(); + } + + private int getRandomNumberFromRuleChainsCount() { + Random random = new Random(); + return random.nextInt(notRootRuleChainsNames().size()); + } + + private String ruleChainName; + + public void setRuleChainNameWithoutRoot() { + this.ruleChainName = notRootRuleChainsNames().get(getRandomNumberFromRuleChainsCount()).getText(); + } + + public void setRuleChainNameWithoutRoot(int number) { + this.ruleChainName = notRootRuleChainsNames().get(number).getText(); + } + + public void setRuleChainName(int number) { + this.ruleChainName = allNames().get(number).getText(); + } + + public String getRuleChainName() { + return this.ruleChainName; + } + + public String getRuleChainId(String entityName) { + PageData tenantRuleChains; + tenantRuleChains = client.getRuleChains(pageLink); + return String.valueOf(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(0).getId()); + } + + public void deleteRuleChain(String entityName) { + try { + PageData tenantRuleChains; + tenantRuleChains = client.getRuleChains(pageLink); + try { + client.deleteRuleChain(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(0).getId()); + } catch (Exception e) { + client.deleteRuleChain(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(1).getId()); + } + } catch (Exception e) { + log.info("Can't delete!"); + } + } + + public void deleteAllRuleChain(String entityName) { + try { + PageData tenantRuleChains; + tenantRuleChains = client.getRuleChains(pageLink); + tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).forEach(x -> client.deleteRuleChain(x.getId())); + } catch (Exception e) { + log.info("Can't delete!"); + } + } + + public void createRuleChain(String entityName) { + try { + PageData tenantRuleChains; + tenantRuleChains = client.getRuleChains(pageLink); + RuleChain ruleChain = new RuleChain(); + ruleChain.setName(entityName); + client.saveRuleChain(ruleChain); + tenantRuleChains.getData().add(ruleChain); + } catch (Exception e) { + log.info("Can't create!"); + } + } + + public void makeRoot() { + try { + PageData tenantRuleChains; + tenantRuleChains = client.getRuleChains(pageLink); + tenantRuleChains.getData().stream().filter(s -> s.getName().equals("Root Rule Chain")).collect(Collectors.toList()).forEach(x -> client.setRootRuleChain(x.getId())); + } catch (Exception e) { + log.info("Can't make root!"); + } + } + + public void createRuleChains(String entityName, int count) { + try { + PageData tenantRuleChains; + tenantRuleChains = client.getRuleChains(pageLink); + RuleChain ruleChain = new RuleChain(); + for (int i = 0; i < count; i++) { + ruleChain.setName(entityName); + client.saveRuleChain(ruleChain); + tenantRuleChains.getData().add(ruleChain); + } + } catch (Exception e) { + log.info("Can't create!"); + } + } + + public String deleteRuleChainFromView(String ruleChainName) { + String s = ""; + if (deleteBtnFromView() != null) { + deleteBtnFromView().click(); + warningPopUpYesBtn().click(); + if (elementIsNotPresent(getWarningMessage())) { + return getEntity(ruleChainName); + } + } else { + for (int i = 0; i < notRootRuleChainsNames().size(); i++) { + notRootRuleChainsNames().get(i).click(); + if (deleteBtnFromView() != null) { + deleteBtnFromView().click(); + warningPopUpYesBtn().click(); + if (elementIsNotPresent(getWarningMessage())) { + s = notRootRuleChainsNames().get(i).getText(); + break; + } + } + } + } + return s; + } + + public void assertCheckBoxIsNotDisplayed(String entityName) { + wait.until(ExpectedConditions.elementToBeClickable(By.xpath("(//mat-checkbox)[2]"))); + Assert.assertFalse(driver.findElement(By.xpath(getCheckbox(entityName))).isDisplayed()); + } + + public void assertDeleteBtnInRootRuleChainIsNotDisplayed() { + Assert.assertFalse(driver.findElement(By.xpath(getDeleteRuleChainFromViewBtn())).isDisplayed()); + } + + public boolean ruleChainsIsNotPresent(String ruleChainName) { + return elementsIsNotPresent(getEntity(ruleChainName)); + } + + public void doubleClickOnRuleChain(String ruleChainName) { + doubleClick(entity(ruleChainName)); + } + + public void sortByNameDown() { + doubleClick(sortByNameBtn()); + } + + ArrayList sort; + + public void setSort() { + ArrayList createdTime = new ArrayList<>(); + createdTime().forEach(x -> createdTime.add(x.getText())); + Collections.sort(createdTime); + sort = createdTime; + } + + public ArrayList getSort() { + return sort; + } +} 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 new file mode 100644 index 0000000000..1e1484be7b --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/SideBarMenuViewElements.java @@ -0,0 +1,27 @@ +package pages; + +import base.BasePage; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; + +public class SideBarMenuViewElements extends BasePage { + public SideBarMenuViewElements(WebDriver driver) { + super(driver); + } + + 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']"; + + public WebElement ruleChainsBtn() { + return waitUntilElementToBeClickable(RULE_CHAINS_BTN); + } + + public WebElement customerBtn() { + return waitUntilElementToBeClickable(CUSTOMER_BTN); + } + + public WebElement dashboardBtn() { + return waitUntilElementToBeClickable(DASHBOARD_BTN); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000..c59b950862 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CreateCustomerTest.java @@ -0,0 +1,164 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.*; + +public class CreateCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private String customerName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @AfterMethod + public void delete() { + if (customerName != null) { + customerPage.deleteCustomer(customerName); + customerName = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description("Can click on Add after specifying the name (text/numbers /special characters)") + public void createCustomer() { + String customerName = ENTITY_NAME; + + sideBarMenuView.customerBtn().click(); + customerPage.plusBtn().click(); + customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.addBtnC().click(); + customerPage.refreshBtn().click(); + this.customerName = customerName; + + Assert.assertNotNull(customerPage.customer(customerName)); + Assert.assertTrue(customerPage.customer(customerName).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + public void createCustomerWithFullInformation() { + String customerName = ENTITY_NAME; + String text = "Text"; + String email = "email@mail.com"; + String number = "2015550123"; + + sideBarMenuView.customerBtn().click(); + customerPage.plusBtn().click(); + customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.selectCountryAddEntityView(); + customerPage.descriptionAddEntityView().sendKeys(text); + customerPage.cityAddEntityView().sendKeys(text); + customerPage.stateAddEntityView().sendKeys(text); + customerPage.zipAddEntityView().sendKeys(text); + customerPage.addressAddEntityView().sendKeys(text); + customerPage.address2AddEntityView().sendKeys(text); + customerPage.phoneNumberAddEntityView().sendKeys(number); + customerPage.emailAddEntityView().sendKeys(email); + customerPage.addBtnC().click(); + customerPage.setCustomerEmail(customerName); + customerPage.setCustomerCountry(customerName); + customerPage.setCustomerCity(customerName); + customerPage.entity(customerName).click(); + this.customerName = customerName; + + Assert.assertNotNull(customerPage.customer(customerName)); + Assert.assertEquals(customerPage.entityViewTitle().getText(), customerName); + Assert.assertEquals(customerPage.titleFieldEntityView().getAttribute("value"), customerName); + Assert.assertEquals(customerPage.countrySelectMenuEntityView().getText(), customerPage.getCountry()); + Assert.assertEquals(customerPage.descriptionEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.cityEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.stateEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.zipEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.addressEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.address2EntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.phoneNumberEntityView().getAttribute("value"), "+1" + number); + Assert.assertEquals(customerPage.emailEntityView().getAttribute("value"), email); + Assert.assertEquals(customerPage.getCustomerEmail(), email); + Assert.assertEquals(customerPage.getCustomerCountry(), customerPage.getCountry()); + Assert.assertEquals(customerPage.getCustomerCity(), text); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t add customer without the name (empty field or just space)") + public void createCustomerWithoutName() { + sideBarMenuView.customerBtn().click(); + customerPage.plusBtn().click(); + + Assert.assertFalse(customerPage.addBtnV().isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description() + public void createCustomerWithOnlySpace() { + sideBarMenuView.customerBtn().click(); + customerPage.plusBtn().click(); + customerPage.titleFieldAddEntityView().sendKeys(" "); + customerPage.addBtnC().click(); + + Assert.assertNotNull(customerPage.warningMessage()); + Assert.assertTrue(customerPage.warningMessage().isDisplayed()); + Assert.assertEquals(customerPage.warningMessage().getText(), EMPTY_CUSTOMER_MESSAGE); + Assert.assertNotNull(customerPage.addEntityView()); + Assert.assertTrue(customerPage.addEntityView().isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can't create a customer with the same name") + public void createCustomerSameName() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + String customerName = customerPage.getCustomerName(); + customerPage.plusBtn().click(); + customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.addBtnC().click(); + + Assert.assertNotNull(customerPage.warningMessage()); + Assert.assertTrue(customerPage.warningMessage().isDisplayed()); + Assert.assertEquals(customerPage.warningMessage().getText(), SAME_NAME_WARNING_CUSTOMER_MESSAGE); + Assert.assertNotNull(customerPage.addEntityView()); + Assert.assertTrue(customerPage.addEntityView().isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can click on Add after specifying the name (text/numbers /special characters)") + public void createCustomerWithoutRefresh() { + String customerName = ENTITY_NAME; + + sideBarMenuView.customerBtn().click(); + customerPage.plusBtn().click(); + customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.addBtnC().click(); + this.customerName = customerName; + + Assert.assertNotNull(customerPage.customer(customerName)); + Assert.assertTrue(customerPage.customer(customerName).isDisplayed()); + } + + @Test(priority = 40, groups = "smoke") + @Description("Question mark icon leads to rule chain documentation (PE)") + public void documentation() { + String urlPath = "docs/user-guide/ui/customers/"; + + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.customer(customerPage.getCustomerName()).click(); + customerPage.goToHelpPage(); + + Assert.assertTrue(urlContains(urlPath)); + } +} 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 new file mode 100644 index 0000000000..36297cbf3a --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/CustomerEditMenuTest.java @@ -0,0 +1,270 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.DashboardPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; +import org.thingsboard.server.msa.ui.utils.DataProviderCredential; + +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; +import static org.thingsboard.server.msa.ui.utils.Const.*; + +public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private DashboardPageHelperAbstract dashboardPage; + private String customerName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + dashboardPage = new DashboardPageHelperAbstract(driver); + } + + @AfterMethod + public void delete() { + if (customerName != null) { + customerPage.deleteCustomer(customerName); + customerName = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description("Can click by pencil icon and edit the title (change the title) and save the changes. All changes have been applied") + public void changeTitle() { + customerPage.createCustomer(ENTITY_NAME); + String title = "Changed" + getRandomNumber(); + + sideBarMenuView.customerBtn().click(); + customerPage.entityTitles().get(0).click(); + customerPage.setHeaderName(); + String titleBefore = customerPage.getHeaderName(); + customerPage.editPencilBtn().click(); + customerPage.changeTitleEditMenu(title); + customerPage.doneBtnEditView().click(); + customerPage.setHeaderName(); + String titleAfter = customerPage.getHeaderName(); + customerName = title; + + Assert.assertNotEquals(titleBefore, titleAfter); + Assert.assertEquals(titleAfter, title); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t delete the title and save changes") + public void deleteTitle() { + sideBarMenuView.customerBtn().click(); + customerPage.entityTitles().get(0).click(); + customerPage.editPencilBtn().click(); + customerPage.titleFieldEntityView().clear(); + + Assert.assertFalse(customerPage.doneBtnEditViewVisible().isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t save just a space in the title") + public void saveOnlyWithSpace() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.entityTitles().get(0).click(); + customerPage.editPencilBtn().click(); + customerPage.changeTitleEditMenu(" "); + customerPage.doneBtnEditView().click(); + customerPage.setHeaderName(); + + Assert.assertNotNull(customerPage.warningMessage()); + Assert.assertTrue(customerPage.warningMessage().isDisplayed()); + Assert.assertEquals(customerPage.warningMessage().getText(), EMPTY_CUSTOMER_MESSAGE); + Assert.assertEquals(customerPage.getCustomerName(), customerPage.getHeaderName()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can write/change/delete the descriptionEntityView and save the changes. All changes have been applied") + public void editDescription() { + String title = ENTITY_NAME; + customerPage.createCustomer(title); + String description = "Description"; + + 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.editPencilBtn().click(); + customerPage.changeDescription(""); + customerPage.doneBtnEditView().click(); + customerName = title; + + Assert.assertEquals(description, description1); + Assert.assertEquals(description + description, description2); + Assert.assertTrue(customerPage.descriptionEntityView().getAttribute("value").isEmpty()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void assignedDashboardFromDashboard() { + String title = ENTITY_NAME; + customerPage.createCustomer(title); + + sideBarMenuView.dashboardBtn().click(); + dashboardPage.setDashboardTitle(); + dashboardPage.assignedBtn(dashboardPage.getDashboardTitle()).click(); + dashboardPage.assignedCustomer(title); + sideBarMenuView.customerBtn().click(); + customerPage.entity(title).click(); + customerPage.editPencilBtn().click(); + customerPage.chooseDashboard(); + customerPage.doneBtnEditView().click(); + customerPage.setDashboardFromView(); + customerPage.closeEntityViewBtn().click(); + customerPage.manageCustomersUserBtn(title).click(); + customerPage.createCustomersUser(); + customerPage.userLoginBtn().click(); + customerName = title; + + Assert.assertNotNull(customerPage.usersWidget()); + Assert.assertTrue(customerPage.usersWidget().isDisplayed()); + Assert.assertEquals(customerPage.getDashboardFromView(), dashboardPage.getDashboardTitle()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void assignedDashboard() { + String title = ENTITY_NAME; + customerPage.createCustomer(title); + + sideBarMenuView.customerBtn().click(); + customerPage.manageCustomersDashboardsBtn(title).click(); + customerPage.assignedDashboard(); + sideBarMenuView.customerBtn().click(); + customerPage.entity(title).click(); + customerPage.editPencilBtn().click(); + customerPage.chooseDashboard(); + customerPage.doneBtnEditView().click(); + customerPage.setDashboardFromView(); + customerPage.closeEntityViewBtn().click(); + customerPage.manageCustomersUserBtn(title).click(); + customerPage.createCustomersUser(); + customerPage.userLoginBtn().click(); + customerName = title; + + Assert.assertNotNull(customerPage.usersWidget()); + Assert.assertTrue(customerPage.usersWidget().isDisplayed()); + Assert.assertEquals(customerPage.getDashboard(), customerPage.getDashboardFromView()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void assignedDashboardWithoutHide() { + String title = ENTITY_NAME; + customerPage.createCustomer(title); + + sideBarMenuView.customerBtn().click(); + customerPage.manageCustomersDashboardsBtn(title).click(); + customerPage.assignedDashboard(); + sideBarMenuView.customerBtn().click(); + customerPage.entity(title).click(); + customerPage.editPencilBtn().click(); + customerPage.chooseDashboard(); + customerPage.hideHomeDashboardToolbarCheckbox().click(); + customerPage.doneBtnEditView().click(); + customerPage.setDashboardFromView(); + customerPage.closeEntityViewBtn().click(); + customerPage.manageCustomersUserBtn(title).click(); + customerPage.createCustomersUser(); + customerPage.userLoginBtn().click(); + customerName = title; + + Assert.assertNotNull(customerPage.usersWidget()); + Assert.assertTrue(customerPage.usersWidget().isDisplayed()); + Assert.assertEquals(customerPage.getDashboard(), customerPage.getDashboardFromView()); + Assert.assertNotNull(customerPage.stateController()); + Assert.assertNotNull(customerPage.filterBtn()); + Assert.assertNotNull(customerPage.timeBtn()); + Assert.assertTrue(customerPage.stateController().isDisplayed()); + Assert.assertTrue(customerPage.filterBtn().isDisplayed()); + Assert.assertTrue(customerPage.timeBtn().isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description + public void addPhoneNumber() { + String title = ENTITY_NAME; + customerPage.createCustomer(title); + String number = "2015550123"; + + sideBarMenuView.customerBtn().click(); + customerPage.entityTitles().get(0).click(); + customerPage.editPencilBtn().click(); + customerPage.phoneNumberEntityView().sendKeys(number); + customerPage.doneBtnEditView().click(); + customerName = title; + + Assert.assertTrue(customerPage.phoneNumberEntityView().getAttribute("value").contains(number)); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "incorrectPhoneNumber") + @Description + public void addIncorrectPhoneNumber(String number) { + sideBarMenuView.customerBtn().click(); + customerPage.entityTitles().get(0).click(); + customerPage.editPencilBtn().click(); + customerPage.phoneNumberEntityView().sendKeys(number); + boolean doneBtnIsEnable = customerPage.doneBtnEditViewVisible().isEnabled(); + customerPage.doneBtnEditViewVisible().click(); + + Assert.assertFalse(doneBtnIsEnable); + Assert.assertNotNull(customerPage.errorMessage()); + Assert.assertTrue(customerPage.errorMessage().isDisplayed()); + Assert.assertEquals(customerPage.errorMessage().getText(), PHONE_NUMBER_ERROR_MESSAGE); + } + + @Test(priority = 30, groups = "smoke") + public void addAllInformation() { + String title = ENTITY_NAME; + customerPage.createCustomer(title); + String text = "Text"; + String email = "email@mail.com"; + String number = "2015550123"; + + sideBarMenuView.customerBtn().click(); + customerPage.entityTitles().get(0).click(); + customerPage.editPencilBtn().click(); + customerPage.selectCountryEntityView(); + customerPage.descriptionEntityView().sendKeys(text); + customerPage.cityEntityView().sendKeys(text); + customerPage.stateEntityView().sendKeys(text); + customerPage.zipEntityView().sendKeys(text); + customerPage.addressEntityView().sendKeys(text); + customerPage.address2EntityView().sendKeys(text); + customerPage.phoneNumberEntityView().sendKeys(number); + customerPage.emailEntityView().sendKeys(email); + customerPage.doneBtnEditView().click(); + customerName = title; + + Assert.assertEquals(customerPage.countrySelectMenuEntityView().getText(), customerPage.getCountry()); + Assert.assertEquals(customerPage.descriptionEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.cityEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.stateEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.zipEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.addressEntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.address2EntityView().getAttribute("value"), text); + Assert.assertEquals(customerPage.phoneNumberEntityView().getAttribute("value"), "+1" + number); + Assert.assertEquals(customerPage.emailEntityView().getAttribute("value"), email); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000..7a22422777 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteCustomerTest.java @@ -0,0 +1,83 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.URL; + +public class DeleteCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private RuleChainsPageHelperAbstract ruleChainsPage; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can remove the customer by clicking on the trash can icon in the right corner") + public void removeCustomerByRightSideBtn() { + String customer = ENTITY_NAME; + customerPage.createCustomer(customer); + + sideBarMenuView.customerBtn().click(); + String deletedCustomer = customerPage.deleteRuleChainTrash(customer); + customerPage.refreshBtn().click(); + + Assert.assertTrue(customerPage.entityIsNotPresent(deletedCustomer)); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can mark the customer in the checkbox and then click on the trash can icon in the menu that appears at the top") + public void removeSelectedCustomer() { + String customerName = ENTITY_NAME; + customerPage.createCustomer(customerName); + + sideBarMenuView.customerBtn().click(); + String deletedCustomer = customerPage.deleteSelected(customerName); + ruleChainsPage.refreshBtn().click(); + + Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedCustomer)); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can click on the name of the rule chain and click on the 'Delete customer' button") + public void removeFromCustomerView() { + String customerName = ENTITY_NAME; + customerPage.createCustomer(customerName); + + sideBarMenuView.customerBtn().click(); + customerPage.entity(customerName).click(); + String deletedCustomer = ruleChainsPage.deleteRuleChainFromView(customerName); + ruleChainsPage.refreshBtn().click(); + + Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedCustomer)); + } + + @Test(priority = 20, groups = "smoke") + @Description("The rule chain is deleted immediately after clicking remove (no need to refresh the page)") + public void removeCustomerByRightSideBtnWithoutRefresh() { + String customer = ENTITY_NAME; + customerPage.createCustomer(customer); + + sideBarMenuView.customerBtn().click(); + String deletedCustomer = customerPage.deleteRuleChainTrash(customer); + customerPage.refreshBtn().click(); + + Assert.assertTrue(customerPage.entityIsNotPresent(deletedCustomer)); + } +} 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 new file mode 100644 index 0000000000..9847f1b763 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/DeleteSeveralCustomerTest.java @@ -0,0 +1,81 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.URL; + +public class DeleteSeveralCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can mark several customers in the checkbox near the names and then click on the trash can icon in the menu that appears at the top") + public void canDeleteSeveralCustomersByTopBtn() { + String title1 = ENTITY_NAME + "1"; + String title2 = ENTITY_NAME + "2"; + int count = 2; + customerPage.createCustomer(title1); + customerPage.createCustomer(title2); + + sideBarMenuView.customerBtn().click(); + customerPage.clickOnCheckBoxes(count); + + Assert.assertEquals(customerPage.markCheckbox().size(), count); + customerPage.markCheckbox().forEach(x -> Assert.assertTrue(x.isDisplayed())); + + customerPage.deleteSelectedBtn().click(); + customerPage.warningPopUpYesBtn().click(); + customerPage.refreshBtn().click(); + + Assert.assertTrue(customerPage.customerIsNotPresent(title1)); + Assert.assertTrue(customerPage.customerIsNotPresent(title2)); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can mark several rule chains in the checkbox near the names and then click on the trash can icon in the menu that appears at the top") + public void selectAllCustomers() { + sideBarMenuView.customerBtn().click(); + customerPage.selectAllCheckBox().click(); + customerPage.deleteSelectedBtn().click(); + + Assert.assertNotNull(customerPage.warningPopUpTitle()); + Assert.assertTrue(customerPage.warningPopUpTitle().isDisplayed()); + Assert.assertTrue(customerPage.warningPopUpTitle().getText().contains(String.valueOf(customerPage.markCheckbox().size()))); + } + + @Test(priority = 30, groups = "smoke") + @Description("The rule chains are deleted immediately after clicking remove (no need to refresh the page)") + public void deleteSeveralCustomersByTopBtnWithoutRefresh() { + String title1 = ENTITY_NAME + "1"; + String title2 = ENTITY_NAME + "2"; + int count = 2; + customerPage.createCustomer(title1); + customerPage.createCustomer(title2); + + sideBarMenuView.customerBtn().click(); + customerPage.clickOnCheckBoxes(count); + + customerPage.deleteSelectedBtn().click(); + customerPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(customerPage.customerIsNotPresent(title1)); + Assert.assertTrue(customerPage.customerIsNotPresent(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 new file mode 100644 index 0000000000..785ee8c813 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersAssetsTest.java @@ -0,0 +1,54 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.URL; + +public class ManageCustomersAssetsAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private final String manage = "Assets"; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer assets' window by clicking on the 'Manage customer users' icon in the right corner") + public void openWindowByRightCornerBtn() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.manageCustomersAssetsBtn(customerPage.getCustomerName()).click(); + + Assert.assertTrue(urlContains(manage.toLowerCase())); + Assert.assertNotNull(customerPage.customerAssetsIconHeader()); + Assert.assertTrue(customerPage.customerAssetsIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(manage)); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Assets' window by clicking on the name/row of the customer and click on the 'Manage users' button") + public void openWindowByView() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.entity(customerPage.getCustomerName()).click(); + customerPage.manageCustomersAssetsBtnView().click(); + + Assert.assertTrue(urlContains(manage.toLowerCase())); + Assert.assertNotNull(customerPage.customerAssetsIconHeader()); + Assert.assertTrue(customerPage.customerAssetsIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(manage)); + } +} 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 new file mode 100644 index 0000000000..68fe281d0b --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDashboardsTest.java @@ -0,0 +1,53 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.URL; + +public class ManageCustomersDashboardsAbstractDiverBaseTest extends AbstractDiverBaseTest { + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private final String manage = "Dashboards"; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Dashboards' window by clicking on the 'Manage customer users' icon in the right corner") + public void openWindowByRightCornerBtn() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.manageCustomersDashboardsBtn(customerPage.getCustomerName()).click(); + + Assert.assertTrue(urlContains(manage.toLowerCase())); + Assert.assertNotNull(customerPage.customerDashboardIconHeader()); + Assert.assertTrue(customerPage.customerDashboardIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(manage)); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Dashboards' window by clicking on the name/row of the customer and click on the 'Manage users' button") + public void openWindowByView() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.entity(customerPage.getCustomerName()).click(); + customerPage.manageCustomersDashboardsBtnView().click(); + + Assert.assertTrue(urlContains(manage.toLowerCase())); + Assert.assertNotNull(customerPage.customerDashboardIconHeader()); + Assert.assertTrue(customerPage.customerDashboardIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(manage)); + } +} 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 new file mode 100644 index 0000000000..d62b5fe4cf --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersDevicesTest.java @@ -0,0 +1,53 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.URL; + +public class ManageCustomersDevicesAbstractDiverBaseTest extends AbstractDiverBaseTest { + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private final String manage = "Devices"; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Devices' window by clicking on the 'Manage customer users' icon in the right corner") + public void openWindowByRightCornerBtn() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.manageCustomersDevicesBtn(customerPage.getCustomerName()).click(); + + Assert.assertTrue(urlContains(manage.toLowerCase())); + Assert.assertNotNull(customerPage.customerDevicesIconHeader()); + Assert.assertTrue(customerPage.customerDevicesIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(manage)); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Devices' window by clicking on the name/row of the customer and click on the 'Manage users' button") + public void openWindowByView() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.entity(customerPage.getCustomerName()).click(); + customerPage.manageCustomersDeviceBtnView().click(); + + Assert.assertTrue(urlContains(manage.toLowerCase())); + Assert.assertNotNull(customerPage.customerDevicesIconHeader()); + Assert.assertTrue(customerPage.customerDevicesIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(manage)); + } +} 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 new file mode 100644 index 0000000000..ff0ac3e4f1 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersEdgesTest.java @@ -0,0 +1,54 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.URL; + +public class ManageCustomersEdgesAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private String iconText = "Edge instances"; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Edges' window by clicking on the 'Manage customer users' icon in the right corner") + public void openWindowByRightCornerBtn() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.manageCustomersEdgeBtn(customerPage.getCustomerName()).click(); + + Assert.assertTrue(urlContains("edgeInstances")); + Assert.assertNotNull(customerPage.customerEdgeIconHeader()); + Assert.assertTrue(customerPage.customerEdgeIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(iconText)); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Edges' window by clicking on the name/row of the customer and click on the 'Manage users' button") + public void openWindowByView() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.entity(customerPage.getCustomerName()).click(); + customerPage.manageCustomersEdgeBtnView().click(); + + Assert.assertTrue(urlContains("edgeInstances")); + Assert.assertNotNull(customerPage.customerEdgeIconHeader()); + Assert.assertTrue(customerPage.customerEdgeIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(iconText)); + } +} 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 new file mode 100644 index 0000000000..855e227b5e --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/ManageCustomersUsersTest.java @@ -0,0 +1,54 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.URL; + +public class ManageCustomersUsersAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private String iconText = "Customer Users"; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Users' window by clicking on the 'Manage customer users' icon in the right corner") + public void openWindowByRightCornerBtn() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.manageCustomersUserBtn(customerPage.getCustomerName()).click(); + + Assert.assertTrue(urlContains("user")); + Assert.assertNotNull(customerPage.customerUserIconHeader()); + Assert.assertTrue(customerPage.customerUserIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(iconText)); + } + + @Test(groups = "smoke") + @Description("Can go to the 'Customer Users' window by clicking on the name/row of the customer and click on the 'Manage users' button") + public void openWindowByView() { + sideBarMenuView.customerBtn().click(); + customerPage.setCustomerName(); + customerPage.entity(customerPage.getCustomerName()).click(); + customerPage.manageCustomersUserBtnView().click(); + + Assert.assertTrue(urlContains("user")); + Assert.assertNotNull(customerPage.customerUserIconHeader()); + Assert.assertTrue(customerPage.customerUserIconHeader().isDisplayed()); + Assert.assertTrue(customerPage.customerManageWindowIconHead().getText().contains(iconText)); + } +} 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 new file mode 100644 index 0000000000..6db022da62 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SearchCustomerTest.java @@ -0,0 +1,56 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.URL; + +public class SearchCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private String entityName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @AfterMethod + public void deleteCustomer() { + customerPage.deleteCustomer(entityName); + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "customerNameForSearchByFirstAndSecondWord") + @Description("Can search by the first/second word of the name") + public void searchFirstWord(String namePath) { + sideBarMenuView.customerBtn().click(); + customerPage.searchEntity(namePath); + + customerPage.allEntity().forEach(x -> Assert.assertTrue(x.getText().contains(namePath))); + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSearchBySymbolAndNumber") + @Description("Can search by number/symbol") + public void searchNumber(String name, String namePath) { + customerPage.createCustomer(name); + + sideBarMenuView.customerBtn().click(); + customerPage.searchEntity(namePath); + customerPage.setCustomerName(); + entityName = name; + + Assert.assertTrue(customerPage.getCustomerName().contains(namePath)); + } +} 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 new file mode 100644 index 0000000000..8ab49b6c68 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/customerSmoke/SortByNameTest.java @@ -0,0 +1,121 @@ +package org.thingsboard.server.msa.ui.tests.customerSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.URL; + +public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { + private SideBarMenuViewElements sideBarMenuView; + private CustomerPageHelperAbstract customerPage; + private String customerName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + customerPage = new CustomerPageHelperAbstract(driver); + } + + @AfterMethod + public void delete() { + if (customerName != null) { + customerPage.deleteCustomer(customerName); + customerName = null; + } + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") + @Description + public void specialCharacterUp(String title) { + customerPage.createCustomer(title); + + sideBarMenuView.customerBtn().click(); + customerPage.sortByTitleBtn().click(); + customerPage.setCustomerName(); + customerName = title; + + Assert.assertEquals(customerPage.getCustomerName(), title); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") + @Description + public void allSortUp(String customer, String customerSymbol, String customerNumber) { + customerPage.createCustomer(customerSymbol); + customerPage.createCustomer(customer); + customerPage.createCustomer(customerNumber); + + sideBarMenuView.customerBtn().click(); + customerPage.sortByTitleBtn().click(); + customerPage.setCustomerName(0); + String firstCustomer = customerPage.getCustomerName(); + customerPage.setCustomerName(1); + String secondCustomer = customerPage.getCustomerName(); + customerPage.setCustomerName(2); + String thirdCustomer = customerPage.getCustomerName(); + + boolean firstEquals = firstCustomer.equals(customerSymbol); + boolean secondEquals = secondCustomer.equals(customerNumber); + boolean thirdEquals = thirdCustomer.equals(customer); + + customerPage.deleteCustomer(customer); + customerPage.deleteCustomer(customerNumber); + customerPage.deleteCustomer(customerSymbol); + + Assert.assertTrue(firstEquals); + Assert.assertTrue(secondEquals); + Assert.assertTrue(thirdEquals); + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") + @Description + public void specialCharacterDown(String title) { + customerPage.createCustomer(title); + + sideBarMenuView.customerBtn().click(); + customerPage.sortByNameDown(); + customerPage.setCustomerName(customerPage.allEntity().size() - 1); + customerName = title; + + Assert.assertEquals(customerPage.getCustomerName(), title); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") + @Description + public void allSortDown(String customer, String customerSymbol, String customerNumber) { + customerPage.createCustomer(customerSymbol); + customerPage.createCustomer(customer); + customerPage.createCustomer(customerNumber); + + sideBarMenuView.customerBtn().click(); + int lastIndex = customerPage.allEntity().size() - 1; + customerPage.sortByNameDown(); + customerPage.setCustomerName(lastIndex); + String firstCustomer = customerPage.getCustomerName(); + customerPage.setCustomerName(lastIndex - 1); + String secondCustomer = customerPage.getCustomerName(); + customerPage.setCustomerName(lastIndex - 2); + String thirdCustomer = customerPage.getCustomerName(); + + boolean firstEquals = firstCustomer.equals(customerSymbol); + boolean secondEquals = secondCustomer.equals(customerNumber); + boolean thirdEquals = thirdCustomer.equals(customer); + + customerPage.deleteCustomer(customer); + customerPage.deleteCustomer(customerNumber); + customerPage.deleteCustomer(customerSymbol); + + Assert.assertTrue(firstEquals); + Assert.assertTrue(secondEquals); + Assert.assertTrue(thirdEquals); + } +} 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 new file mode 100644 index 0000000000..2b05fb8867 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainImportTest.java @@ -0,0 +1,110 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.*; + +public class CreateRuleChainImportAbstractDiverBaseTest extends AbstractDiverBaseTest { + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + private OpenRuleChainPageHelperAbstract openRuleChainPage; + private final String absolutePathToFileImportRuleChain = getClass().getClassLoader().getResource(IMPORT_RULE_CHAIN_FILE_NAME).getPath(); + private final String absolutePathToFileImportTxt = getClass().getClassLoader().getResource(IMPORT_TXT_FILE_NAME).getPath(); + private String ruleChainName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + openRuleChainPage = new OpenRuleChainPageHelperAbstract(driver); + } + + @AfterMethod + public void delete() { + if (ruleChainName != null) { + ruleChainsPage.deleteRuleChain(ruleChainName); + ruleChainName = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description("Can drop a JSON file and import it") + public void importRuleChain() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openImportRuleChainView(); + ruleChainsPage.browseFile().sendKeys(absolutePathToFileImportRuleChain); + + Assert.assertNotNull(ruleChainsPage.importingFile(IMPORT_RULE_CHAIN_FILE_NAME)); + Assert.assertTrue(ruleChainsPage.importingFile(IMPORT_RULE_CHAIN_FILE_NAME).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can delete a file by clicking on the icon Remove") + public void importRuleChainAndDeleteFile() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openImportRuleChainView(); + ruleChainsPage.browseFile().sendKeys(absolutePathToFileImportRuleChain); + ruleChainsPage.clearImportFileBtn().click(); + + Assert.assertNotNull(ruleChainsPage.importingFile(EMPTY_IMPORT_MESSAGE)); + Assert.assertTrue(ruleChainsPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed()); + Assert.assertTrue(ruleChainsPage.entityIsNotPresent(IMPORT_TXT_FILE_NAME)); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t Select / drop a file of a different format than JSON") + public void importTxtFile() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openImportRuleChainView(); + ruleChainsPage.browseFile().sendKeys(absolutePathToFileImportTxt); + + Assert.assertNotNull(ruleChainsPage.importingFile(EMPTY_IMPORT_MESSAGE)); + Assert.assertTrue(ruleChainsPage.importingFile(EMPTY_IMPORT_MESSAGE).isDisplayed()); + } + + @Test(priority = 30, groups = "smoke") + @Description("After clicking on Import - imported rule chain opens (need to save by clicking on the Apply changes icon)") + public void importRuleChainAndSave() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openImportRuleChainView(); + ruleChainsPage.browseFile().sendKeys(absolutePathToFileImportRuleChain); + ruleChainsPage.importBrowseFileBtn().click(); + openRuleChainPage.doneBtn().click(); + openRuleChainPage.waitUntilDoneBtnDisable(); + sideBarMenuView.ruleChainsBtn().click(); + ruleChainName = IMPORT_RULE_CHAIN_NAME; + + Assert.assertNotNull(ruleChainsPage.entity(IMPORT_RULE_CHAIN_NAME)); + Assert.assertTrue(ruleChainsPage.entity(IMPORT_RULE_CHAIN_NAME).isDisplayed()); + } + + @Test(priority = 40, groups = "smoke") + @Description("Can create a rule chain with the same name") + public void importRuleChainAndSaveWithSameName() { + ruleChainsPage.createRuleChain(IMPORT_RULE_CHAIN_NAME); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openImportRuleChainView(); + ruleChainsPage.browseFile().sendKeys(absolutePathToFileImportRuleChain); + ruleChainsPage.importBrowseFileBtn().click(); + openRuleChainPage.doneBtn().click(); + openRuleChainPage.waitUntilDoneBtnDisable(); + sideBarMenuView.ruleChainsBtn().click(); + boolean sizeBigger1 = ruleChainsPage.entities(IMPORT_RULE_CHAIN_NAME).size() > 1; + + ruleChainsPage.deleteAllRuleChain(IMPORT_RULE_CHAIN_NAME); + + Assert.assertTrue(sizeBigger1); + } +} 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 new file mode 100644 index 0000000000..32470c86f9 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/CreateRuleChainTest.java @@ -0,0 +1,139 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.*; + +public class CreateRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + private String ruleChainName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @AfterMethod + public void delete() { + if (ruleChainName != null) { + ruleChainsPage.deleteRuleChain(ruleChainName); + ruleChainName = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description("Can click on Add after specifying the name (text/numbers /special characters)") + public void createRuleChain() { + String ruleChainName = ENTITY_NAME; + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openCreateRuleChainView(); + ruleChainsPage.nameField().sendKeys(ruleChainName); + ruleChainsPage.addBtnC().click(); + ruleChainsPage.refreshBtn().click(); + this.ruleChainName = ruleChainName; + + Assert.assertNotNull(ruleChainsPage.entity(ruleChainName)); + Assert.assertTrue(ruleChainsPage.entity(ruleChainName).isDisplayed()); + } + + @Test(priority = 10, groups = "smoke") + @Description() + public void createRuleChainWithDescription() { + String ruleChainName = ENTITY_NAME; + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openCreateRuleChainView(); + ruleChainsPage.nameField().sendKeys(ruleChainName); + ruleChainsPage.descriptionAddEntityView().sendKeys(ENTITY_NAME); + ruleChainsPage.addBtnC().click(); + ruleChainsPage.refreshBtn().click(); + ruleChainsPage.entity(ENTITY_NAME).click(); + ruleChainsPage.setHeaderName(); + this.ruleChainName = ruleChainName; + + Assert.assertEquals(ruleChainsPage.getHeaderName(), ruleChainName); + Assert.assertEquals(ruleChainsPage.descriptionEntityView().getAttribute("value"), ruleChainName); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t add rule chain without the name (empty field or just space)") + public void createRuleChainWithoutName() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openCreateRuleChainView(); + + Assert.assertFalse(ruleChainsPage.addBtnV().isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description() + public void createRuleChainWithOnlySpace() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openCreateRuleChainView(); + ruleChainsPage.nameField().sendKeys(" "); + ruleChainsPage.addBtnC().click(); + + Assert.assertNotNull(ruleChainsPage.warningMessage()); + Assert.assertTrue(ruleChainsPage.warningMessage().isDisplayed()); + Assert.assertEquals(ruleChainsPage.warningMessage().getText(), EMPTY_RULE_CHAIN_MESSAGE); + Assert.assertNotNull(ruleChainsPage.addEntityView()); + Assert.assertTrue(ruleChainsPage.addEntityView().isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can create a rule chain with the same name") + public void createRuleChainWithSameName() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setRuleChainNameWithoutRoot(); + ruleChainsPage.openCreateRuleChainView(); + String ruleChainName = ruleChainsPage.getRuleChainName(); + ruleChainsPage.nameField().sendKeys(ruleChainName); + ruleChainsPage.addBtnC().click(); + ruleChainsPage.refreshBtn().click(); + this.ruleChainName = ruleChainName; + + Assert.assertNotNull(ruleChainsPage.entity(ruleChainName)); + Assert.assertTrue(ruleChainsPage.entities(ruleChainName).size() > 1); + } + + @Test(priority = 30, groups = "smoke") + @Description("After clicking on Add - appears immediately in the list (no need to refresh the page)") + public void createRuleChainWithoutRefresh() { + String ruleChainName = ENTITY_NAME; + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.openCreateRuleChainView(); + ruleChainsPage.nameField().sendKeys(ruleChainName); + ruleChainsPage.addBtnC().click(); + this.ruleChainName = ruleChainName; + + Assert.assertNotNull(ruleChainsPage.entity(ruleChainName)); + Assert.assertTrue(ruleChainsPage.entity(ruleChainName).isDisplayed()); + } + + @Test(priority = 40, groups = "smoke") + @Description("Question mark icon leads to rule chain documentation (PE)") + public void documentation() { + String urlPath = "docs/user-guide/ui/rule-chains/"; + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setRuleChainNameWithoutRoot(); + ruleChainsPage.entity(ruleChainsPage.getRuleChainName()).click(); + ruleChainsPage.goToHelpPage(); + + Assert.assertTrue(urlContains(urlPath)); + } +} 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 new file mode 100644 index 0000000000..f2fe8c7c1c --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteRuleChainTest.java @@ -0,0 +1,148 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.*; + +public class DeleteRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can remove the rule chain by clicking on the trash can icon in the right corner") + public void removeRuleChainByRightSideBtn() { + ruleChainsPage.createRuleChain(ENTITY_NAME); + + sideBarMenuView.ruleChainsBtn().click(); + String deletedRuleChain = ruleChainsPage.deleteRuleChainTrash(ENTITY_NAME); + ruleChainsPage.refreshBtn().click(); + + Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedRuleChain)); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can mark the rule chain in the checkbox and then click on the trash can icon in the menu that appears at the top") + public void removeSelectedRuleChain() { + String ruleChainName = ENTITY_NAME; + ruleChainsPage.createRuleChain(ruleChainName); + + sideBarMenuView.ruleChainsBtn().click(); + String deletedRuleChain = ruleChainsPage.deleteSelected(ruleChainName); + ruleChainsPage.refreshBtn().click(); + + Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedRuleChain)); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can click on the name of the rule chain and click on the 'Delete rule chain' button") + public void removeFromRuleChainView() { + ruleChainsPage.createRuleChain(ENTITY_NAME); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.entity(ENTITY_NAME).click(); + String deletedRuleChain = ruleChainsPage.deleteRuleChainFromView(ENTITY_NAME); + ruleChainsPage.refreshBtn().click(); + + Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedRuleChain)); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t remove Root Rule Chain (the trash can is disabled in the right corner)") + public void removeRootRuleChain() { + sideBarMenuView.ruleChainsBtn().click(); + + Assert.assertFalse(ruleChainsPage.deleteBtn(ROOT_RULE_CHAIN_NAME).isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t remove Root Rule Chain (can`t mark the rule chain in the checkbox )") + public void removeSelectedRootRuleChain() { + sideBarMenuView.ruleChainsBtn().click(); + + ruleChainsPage.assertCheckBoxIsNotDisplayed(ROOT_RULE_CHAIN_NAME); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t remove Root Rule Chain (missing delete button)") + public void removeFromRootRuleChainView() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.entity(ROOT_RULE_CHAIN_NAME).click(); + ruleChainsPage.deleteBtnFromView(); + + ruleChainsPage.assertDeleteBtnInRootRuleChainIsNotDisplayed(); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can remove the rule chain by clicking on the trash can icon in the right corner") + public void removeProfileRuleChainByRightSideBtn() { + String deletedRuleChain = "Thermostat"; + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.deleteBtn(deletedRuleChain).click(); + ruleChainsPage.warningPopUpYesBtn().click(); + ruleChainsPage.refreshBtn().click(); + + Assert.assertNotNull(ruleChainsPage.entity(deletedRuleChain)); + Assert.assertTrue(ruleChainsPage.entity(deletedRuleChain).isDisplayed()); + Assert.assertNotNull(ruleChainsPage.warningMessage()); + Assert.assertTrue(ruleChainsPage.warningMessage().isDisplayed()); + Assert.assertEquals(ruleChainsPage.warningMessage().getText(), DELETE_RULE_CHAIN_WITH_PROFILE_MESSAGE); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can mark the rule chain in the checkbox and then click on the trash can icon in the menu that appears at the top") + public void removeSelectedProfileRuleChain() { + sideBarMenuView.ruleChainsBtn().click(); + String deletedRuleChain = ruleChainsPage.deleteSelected("Thermostat"); + ruleChainsPage.refreshBtn().click(); + + Assert.assertNotNull(ruleChainsPage.entity(deletedRuleChain)); + Assert.assertTrue(ruleChainsPage.entity(deletedRuleChain).isDisplayed()); + Assert.assertNotNull(ruleChainsPage.warningMessage()); + Assert.assertTrue(ruleChainsPage.warningMessage().isDisplayed()); + Assert.assertEquals(ruleChainsPage.warningMessage().getText(), DELETE_RULE_CHAIN_WITH_PROFILE_MESSAGE); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can click on the name of the rule chain and click on the 'Delete rule chain' button") + public void removeFromProfileRuleChainView() { + String deletedRuleChain = "Thermostat"; + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.entity(deletedRuleChain).click(); + ruleChainsPage.deleteBtnFromView().click(); + ruleChainsPage.warningPopUpYesBtn().click(); + + Assert.assertNotNull(ruleChainsPage.entity(deletedRuleChain)); + Assert.assertNotNull(ruleChainsPage.warningMessage()); + Assert.assertTrue(ruleChainsPage.warningMessage().isDisplayed()); + Assert.assertEquals(ruleChainsPage.warningMessage().getText(), DELETE_RULE_CHAIN_WITH_PROFILE_MESSAGE); + } + + @Test(priority = 30, groups = "smoke") + @Description("The rule chain is deleted immediately after clicking remove (no need to refresh the page)") + public void removeRuleChainByRightSideBtnWithoutRefresh() { + String ruleChainName = ENTITY_NAME; + ruleChainsPage.createRuleChain(ruleChainName); + + sideBarMenuView.ruleChainsBtn().click(); + String deletedRuleChain = ruleChainsPage.deleteRuleChainTrash(ruleChainName); + + Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedRuleChain)); + } +} 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 new file mode 100644 index 0000000000..8481d9cde6 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/DeleteSeveralRuleChainsTest.java @@ -0,0 +1,92 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.*; + +public class DeleteSeveralRuleChainsAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can mark several rule chains in the checkbox near the names and then click on the trash can icon in the menu that appears at the top") + public void canDeleteSeveralRuleChainsByTopBtn() { + String ruleChainName = ENTITY_NAME; + int count = 2; + ruleChainsPage.createRuleChains(ruleChainName, count); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.clickOnCheckBoxes(count); + + ruleChainsPage.deleteSelectedBtn().click(); + ruleChainsPage.warningPopUpYesBtn().click(); + ruleChainsPage.refreshBtn().click(); + + Assert.assertTrue(ruleChainsPage.ruleChainsIsNotPresent(ruleChainName)); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can mark several rule chains in the checkbox near the names and then click on the trash can icon in the menu that appears at the top") + public void selectAllRuleChain() { + String ruleChainName = ENTITY_NAME; + int count = 2; + ruleChainsPage.createRuleChains(ruleChainName, count); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.selectAllCheckBox().click(); + ruleChainsPage.deleteSelectedBtn().click(); + ruleChainsPage.warningPopUpYesBtn().click(); + ruleChainsPage.refreshBtn().click(); + + Assert.assertTrue(ruleChainsPage.ruleChainsIsNotPresent(ruleChainName)); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t remove Root Rule Chain (the trash can is disabled in the right corner)") + public void removeRootRuleChain() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.selectAllCheckBox().click(); + + Assert.assertFalse(ruleChainsPage.deleteBtn(ROOT_RULE_CHAIN_NAME).isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t remove Root Rule Chain (can`t mark the rule chain in the checkbox )") + public void removeSelectedRootRuleChain() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.selectAllCheckBox().click(); + + ruleChainsPage.assertCheckBoxIsNotDisplayed(ROOT_RULE_CHAIN_NAME); + } + + @Test(priority = 30, groups = "smoke") + @Description("The rule chains are deleted immediately after clicking remove (no need to refresh the page)") + public void deleteSeveralRuleChainsByTopBtnWithoutRefresh() { + String ruleChainName = ENTITY_NAME; + int count = 2; + ruleChainsPage.createRuleChains(ruleChainName, count); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.clickOnCheckBoxes(count); + ruleChainsPage.deleteSelectedBtn().click(); + ruleChainsPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(ruleChainsPage.ruleChainsIsNotPresent(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 new file mode 100644 index 0000000000..8a71a11232 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/MakeRuleChainRootTest.java @@ -0,0 +1,75 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.URL; + +public class MakeRuleChainRootAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @AfterMethod + public void makeRoot() { + ruleChainsPage.makeRoot(); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can make rule chain root by clicking on the 'Make rule chain root' icon in the right corner") + public void makeRuleChainRootByRightCornerBtn() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setRuleChainNameWithoutRoot(0); + String ruleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.makeRootBtn(ruleChain).click(); + ruleChainsPage.warningPopUpYesBtn().click(); + + Assert.assertTrue(ruleChainsPage.rootCheckBoxEnable(ruleChain).isDisplayed()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can make rule chain by clicking on the name/row of the rule chain and click on the 'make rule chain root' button") + public void makeRuleChainRootFromView() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setRuleChainNameWithoutRoot(0); + String ruleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.entity(ruleChain).click(); + ruleChainsPage.makeRootFromViewBtn().click(); + ruleChainsPage.warningPopUpYesBtn().click(); + ruleChainsPage.closeEntityViewBtn().click(); + + Assert.assertTrue(ruleChainsPage.rootCheckBoxEnable(ruleChain).isDisplayed()); + } + + @Test(priority = 30, groups = "smoke") + @Description("Can't make multiple root rule chains (only one rule chain can be root)") + public void multiplyRoot() { + SideBarMenuViewElements sideBarMenuView = new SideBarMenuViewElements(driver); + RuleChainsPageHelperAbstract ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setRuleChainNameWithoutRoot(0); + String ruleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.entity(ruleChain).click(); + ruleChainsPage.makeRootFromViewBtn().click(); + ruleChainsPage.warningPopUpYesBtn().click(); + ruleChainsPage.closeEntityViewBtn().click(); + + Assert.assertEquals(ruleChainsPage.rootCheckBoxesEnable().size(), 1); + } +} 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 new file mode 100644 index 0000000000..f38f20bdff --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/OpenRuleChainTest.java @@ -0,0 +1,71 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.URL; + +public class OpenRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + private OpenRuleChainPageHelperAbstract openRuleChainPage; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + openRuleChainPage = new OpenRuleChainPageHelperAbstract(driver); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can open the rule chain by clicking on the 'Open rule chain' icon in the right corner") + public void openRuleChainByRightCornerBtn() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setRuleChainNameWithoutRoot(0); + String ruleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.openRuleChainBtn(ruleChain).click(); + openRuleChainPage.setHeadName(); + + Assert.assertTrue(urlContains(ruleChainsPage.getRuleChainId(ruleChainsPage.getRuleChainName()))); + Assert.assertTrue(openRuleChainPage.headRuleChainName().isDisplayed()); + Assert.assertTrue(openRuleChainPage.inputNode().isDisplayed()); + Assert.assertEquals(ruleChainsPage.getRuleChainName(), openRuleChainPage.getHeadName()); + } + + @Test(priority = 10, groups = "smoke") + @Description("Can open the rule chain by clicking on the name/row of the rule chain and click on the 'Open rule chain' button") + public void openRuleChainByViewBtn() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setRuleChainNameWithoutRoot(0); + String ruleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.entity(ruleChain).click(); + ruleChainsPage.openRuleChainFromViewBtn().click(); + openRuleChainPage.setHeadName(); + + Assert.assertTrue(urlContains(ruleChainsPage.getRuleChainId(ruleChain))); + Assert.assertTrue(openRuleChainPage.headRuleChainName().isDisplayed()); + Assert.assertTrue(openRuleChainPage.inputNode().isDisplayed()); + Assert.assertEquals(ruleChain, openRuleChainPage.getHeadName()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t open the rule chain by clicking twice on the row/name") + public void openRuleChainDoubleClick() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setRuleChainNameWithoutRoot(0); + String ruleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.doubleClickOnRuleChain(ruleChain); + + Assert.assertEquals(getUrl(), URL + "ruleChains"); + } +} 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 new file mode 100644 index 0000000000..9a080d7435 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/RuleChainEditMenuTest.java @@ -0,0 +1,130 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; + +import static org.thingsboard.server.msa.ui.utils.Const.*; + +public class RuleChainEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + private String ruleChainName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @AfterMethod + public void delete() { + if (ruleChainName != null) { + ruleChainsPage.deleteRuleChain(ruleChainName); + ruleChainName = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description("Can click by pencil icon and edit the name (change the name) and save the changes. All changes have been applied") + public void changeName() { + ruleChainsPage.createRuleChain(ENTITY_NAME); + String name = "Changed"; + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.setHeaderName(); + String nameBefore = ruleChainsPage.getHeaderName(); + ruleChainsPage.editPencilBtn().click(); + ruleChainsPage.changeNameEditMenu(name); + ruleChainsPage.doneBtnEditView().click(); + ruleChainsPage.setHeaderName(); + String nameAfter = ruleChainsPage.getHeaderName(); + ruleChainName = name; + + Assert.assertNotEquals(nameBefore, nameAfter); + Assert.assertEquals(name, nameAfter); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t delete the name and save changes") + public void deleteName() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.editPencilBtn().click(); + ruleChainsPage.changeNameEditMenu(""); + + Assert.assertFalse(ruleChainsPage.doneBtnEditViewVisible().isEnabled()); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can`t save just a space in the name") + public void saveOnlyWithSpace() { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.editPencilBtn().click(); + ruleChainsPage.changeNameEditMenu(" "); + ruleChainsPage.doneBtnEditView().click(); + + Assert.assertNotNull(ruleChainsPage.warningMessage()); + Assert.assertTrue(ruleChainsPage.warningMessage().isDisplayed()); + Assert.assertEquals(ruleChainsPage.warningMessage().getText(), EMPTY_RULE_CHAIN_MESSAGE); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can write/change/delete the descriptionEntityView and save the changes. All changes have been applied") + public void editDescription() { + String name = ENTITY_NAME; + ruleChainsPage.createRuleChain(name); + String description = "Description"; + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.notRootRuleChainsNames().get(0).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.editPencilBtn().click(); + ruleChainsPage.changeDescription(""); + ruleChainsPage.doneBtnEditView().click(); + ruleChainName = name; + + Assert.assertTrue(ruleChainsPage.descriptionEntityView().getAttribute("value").isEmpty()); + Assert.assertEquals(description, description1); + Assert.assertEquals(description + description, description2); + } + + @Test(priority = 20, groups = "smoke") + @Description("Can enable / disable debug and save changes. All changes have been applied") + public void debugMode() { + String name = ENTITY_NAME; + ruleChainsPage.createRuleChain(name); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.editPencilBtn().click(); + ruleChainsPage.debugCheckboxEdit().click(); + ruleChainsPage.doneBtnEditView().click(); + boolean debugMode = Boolean.parseBoolean(ruleChainsPage.debugCheckboxView().getAttribute("aria-checked")); + ruleChainsPage.editPencilBtn().click(); + ruleChainsPage.debugCheckboxEdit().click(); + ruleChainsPage.doneBtnEditView().click(); + ruleChainName = name; + + Assert.assertFalse(Boolean.parseBoolean(ruleChainsPage.debugCheckboxView().getAttribute("aria-checked"))); + Assert.assertTrue(debugMode); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000..0a8dc6d96b --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SearchRuleChainTest.java @@ -0,0 +1,52 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.URL; + +public class SearchRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "ruleChainNameForSearchByFirstAndSecondWord") + @Description("Can search by the first/second word of the name") + public void searchFirstWord(String namePath) { + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.searchEntity(namePath); + ruleChainsPage.setRuleChainName(0); + + Assert.assertTrue(ruleChainsPage.getRuleChainName().contains(namePath)); + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSearchBySymbolAndNumber") + @Description("Can search by number/symbol") + public void searchNumber(String name, String namePath) { + ruleChainsPage.createRuleChain(name); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.searchEntity(namePath); + ruleChainsPage.setRuleChainName(0); + boolean ruleChainContainsNamePath = ruleChainsPage.getRuleChainName().contains(namePath); + + ruleChainsPage.deleteRuleChain(name); + + Assert.assertTrue(ruleChainContainsNamePath); + } +} 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 new file mode 100644 index 0000000000..a8f381c494 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByNameTest.java @@ -0,0 +1,122 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.URL; + +public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + private String ruleChainName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @AfterMethod + public void delete() { + if (ruleChainName != null) { + ruleChainsPage.deleteRuleChain(ruleChainName); + ruleChainName = null; + } + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") + @Description + public void specialCharacterUp(String ruleChainName) { + ruleChainsPage.createRuleChain(ruleChainName); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.sortByNameBtn().click(); + ruleChainsPage.setRuleChainName(0); + this.ruleChainName = ruleChainName; + + Assert.assertEquals(ruleChainsPage.getRuleChainName(), ruleChainName); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") + @Description + public void allSortUp(String ruleChain, String ruleChainSymbol, String ruleChainNumber) { + ruleChainsPage.createRuleChain(ruleChainSymbol); + ruleChainsPage.createRuleChain(ruleChain); + ruleChainsPage.createRuleChain(ruleChainNumber); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.sortByNameBtn().click(); + ruleChainsPage.setRuleChainName(0); + String firstRuleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.setRuleChainName(1); + String secondRuleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.setRuleChainName(2); + String thirdRuleChain = ruleChainsPage.getRuleChainName(); + + boolean firstEquals = firstRuleChain.equals(ruleChainSymbol); + boolean secondEquals = secondRuleChain.equals(ruleChainNumber); + boolean thirdEquals = thirdRuleChain.equals(ruleChain); + + ruleChainsPage.deleteRuleChain(ruleChain); + ruleChainsPage.deleteRuleChain(ruleChainNumber); + ruleChainsPage.deleteRuleChain(ruleChainSymbol); + + Assert.assertTrue(firstEquals); + Assert.assertTrue(secondEquals); + Assert.assertTrue(thirdEquals); + } + + @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") + @Description + public void specialCharacterDown(String ruleChainName) { + ruleChainsPage.createRuleChain(ruleChainName); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.sortByNameDown(); + ruleChainsPage.setRuleChainName(ruleChainsPage.allNames().size() - 1); + this.ruleChainName = ruleChainName; + + Assert.assertEquals(ruleChainsPage.getRuleChainName(), ruleChainName); + } + + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") + @Description + public void allSortDown(String ruleChain, String ruleChainSymbol, String ruleChainNumber) { + ruleChainsPage.createRuleChain(ruleChainSymbol); + ruleChainsPage.createRuleChain(ruleChain); + ruleChainsPage.createRuleChain(ruleChainNumber); + + sideBarMenuView.ruleChainsBtn().click(); + int lastIndex = ruleChainsPage.allNames().size() - 1; + ruleChainsPage.sortByNameDown(); + ruleChainsPage.setRuleChainName(lastIndex); + String firstRuleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.setRuleChainName(lastIndex - 1); + String secondRuleChain = ruleChainsPage.getRuleChainName(); + ruleChainsPage.setRuleChainName(lastIndex - 2); + String thirdRuleChain = ruleChainsPage.getRuleChainName(); + + boolean firstEquals = firstRuleChain.equals(ruleChainSymbol); + boolean secondEquals = secondRuleChain.equals(ruleChainNumber); + boolean thirdEquals = thirdRuleChain.equals(ruleChain); + + ruleChainsPage.deleteRuleChain(ruleChain); + ruleChainsPage.deleteRuleChain(ruleChainNumber); + ruleChainsPage.deleteRuleChain(ruleChainSymbol); + + Assert.assertTrue(firstEquals); + Assert.assertTrue(secondEquals); + Assert.assertTrue(thirdEquals); + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000..3fc33e3ac0 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/tests/ruleChainsSmoke/SortByTimeTest.java @@ -0,0 +1,70 @@ +package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; + +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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.URL; + +public class SortByTimeAbstractDiverBaseTest extends AbstractDiverBaseTest { + + private SideBarMenuViewElements sideBarMenuView; + private RuleChainsPageHelperAbstract ruleChainsPage; + private String ruleChainName; + + @BeforeMethod + public void login() { + openUrl(URL); + new LoginPageHelperAbstract(driver).authorizationTenant(); + sideBarMenuView = new SideBarMenuViewElements(driver); + ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + } + + @AfterMethod + public void delete() { + if (ruleChainName != null) { + ruleChainsPage.deleteRuleChain(ruleChainName); + ruleChainName = null; + } + } + + @Test(priority = 10, groups = "smoke") + @Description + public void sortByTimeDown() { + String ruleChain = ENTITY_NAME; + ruleChainsPage.createRuleChain(ruleChain); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.setSort(); + String firstListElement = ruleChainsPage.getSort().get(ruleChainsPage.getSort().size() - 1); + String lastCreated = ruleChainsPage.createdTime().get(0).getText(); + ruleChainName = ruleChain; + + Assert.assertEquals(firstListElement, lastCreated); + Assert.assertNotNull(ruleChainsPage.createdTimeEntity(ruleChain, lastCreated)); + } + + @Test(priority = 10, groups = "smoke") + @Description + public void sortByTimeUp() { + String ruleChain = ENTITY_NAME; + ruleChainsPage.createRuleChain(ruleChain); + + sideBarMenuView.ruleChainsBtn().click(); + ruleChainsPage.sortByTimeBtn().click(); + ruleChainsPage.setSort(); + String firstListElement = ruleChainsPage.getSort().get(ruleChainsPage.getSort().size() - 1); + String lastCreated = ruleChainsPage.createdTime().get(ruleChainsPage.createdTime().size() - 1).getText(); + ruleChainName = ruleChain; + + Assert.assertEquals(firstListElement, lastCreated); + Assert.assertNotNull(ruleChainsPage.createdTimeEntity(ruleChain, lastCreated)); + } +} 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 new file mode 100644 index 0000000000..db6bd40084 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/Const.java @@ -0,0 +1,21 @@ +package utils; + +import base.Base; + +public class Const extends Base { + + public static final String URL = "http://localhost:8080/"; + 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 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_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 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 PHONE_NUMBER_ERROR_MESSAGE = "Phone number is invalid or not possible"; +} \ 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 new file mode 100644 index 0000000000..1509250abf --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/DataProviderCredential.java @@ -0,0 +1,62 @@ +package utils; + +import org.testng.annotations.DataProvider; + +import static base.Base.getRandomSymbol; +import static 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 NUMBER = "1"; + private static final String LONG_PHONE_NUMBER = "20155501231"; + private static final String SHORT_PHONE_NUMBER = "201555011"; + private static final String RULE_CHAIN_SECOND_WORD_NAME_PATH = "Rule"; + 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"; + + @DataProvider + public static Object[][] ruleChainNameForSearchByFirstAndSecondWord() { + return new Object[][]{ + {RULE_CHAIN_SECOND_WORD_NAME_PATH}, + {RULE_CHAIN_FIRST_WORD_NAME_PATH}}; + } + + @DataProvider + public static Object[][] nameForSearchBySymbolAndNumber() { + return new Object[][]{ + {NAME, ENTITY_NAME.split("`")[1]}, + {NAME, String.valueOf(getRandomSymbol())}}; + } + + @DataProvider + public static Object[][] nameForSort() { + return new Object[][]{ + {NAME}, + {SYMBOL}, + {NUMBER}}; + } + + @DataProvider + public static Object[][] nameForAllSort() { + return new Object[][]{ + {NAME, SYMBOL, NUMBER}}; + } + + @DataProvider + public static Object[][] incorrectPhoneNumber() { + return new Object[][]{ + {LONG_PHONE_NUMBER}, + {SHORT_PHONE_NUMBER}, + {ENTITY_NAME}}; + } + + @DataProvider + public static Object[][] customerNameForSearchByFirstAndSecondWord() { + return new Object[][]{ + {CUSTOMER_FIRST_WORD_NAME_PATH}, + {CUSTOMER_SECOND_WORD_NAME_PATH}}; + } +} 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 new file mode 100644 index 0000000000..683dca511c --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/utils/EntityPrototypes.java @@ -0,0 +1,19 @@ +package org.thingsboard.server.msa.ui.utils; + +import org.thingsboard.server.common.data.Customer; +import org.thingsboard.server.common.data.rule.RuleChain; + +public class CustomerPrototypes { + + public static Customer defaultCustomerPrototype(String entityName){ + Customer customer = new Customer(); + customer.setTitle(entityName); + return customer; + } + + public static RuleChain defaultRuleChainPrototype(String entityName){ + RuleChain ruleChain = new RuleChain(); + ruleChain.setName(entityName); + return ruleChain; + } +} diff --git a/msa/black-box-tests/src/test/resources/connectivity.xml b/msa/black-box-tests/src/test/resources/connectivity.xml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/msa/black-box-tests/src/test/resources/forImport.json b/msa/black-box-tests/src/test/resources/forImport.json new file mode 100644 index 0000000000..40367d7609 --- /dev/null +++ b/msa/black-box-tests/src/test/resources/forImport.json @@ -0,0 +1,20 @@ +{ + "ruleChain": { + "additionalInfo": { + "description": "" + }, + "name": "Rule Chain from Import", + "type": "CORE", + "firstRuleNodeId": null, + "root": false, + "debugMode": false, + "configuration": null, + "externalId": null + }, + "metadata": { + "firstNodeIndex": null, + "nodes": [], + "connections": null, + "ruleChainConnections": null + } +} diff --git a/msa/black-box-tests/src/test/resources/forImport.txt b/msa/black-box-tests/src/test/resources/forImport.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/msa/black-box-tests/src/test/resources/smokeTests.xml b/msa/black-box-tests/src/test/resources/smokeTests.xml new file mode 100644 index 0000000000..1194791760 --- /dev/null +++ b/msa/black-box-tests/src/test/resources/smokeTests.xml @@ -0,0 +1,26 @@ + + + + + + + + + + \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/smokesCustomer.xml b/msa/black-box-tests/src/test/resources/smokesCustomer.xml new file mode 100644 index 0000000000..0282d57cbd --- /dev/null +++ b/msa/black-box-tests/src/test/resources/smokesCustomer.xml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/smokesRuleChain.xml b/msa/black-box-tests/src/test/resources/smokesRuleChain.xml new file mode 100644 index 0000000000..43598e5358 --- /dev/null +++ b/msa/black-box-tests/src/test/resources/smokesRuleChain.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 843e6ee87c2455410bdf4fcd8839793ff1236b98 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 22 Nov 2022 13:19:21 +0200 Subject: [PATCH 02/44] add ui tests --- .../server/msa/TestRestClient.java | 80 +++++++++---- .../msa/connectivity/MqttClientTest.java | 2 +- .../server/msa/ui/base/AbstractBasePage.java | 42 ++++--- .../msa/ui/base/AbstractDiverBaseTest.java | 60 ++++++++-- .../msa/ui/listeners/RetryAnalyzer.java | 17 ++- .../msa/ui/listeners/RetryTestListener.java | 17 ++- .../server/msa/ui/listeners/TestListener.java | 31 ++++-- .../msa/ui/pages/CustomerPageElements.java | 19 +++- .../msa/ui/pages/CustomerPageHelper.java | 50 +++------ .../msa/ui/pages/DashboardPageElements.java | 19 +++- .../msa/ui/pages/DashboardPageHelper.java | 19 +++- .../msa/ui/pages/LoginPageElements.java | 19 +++- .../server/msa/ui/pages/LoginPageHelper.java | 19 +++- .../ui/pages/OpenRuleChainPageElements.java | 19 +++- .../msa/ui/pages/OpenRuleChainPageHelper.java | 19 +++- .../msa/ui/pages/OtherPageElements.java | 20 +++- .../msa/ui/pages/OtherPageElementsHelper.java | 19 +++- .../msa/ui/pages/RuleChainsPageElements.java | 19 +++- .../msa/ui/pages/RuleChainsPageHelper.java | 94 ++++------------ .../msa/ui/pages/SideBarMenuViewElements.java | 21 +++- .../customerSmoke/CreateCustomerTest.java | 56 ++++++---- .../customerSmoke/CustomerEditMenuTest.java | 105 ++++++++++-------- .../customerSmoke/DeleteCustomerTest.java | 54 +++++---- .../DeleteSeveralCustomerTest.java | 57 ++++++---- .../ManageCustomersAssetsTest.java | 31 ++++-- .../ManageCustomersDashboardsTest.java | 31 ++++-- .../ManageCustomersDevicesTest.java | 31 ++++-- .../ManageCustomersEdgesTest.java | 33 ++++-- .../ManageCustomersUsersTest.java | 33 ++++-- .../customerSmoke/SearchCustomerTest.java | 50 +++++---- .../tests/customerSmoke/SortByNameTest.java | 65 +++++++---- .../CreateRuleChainImportTest.java | 65 +++++++---- .../ruleChainsSmoke/CreateRuleChainTest.java | 74 +++++++----- .../ruleChainsSmoke/DeleteRuleChainTest.java | 65 +++++++---- .../DeleteSeveralRuleChainsTest.java | 56 ++++++---- .../MakeRuleChainRootTest.java | 41 ++++--- .../ruleChainsSmoke/OpenRuleChainTest.java | 46 +++++--- .../RuleChainEditMenuTest.java | 54 +++++---- .../ruleChainsSmoke/SearchRuleChainTest.java | 39 +++++-- .../tests/ruleChainsSmoke/SortByNameTest.java | 62 +++++++---- .../tests/ruleChainsSmoke/SortByTimeTest.java | 38 +++++-- .../server/msa/ui/utils/Const.java | 21 +++- .../msa/ui/utils/DataProviderCredential.java | 21 +++- .../server/msa/ui/utils/EntityPrototypes.java | 17 ++- .../src/test/resources/connectivity.xml | 27 +++++ .../src/test/resources/forImport.txt | 16 +++ .../src/test/resources/smokeTests.xml | 6 +- .../src/test/resources/smokesCustomer.xml | 2 +- .../src/test/resources/smokesRuleChain.xml | 2 +- .../src/test/resources/testNG.xml | 10 +- msa/pom.xml | 2 + 51 files changed, 1237 insertions(+), 578 deletions(-) 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 713205e228..be0068fd04 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 @@ -26,7 +26,9 @@ import io.restassured.http.ContentType; import io.restassured.path.json.JsonPath; import io.restassured.response.ValidatableResponse; 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.id.CustomerId; import org.thingsboard.server.common.data.id.DeviceId; import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.RuleChainId; @@ -76,7 +78,7 @@ public class TestRestClient { loginRequest.put("password", password); JsonPath jsonPath = given().spec(requestSpec).body(loginRequest) - .post( "/api/auth/login") + .post("/api/auth/login") .getBody().jsonPath(); token = jsonPath.get("token"); refreshToken = jsonPath.get("refreshToken"); @@ -84,7 +86,7 @@ public class TestRestClient { } public Device postDevice(String accessToken, Device device) { - return given().spec(requestSpec).body(device) + return given().spec(requestSpec).body(device) .pathParams("accessToken", accessToken) .post("/api/device?accessToken={accessToken}") .then() @@ -94,62 +96,65 @@ public class TestRestClient { } public ValidatableResponse getDeviceById(DeviceId deviceId, int statusCode) { - return given().spec(requestSpec) + return given().spec(requestSpec) .pathParams("deviceId", deviceId.getId()) .get("/api/device/{deviceId}") .then() .statusCode(statusCode); } + public Device getDeviceById(DeviceId deviceId) { - return getDeviceById(deviceId, HTTP_OK) + return getDeviceById(deviceId, HTTP_OK) .extract() .as(Device.class); } + public DeviceCredentials getDeviceCredentialsByDeviceId(DeviceId deviceId) { return given().spec(requestSpec).get("/api/device/{deviceId}/credentials", deviceId.getId()) - .then() - .assertThat() - .statusCode(HTTP_OK) - .extract() - .as(DeviceCredentials.class); + .then() + .assertThat() + .statusCode(HTTP_OK) + .extract() + .as(DeviceCredentials.class); } public ValidatableResponse postTelemetry(String credentialsId, JsonNode telemetry) { - return given().spec(requestSpec).body(telemetry) - .post("/api/v1/{credentialsId}/telemetry", credentialsId) - .then() - .statusCode(HTTP_OK); + return given().spec(requestSpec).body(telemetry) + .post("/api/v1/{credentialsId}/telemetry", credentialsId) + .then() + .statusCode(HTTP_OK); } public ValidatableResponse deleteDevice(DeviceId deviceId) { - return given().spec(requestSpec) + return given().spec(requestSpec) .delete("/api/device/{deviceId}", deviceId.getId()) .then() .statusCode(HTTP_OK); } + public ValidatableResponse deleteDeviceIfExists(DeviceId deviceId) { - return given().spec(requestSpec) + return given().spec(requestSpec) .delete("/api/device/{deviceId}", deviceId.getId()) .then() - .statusCode(anyOf(is(HTTP_OK),is(HTTP_NOT_FOUND))); + .statusCode(anyOf(is(HTTP_OK), is(HTTP_NOT_FOUND))); } public ValidatableResponse postTelemetryAttribute(String entityType, DeviceId deviceId, String scope, JsonNode attribute) { - return given().spec(requestSpec).body(attribute) + return given().spec(requestSpec).body(attribute) .post("/api/plugins/telemetry/{entityType}/{entityId}/attributes/{scope}", entityType, deviceId.getId(), scope) .then() .statusCode(HTTP_OK); } public ValidatableResponse postAttribute(String accessToken, JsonNode attribute) { - return given().spec(requestSpec).body(attribute) + return given().spec(requestSpec).body(attribute) .post("/api/v1/{accessToken}/attributes/", accessToken) .then() .statusCode(HTTP_OK); } public JsonNode getAttributes(String accessToken, String clientKeys, String sharedKeys) { - return given().spec(requestSpec) + return given().spec(requestSpec) .queryParam("clientKeys", clientKeys) .queryParam("sharedKeys", sharedKeys) .get("/api/v1/{accessToken}/attributes", accessToken) @@ -167,10 +172,11 @@ public class TestRestClient { .then() .statusCode(HTTP_OK) .extract() - .as(new TypeRef>() {}); + .as(new TypeRef>() { + }); } - public RuleChain postRootRuleChain(RuleChain ruleChain) { + public RuleChain postRuleChain(RuleChain ruleChain) { return given().spec(requestSpec) .body(ruleChain) .post("/api/ruleChain") @@ -239,7 +245,8 @@ public class TestRestClient { .then() .statusCode(HTTP_OK) .extract() - .as(new TypeRef>() {}); + .as(new TypeRef>() { + }); } public JsonNode postServerSideRpc(DeviceId deviceId, JsonNode serverRpcPayload) { @@ -252,6 +259,35 @@ public class TestRestClient { .as(JsonNode.class); } + public Customer postCustomer(Customer customer) { + return given().spec(requestSpec) + .body(customer) + .post("/api/customer") + .then() + .statusCode(HTTP_OK) + .extract() + .as(Customer.class); + } + + public void deleteCustomer(CustomerId customerId) { + given().spec(requestSpec) + .delete("/api/customer/{customerId}", customerId.getId()) + .then() + .statusCode(HTTP_OK); + } + + public PageData getCustomers(PageLink pageLink) { + Map params = new HashMap<>(); + addPageLinkToParam(params, pageLink); + return given().spec(requestSpec).queryParams(params) + .get("/api/customers") + .then() + .statusCode(HTTP_OK) + .extract() + .as(new TypeRef>() { + }); + } + public String getToken() { return token; } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttClientTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttClientTest.java index 55dd432644..03271e629a 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttClientTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttClientTest.java @@ -326,7 +326,7 @@ public class MqttClientTest extends AbstractContainerTest { RuleChain newRuleChain = new RuleChain(); newRuleChain.setName("testRuleChain"); - RuleChain ruleChain = testRestClient.postRootRuleChain(newRuleChain); + RuleChain ruleChain = testRestClient.postRuleChain(newRuleChain); JsonNode configuration = mapper.readTree(this.getClass().getClassLoader().getResourceAsStream("RpcResponseRuleChainMetadata.json")); RuleChainMetaData ruleChainMetaData = new RuleChainMetaData(); 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 8e8a15c5af..9e32d6e917 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 @@ -1,3 +1,18 @@ +/** + * 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.base; import lombok.SneakyThrows; @@ -9,33 +24,22 @@ import org.openqa.selenium.WebElement; import org.openqa.selenium.interactions.Actions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; -import org.thingsboard.rest.client.RestClient; -import org.thingsboard.server.common.data.page.PageLink; -import org.thingsboard.server.msa.ui.utils.Const; import java.time.Duration; import java.util.ArrayList; import java.util.List; +import java.util.Random; @Slf4j -abstract public class BasePage extends Base { +abstract public class AbstractBasePage { protected WebDriver driver; protected WebDriverWait wait; protected Actions actions; - protected RestClient client; - protected PageLink pageLink; - public BasePage(WebDriver driver) { + public AbstractBasePage(WebDriver driver) { this.driver = driver; this.wait = new WebDriverWait(driver, Duration.ofMillis(5000)); this.actions = new Actions(driver); - try { - client = new RestClient(Const.URL); - client.login(Const.TENANT_EMAIL, Const.TENANT_PASSWORD); - pageLink = new PageLink(10); - } catch (Exception e) { - log.info("Can't login"); - } } @SneakyThrows @@ -126,4 +130,14 @@ abstract public class BasePage extends Base { ArrayList tabs = new ArrayList<>(driver.getWindowHandles()); driver.switchTo().window(tabs.get(tabNumber - 1)); } + + public static long getRandomNumber() { + return System.currentTimeMillis(); + } + + public static char getRandomSymbol() { + Random rand = new Random(); + String s = "~`!@#$^&*()_+=-"; + return s.charAt(rand.nextInt(s.length())); + } } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java index 4e5d0d5ead..4079ec264c 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java @@ -1,10 +1,27 @@ +/** + * 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.base; +import com.google.common.io.Files; import io.github.bonigarcia.wdm.WebDriverManager; +import io.qameta.allure.Attachment; +import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; -import org.openqa.selenium.Dimension; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebDriverException; +import org.apache.commons.io.FileUtils; +import org.openqa.selenium.*; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; @@ -12,20 +29,27 @@ import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Listeners; -import org.thingsboard.server.msa.TestListener; -import org.thingsboard.server.msa.ui.listeners.RetryTestListener; +import org.thingsboard.server.common.data.Customer; +import org.thingsboard.server.common.data.page.PageLink; +import org.thingsboard.server.common.data.rule.RuleChain; +import org.thingsboard.server.msa.AbstractContainerTest; +import org.thingsboard.server.msa.ui.listeners.TestListener; +import java.io.File; import java.time.Duration; +import java.util.stream.Collectors; @Slf4j -@Listeners({TestListener.class, RetryTestListener.class}) -abstract public class DiverBaseTest extends Base { - protected WebDriver driver; +@Listeners(TestListener.class) +abstract public class AbstractDiverBaseTest extends AbstractContainerTest { + protected WebDriver driver; private final Dimension dimension = new Dimension(WIDTH, HEIGHT); private static final int WIDTH = 1680; private static final int HEIGHT = 1050; private static final boolean HEADLESS = false; + protected static final PageLink pageLink = new PageLink(10); + @BeforeMethod public void openBrowser() { @@ -63,7 +87,7 @@ abstract public class DiverBaseTest extends Base { } protected boolean urlContains(String urlPath) { - WebDriverWait wait = new WebDriverWait(driver, Duration.ofMillis(10000)); + WebDriverWait wait = new WebDriverWait(driver, Duration.ofMillis(5000)); try { wait.until(ExpectedConditions.urlContains(urlPath)); } catch (WebDriverException e) { @@ -71,4 +95,22 @@ abstract public class DiverBaseTest extends Base { } return driver.getCurrentUrl().contains(urlPath); } + + public static RuleChain getRuleChainByName(String name) { + return testRestClient.getRuleChains(pageLink).getData().stream() + .filter(s -> s.getName().equals(name)).collect(Collectors.toList()).get(0); + } + + public static Customer getCustomerByName(String name) { + return testRestClient.getCustomers(pageLink).getData().stream() + .filter(x -> x.getName().equals(name)).collect(Collectors.toList()).get(0); + } + + @SneakyThrows + @Attachment(value = "Page screenshot", type = "image/png") + public static byte[] captureScreen(WebDriver driver, String dirPath) { + File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); + FileUtils.copyFile(screenshot, new File("./target/allure-results/screenshots/" + dirPath + "//" + screenshot.getName())); + return Files.toByteArray(screenshot); + } } \ No newline at end of file diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java index 30b157f13d..bc3f88d99e 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java @@ -1,4 +1,19 @@ -package listeners; +/** + * 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.listeners; import org.testng.IRetryAnalyzer; import org.testng.ITestResult; diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryTestListener.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryTestListener.java index 6083781820..0411083f87 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryTestListener.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryTestListener.java @@ -1,4 +1,19 @@ -package listeners; +/** + * 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.listeners; import org.testng.IAnnotationTransformer; import org.testng.annotations.ITestAnnotation; diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java index dec83f374b..90ae18bec4 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java @@ -1,16 +1,33 @@ -package listeners; +/** + * 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.listeners; + -import base.Base; -import base.TestInit; import io.qameta.allure.Allure; import lombok.extern.slf4j.Slf4j; import org.openqa.selenium.WebDriver; import org.testng.ITestContext; import org.testng.ITestListener; import org.testng.ITestResult; +import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; + +import static org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest.captureScreen; @Slf4j -public class TestListener extends Base implements ITestListener { +public class TestListener implements ITestListener { WebDriver driver; @@ -20,7 +37,7 @@ public class TestListener extends Base implements ITestListener { Allure.getLifecycle().updateTestCase((t) -> { t.setStatusDetails(t.getStatusDetails().setMessage(str)); }); - driver = ((TestInit) tr.getInstance()).getDriver(); + driver = ((AbstractDiverBaseTest) tr.getInstance()).getDriver(); captureScreen(driver, "success"); } @@ -33,7 +50,7 @@ public class TestListener extends Base implements ITestListener { t.setStatusDetails(t.getStatusDetails().setMessage(str)); t.setStatusDetails(t.getStatusDetails().setMessage(str1)); }); - driver = ((TestInit) tr.getInstance()).getDriver(); + driver = ((AbstractDiverBaseTest) tr.getInstance()).getDriver(); captureScreen(driver, "failure"); } @@ -46,7 +63,7 @@ public class TestListener extends Base implements ITestListener { t.setStatusDetails(t.getStatusDetails().setMessage(str)); t.setStatusDetails(t.getStatusDetails().setMessage(str1)); }); - driver = ((TestInit) tr.getInstance()).getDriver(); + driver = ((AbstractDiverBaseTest) tr.getInstance()).getDriver(); captureScreen(driver, "skipped"); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java index dcb513ab71..e10fb7d1ed 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java @@ -1,3 +1,18 @@ +/** + * 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; @@ -5,8 +20,8 @@ import org.openqa.selenium.WebElement; import java.util.List; -public class CustomerPageElementsAbstract extends OtherPageElementsHelperAbstract { - public CustomerPageElementsAbstract(WebDriver driver) { +public class CustomerPageElements extends OtherPageElementsHelper { + public CustomerPageElements(WebDriver driver) { super(driver); } 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 13d6a26077..9956966a16 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 @@ -1,17 +1,28 @@ +/** + * 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 lombok.extern.slf4j.Slf4j; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; -import org.thingsboard.server.common.data.Customer; -import org.thingsboard.server.common.data.page.PageData; - -import java.util.stream.Collectors; @Slf4j -public class CustomerPageHelperAbstract extends CustomerPageElementsAbstract { - public CustomerPageHelperAbstract(WebDriver driver) { +public class CustomerPageHelper extends CustomerPageElements { + public CustomerPageHelper(WebDriver driver) { super(driver); } @@ -84,33 +95,6 @@ public class CustomerPageHelperAbstract extends CustomerPageElementsAbstract { return customerCity; } - public void createCustomer(String entityName) { - try { - PageData tenantCustomer; - tenantCustomer = client.getCustomers(pageLink); - Customer customer = new Customer(); - customer.setTitle(entityName); - client.saveCustomer(customer); - tenantCustomer.getData().add(customer); - } catch (Exception e) { - log.info("Can't create!"); - } - } - - public void deleteCustomer(String entityName) { - try { - PageData tenantRuleChains; - tenantRuleChains = client.getCustomers(pageLink); - try { - client.deleteCustomer(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(0).getId()); - } catch (Exception e) { - client.deleteCustomer(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(1).getId()); - } - } catch (Exception e) { - log.info("Can't delete!"); - } - } - public void changeTitleEditMenu(String newTitle) { titleFieldEntityView().clear(); wait.until(ExpectedConditions.textToBe(By.xpath(String.format(INPUT_FIELD, INPUT_FIELD_NAME_TITLE)), "")); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageElements.java index 9e2595ed3c..80bd3780c7 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageElements.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageElements.java @@ -1,3 +1,18 @@ +/** + * 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; @@ -5,8 +20,8 @@ import org.openqa.selenium.WebElement; import java.util.List; -public class DashboardPageElementsAbstract extends OtherPageElementsHelperAbstract { - public DashboardPageElementsAbstract(WebDriver driver) { +public class DashboardPageElements extends OtherPageElementsHelper { + public DashboardPageElements(WebDriver driver) { super(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageHelper.java index 7bf8956542..1b4ae6dfa9 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageHelper.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/DashboardPageHelper.java @@ -1,9 +1,24 @@ +/** + * 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 DashboardPageHelperAbstract extends DashboardPageElementsAbstract { - public DashboardPageHelperAbstract(WebDriver driver) { +public class DashboardPageHelper extends DashboardPageElements { + public DashboardPageHelper(WebDriver driver) { super(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageElements.java index 54239e2971..b6a2f09513 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageElements.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageElements.java @@ -1,11 +1,26 @@ +/** + * 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 org.thingsboard.server.msa.ui.base.AbstractBasePage; -public class LoginPageElementsAbstract extends AbstractBasePage { - public LoginPageElementsAbstract(WebDriver driver) { +public class LoginPageElements extends AbstractBasePage { + public LoginPageElements(WebDriver driver) { super(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageHelper.java index a39b507882..e59d07e455 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageHelper.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/LoginPageHelper.java @@ -1,10 +1,25 @@ +/** + * 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.thingsboard.server.msa.ui.utils.Const; -public class LoginPageHelperAbstract extends LoginPageElementsAbstract { - public LoginPageHelperAbstract(WebDriver driver) { +public class LoginPageHelper extends LoginPageElements { + public LoginPageHelper(WebDriver driver) { super(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageElements.java index 521758ea41..7fa0bd7468 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageElements.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageElements.java @@ -1,11 +1,26 @@ +/** + * 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 org.thingsboard.server.msa.ui.base.AbstractBasePage; -public class OpenRuleChainPageElementsAbstract extends AbstractBasePage { - public OpenRuleChainPageElementsAbstract(WebDriver driver) { +public class OpenRuleChainPageElements extends AbstractBasePage { + public OpenRuleChainPageElements(WebDriver driver) { super(driver); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageHelper.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageHelper.java index ccaaedab28..0017396a8a 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageHelper.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/OpenRuleChainPageHelper.java @@ -1,9 +1,24 @@ +/** + * 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 OpenRuleChainPageHelperAbstract extends OpenRuleChainPageElementsAbstract { - public OpenRuleChainPageHelperAbstract(WebDriver driver) { +public class OpenRuleChainPageHelper extends OpenRuleChainPageElements { + public OpenRuleChainPageHelper(WebDriver driver) { super(driver); } 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 bf4be2dae2..1f3ecfa208 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 @@ -1,3 +1,18 @@ +/** + * 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; @@ -6,8 +21,8 @@ import org.thingsboard.server.msa.ui.base.AbstractBasePage; import java.util.List; -public class OtherPageElementsAbstract extends AbstractBasePage { - public OtherPageElementsAbstract(WebDriver driver) { +public class OtherPageElements extends AbstractBasePage { + public OtherPageElements(WebDriver driver) { super(driver); } @@ -103,6 +118,7 @@ public class OtherPageElementsAbstract extends AbstractBasePage { } public WebElement editPencilBtn() { + waitUntilVisibilityOfElementsLocated(EDIT_PENCIL_BTN); return waitUntilElementToBeClickable(EDIT_PENCIL_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 dc4a41e9b9..dbef06e7fe 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 @@ -1,11 +1,26 @@ +/** + * 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.Keys; import org.openqa.selenium.WebDriver; -public class OtherPageElementsHelperAbstract extends OtherPageElementsAbstract { - public OtherPageElementsHelperAbstract(WebDriver driver) { +public class OtherPageElementsHelper extends OtherPageElements { + public OtherPageElementsHelper(WebDriver driver) { super(driver); } 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 4a378bb1c3..eee95edcae 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 @@ -1,3 +1,18 @@ +/** + * 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; @@ -6,8 +21,8 @@ import org.openqa.selenium.WebElement; import java.util.List; -public class RuleChainsPageElementsAbstract extends OtherPageElementsHelperAbstract { - public RuleChainsPageElementsAbstract(WebDriver driver) { +public class RuleChainsPageElements extends OtherPageElementsHelper { + public RuleChainsPageElements(WebDriver driver) { super(driver); } 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 9d23660b11..a6a7148bc4 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 @@ -1,3 +1,18 @@ +/** + * 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 lombok.extern.slf4j.Slf4j; @@ -5,17 +20,14 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.testng.Assert; -import org.thingsboard.server.common.data.page.PageData; -import org.thingsboard.server.common.data.rule.RuleChain; import java.util.ArrayList; import java.util.Collections; import java.util.Random; -import java.util.stream.Collectors; @Slf4j -public class RuleChainsPageHelperAbstract extends RuleChainsPageElementsAbstract { - public RuleChainsPageHelperAbstract(WebDriver driver) { +public class RuleChainsPageHelper extends RuleChainsPageElements { + public RuleChainsPageHelper(WebDriver driver) { super(driver); } @@ -52,74 +64,6 @@ public class RuleChainsPageHelperAbstract extends RuleChainsPageElementsAbstract return this.ruleChainName; } - public String getRuleChainId(String entityName) { - PageData tenantRuleChains; - tenantRuleChains = client.getRuleChains(pageLink); - return String.valueOf(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(0).getId()); - } - - public void deleteRuleChain(String entityName) { - try { - PageData tenantRuleChains; - tenantRuleChains = client.getRuleChains(pageLink); - try { - client.deleteRuleChain(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(0).getId()); - } catch (Exception e) { - client.deleteRuleChain(tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).get(1).getId()); - } - } catch (Exception e) { - log.info("Can't delete!"); - } - } - - public void deleteAllRuleChain(String entityName) { - try { - PageData tenantRuleChains; - tenantRuleChains = client.getRuleChains(pageLink); - tenantRuleChains.getData().stream().filter(s -> s.getName().equals(entityName)).collect(Collectors.toList()).forEach(x -> client.deleteRuleChain(x.getId())); - } catch (Exception e) { - log.info("Can't delete!"); - } - } - - public void createRuleChain(String entityName) { - try { - PageData tenantRuleChains; - tenantRuleChains = client.getRuleChains(pageLink); - RuleChain ruleChain = new RuleChain(); - ruleChain.setName(entityName); - client.saveRuleChain(ruleChain); - tenantRuleChains.getData().add(ruleChain); - } catch (Exception e) { - log.info("Can't create!"); - } - } - - public void makeRoot() { - try { - PageData tenantRuleChains; - tenantRuleChains = client.getRuleChains(pageLink); - tenantRuleChains.getData().stream().filter(s -> s.getName().equals("Root Rule Chain")).collect(Collectors.toList()).forEach(x -> client.setRootRuleChain(x.getId())); - } catch (Exception e) { - log.info("Can't make root!"); - } - } - - public void createRuleChains(String entityName, int count) { - try { - PageData tenantRuleChains; - tenantRuleChains = client.getRuleChains(pageLink); - RuleChain ruleChain = new RuleChain(); - for (int i = 0; i < count; i++) { - ruleChain.setName(entityName); - client.saveRuleChain(ruleChain); - tenantRuleChains.getData().add(ruleChain); - } - } catch (Exception e) { - log.info("Can't create!"); - } - } - public String deleteRuleChainFromView(String ruleChainName) { String s = ""; if (deleteBtnFromView() != null) { @@ -149,8 +93,8 @@ public class RuleChainsPageHelperAbstract extends RuleChainsPageElementsAbstract Assert.assertFalse(driver.findElement(By.xpath(getCheckbox(entityName))).isDisplayed()); } - public void assertDeleteBtnInRootRuleChainIsNotDisplayed() { - Assert.assertFalse(driver.findElement(By.xpath(getDeleteRuleChainFromViewBtn())).isDisplayed()); + public boolean deleteBtnInRootRuleChainIsNotDisplayed() { + return wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath(getDeleteRuleChainFromViewBtn()))); } public boolean ruleChainsIsNotPresent(String ruleChainName) { 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 1e1484be7b..902966a1ac 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 @@ -1,10 +1,25 @@ -package pages; +/** + * 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 base.BasePage; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.thingsboard.server.msa.ui.base.AbstractBasePage; -public class SideBarMenuViewElements extends BasePage { +public class SideBarMenuViewElements extends AbstractBasePage { public SideBarMenuViewElements(WebDriver driver) { super(driver); } 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 c59b950862..9a604416d9 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -6,56 +21,57 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.utils.Const.*; -public class CreateCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class CreateCustomerTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; + private CustomerPageHelper customerPage; private String customerName; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); } @AfterMethod public void delete() { if (customerName != null) { - customerPage.deleteCustomer(customerName); + testRestClient.deleteCustomer(getCustomerByName(customerName).getId()); customerName = null; } } @Test(priority = 10, groups = "smoke") - @Description("Can click on Add after specifying the name (text/numbers /special characters)") + @Description public void createCustomer() { - String customerName = ENTITY_NAME; + customerName = ENTITY_NAME; sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); customerPage.titleFieldAddEntityView().sendKeys(customerName); customerPage.addBtnC().click(); customerPage.refreshBtn().click(); - this.customerName = customerName; Assert.assertNotNull(customerPage.customer(customerName)); Assert.assertTrue(customerPage.customer(customerName).isDisplayed()); } @Test(priority = 20, groups = "smoke") + @Description public void createCustomerWithFullInformation() { - String customerName = ENTITY_NAME; + customerName = ENTITY_NAME; String text = "Text"; String email = "email@mail.com"; - String number = "2015550123"; + String number = "12015550123"; sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); @@ -74,7 +90,6 @@ public class CreateCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { customerPage.setCustomerCountry(customerName); customerPage.setCustomerCity(customerName); customerPage.entity(customerName).click(); - this.customerName = customerName; Assert.assertNotNull(customerPage.customer(customerName)); Assert.assertEquals(customerPage.entityViewTitle().getText(), customerName); @@ -86,7 +101,7 @@ public class CreateCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { Assert.assertEquals(customerPage.zipEntityView().getAttribute("value"), text); Assert.assertEquals(customerPage.addressEntityView().getAttribute("value"), text); Assert.assertEquals(customerPage.address2EntityView().getAttribute("value"), text); - Assert.assertEquals(customerPage.phoneNumberEntityView().getAttribute("value"), "+1" + number); + Assert.assertEquals(customerPage.phoneNumberEntityView().getAttribute("value"), "+" + number); Assert.assertEquals(customerPage.emailEntityView().getAttribute("value"), email); Assert.assertEquals(customerPage.getCustomerEmail(), email); Assert.assertEquals(customerPage.getCustomerCountry(), customerPage.getCountry()); @@ -94,7 +109,7 @@ public class CreateCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { } @Test(priority = 20, groups = "smoke") - @Description("Can`t add customer without the name (empty field or just space)") + @Description public void createCustomerWithoutName() { sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); @@ -103,7 +118,7 @@ public class CreateCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { } @Test(priority = 20, groups = "smoke") - @Description() + @Description public void createCustomerWithOnlySpace() { sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); @@ -118,7 +133,7 @@ public class CreateCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { } @Test(priority = 20, groups = "smoke") - @Description("Can't create a customer with the same name") + @Description public void createCustomerSameName() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); @@ -135,22 +150,21 @@ public class CreateCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { } @Test(priority = 20, groups = "smoke") - @Description("Can click on Add after specifying the name (text/numbers /special characters)") + @Description public void createCustomerWithoutRefresh() { - String customerName = ENTITY_NAME; + customerName = ENTITY_NAME; sideBarMenuView.customerBtn().click(); customerPage.plusBtn().click(); customerPage.titleFieldAddEntityView().sendKeys(customerName); customerPage.addBtnC().click(); - this.customerName = customerName; Assert.assertNotNull(customerPage.customer(customerName)); Assert.assertTrue(customerPage.customer(customerName).isDisplayed()); } @Test(priority = 40, groups = "smoke") - @Description("Question mark icon leads to rule chain documentation (PE)") + @Description public void documentation() { String urlPath = "docs/user-guide/ui/customers/"; 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 36297cbf3a..2bfd157773 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -6,62 +21,64 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.DashboardPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; +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 static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class CustomerEditMenuTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; - private DashboardPageHelperAbstract dashboardPage; + private CustomerPageHelper customerPage; + private DashboardPageHelper dashboardPage; private String customerName; + @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); - dashboardPage = new DashboardPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); + dashboardPage = new DashboardPageHelper(driver); } @AfterMethod public void delete() { if (customerName != null) { - customerPage.deleteCustomer(customerName); + testRestClient.deleteCustomer(getCustomerByName(customerName).getId()); customerName = null; } } @Test(priority = 10, groups = "smoke") - @Description("Can click by pencil icon and edit the title (change the title) and save the changes. All changes have been applied") + @Description public void changeTitle() { - customerPage.createCustomer(ENTITY_NAME); - String title = "Changed" + getRandomNumber(); + customerName = "Changed" + getRandomNumber(); + testRestClient.postCustomer(defaultCustomerPrototype(ENTITY_NAME)); sideBarMenuView.customerBtn().click(); customerPage.entityTitles().get(0).click(); customerPage.setHeaderName(); String titleBefore = customerPage.getHeaderName(); customerPage.editPencilBtn().click(); - customerPage.changeTitleEditMenu(title); + customerPage.changeTitleEditMenu(customerName); customerPage.doneBtnEditView().click(); customerPage.setHeaderName(); String titleAfter = customerPage.getHeaderName(); - customerName = title; Assert.assertNotEquals(titleBefore, titleAfter); - Assert.assertEquals(titleAfter, title); + Assert.assertEquals(titleAfter, customerName); } @Test(priority = 20, groups = "smoke") - @Description("Can`t delete the title and save changes") + @Description public void deleteTitle() { sideBarMenuView.customerBtn().click(); customerPage.entityTitles().get(0).click(); @@ -72,7 +89,7 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description("Can`t save just a space in the title") + @Description public void saveOnlyWithSpace() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); @@ -89,10 +106,10 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description("Can write/change/delete the descriptionEntityView and save the changes. All changes have been applied") + @Description public void editDescription() { - String title = ENTITY_NAME; - customerPage.createCustomer(title); + customerName = ENTITY_NAME; + testRestClient.postCustomer(defaultCustomerPrototype(customerName)); String description = "Description"; sideBarMenuView.customerBtn().click(); @@ -108,7 +125,6 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest customerPage.editPencilBtn().click(); customerPage.changeDescription(""); customerPage.doneBtnEditView().click(); - customerName = title; Assert.assertEquals(description, description1); Assert.assertEquals(description + description, description2); @@ -118,24 +134,23 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest @Test(priority = 20, groups = "smoke") @Description public void assignedDashboardFromDashboard() { - String title = ENTITY_NAME; - customerPage.createCustomer(title); + customerName = ENTITY_NAME; + testRestClient.postCustomer(defaultCustomerPrototype(customerName)); sideBarMenuView.dashboardBtn().click(); dashboardPage.setDashboardTitle(); dashboardPage.assignedBtn(dashboardPage.getDashboardTitle()).click(); - dashboardPage.assignedCustomer(title); + dashboardPage.assignedCustomer(customerName); sideBarMenuView.customerBtn().click(); - customerPage.entity(title).click(); + customerPage.entity(customerName).click(); customerPage.editPencilBtn().click(); customerPage.chooseDashboard(); customerPage.doneBtnEditView().click(); customerPage.setDashboardFromView(); customerPage.closeEntityViewBtn().click(); - customerPage.manageCustomersUserBtn(title).click(); + customerPage.manageCustomersUserBtn(customerName).click(); customerPage.createCustomersUser(); customerPage.userLoginBtn().click(); - customerName = title; Assert.assertNotNull(customerPage.usersWidget()); Assert.assertTrue(customerPage.usersWidget().isDisplayed()); @@ -145,23 +160,22 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest @Test(priority = 20, groups = "smoke") @Description public void assignedDashboard() { - String title = ENTITY_NAME; - customerPage.createCustomer(title); + customerName = ENTITY_NAME; + testRestClient.postCustomer(defaultCustomerPrototype(customerName)); sideBarMenuView.customerBtn().click(); - customerPage.manageCustomersDashboardsBtn(title).click(); + customerPage.manageCustomersDashboardsBtn(customerName).click(); customerPage.assignedDashboard(); sideBarMenuView.customerBtn().click(); - customerPage.entity(title).click(); + customerPage.entity(customerName).click(); customerPage.editPencilBtn().click(); customerPage.chooseDashboard(); customerPage.doneBtnEditView().click(); customerPage.setDashboardFromView(); customerPage.closeEntityViewBtn().click(); - customerPage.manageCustomersUserBtn(title).click(); + customerPage.manageCustomersUserBtn(customerName).click(); customerPage.createCustomersUser(); customerPage.userLoginBtn().click(); - customerName = title; Assert.assertNotNull(customerPage.usersWidget()); Assert.assertTrue(customerPage.usersWidget().isDisplayed()); @@ -171,24 +185,23 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest @Test(priority = 20, groups = "smoke") @Description public void assignedDashboardWithoutHide() { - String title = ENTITY_NAME; - customerPage.createCustomer(title); + customerName = ENTITY_NAME; + testRestClient.postCustomer(defaultCustomerPrototype(customerName)); sideBarMenuView.customerBtn().click(); - customerPage.manageCustomersDashboardsBtn(title).click(); + customerPage.manageCustomersDashboardsBtn(customerName).click(); customerPage.assignedDashboard(); sideBarMenuView.customerBtn().click(); - customerPage.entity(title).click(); + customerPage.entity(customerName).click(); customerPage.editPencilBtn().click(); customerPage.chooseDashboard(); customerPage.hideHomeDashboardToolbarCheckbox().click(); customerPage.doneBtnEditView().click(); customerPage.setDashboardFromView(); customerPage.closeEntityViewBtn().click(); - customerPage.manageCustomersUserBtn(title).click(); + customerPage.manageCustomersUserBtn(customerName).click(); customerPage.createCustomersUser(); customerPage.userLoginBtn().click(); - customerName = title; Assert.assertNotNull(customerPage.usersWidget()); Assert.assertTrue(customerPage.usersWidget().isDisplayed()); @@ -204,8 +217,8 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest @Test(priority = 20, groups = "smoke") @Description public void addPhoneNumber() { - String title = ENTITY_NAME; - customerPage.createCustomer(title); + customerName = ENTITY_NAME; + testRestClient.postCustomer(defaultCustomerPrototype(customerName)); String number = "2015550123"; sideBarMenuView.customerBtn().click(); @@ -213,7 +226,6 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest customerPage.editPencilBtn().click(); customerPage.phoneNumberEntityView().sendKeys(number); customerPage.doneBtnEditView().click(); - customerName = title; Assert.assertTrue(customerPage.phoneNumberEntityView().getAttribute("value").contains(number)); } @@ -235,9 +247,11 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 30, groups = "smoke") + @Description public void addAllInformation() { - String title = ENTITY_NAME; - customerPage.createCustomer(title); + customerName = ENTITY_NAME; + testRestClient.postCustomer(defaultCustomerPrototype(customerName)); + ; String text = "Text"; String email = "email@mail.com"; String number = "2015550123"; @@ -255,7 +269,6 @@ public class CustomerEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest customerPage.phoneNumberEntityView().sendKeys(number); customerPage.emailEntityView().sendKeys(email); customerPage.doneBtnEditView().click(); - customerName = title; Assert.assertEquals(customerPage.countrySelectMenuEntityView().getText(), customerPage.getCountry()); Assert.assertEquals(customerPage.descriptionEntityView().getAttribute("value"), 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 7a22422777..27e8605926 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -5,34 +20,35 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; +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.ENTITY_NAME; -import static org.thingsboard.server.msa.ui.utils.Const.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class DeleteCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class DeleteCustomerTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; - private RuleChainsPageHelperAbstract ruleChainsPage; + private CustomerPageHelper customerPage; + private RuleChainsPageHelper ruleChainsPage; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @Test(priority = 10, groups = "smoke") - @Description("Can remove the customer by clicking on the trash can icon in the right corner") + @Description public void removeCustomerByRightSideBtn() { String customer = ENTITY_NAME; - customerPage.createCustomer(customer); + testRestClient.postCustomer(defaultCustomerPrototype(customer)); sideBarMenuView.customerBtn().click(); String deletedCustomer = customerPage.deleteRuleChainTrash(customer); @@ -42,10 +58,10 @@ public class DeleteCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { } @Test(priority = 20, groups = "smoke") - @Description("Can mark the customer in the checkbox and then click on the trash can icon in the menu that appears at the top") + @Description public void removeSelectedCustomer() { String customerName = ENTITY_NAME; - customerPage.createCustomer(customerName); + testRestClient.postCustomer(defaultCustomerPrototype(customerName)); sideBarMenuView.customerBtn().click(); String deletedCustomer = customerPage.deleteSelected(customerName); @@ -55,10 +71,10 @@ public class DeleteCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { } @Test(priority = 20, groups = "smoke") - @Description("Can click on the name of the rule chain and click on the 'Delete customer' button") + @Description public void removeFromCustomerView() { String customerName = ENTITY_NAME; - customerPage.createCustomer(customerName); + testRestClient.postCustomer(defaultCustomerPrototype(customerName)); sideBarMenuView.customerBtn().click(); customerPage.entity(customerName).click(); @@ -69,10 +85,10 @@ public class DeleteCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { } @Test(priority = 20, groups = "smoke") - @Description("The rule chain is deleted immediately after clicking remove (no need to refresh the page)") + @Description public void removeCustomerByRightSideBtnWithoutRefresh() { String customer = ENTITY_NAME; - customerPage.createCustomer(customer); + testRestClient.postCustomer(defaultCustomerPrototype(customer)); sideBarMenuView.customerBtn().click(); String deletedCustomer = customerPage.deleteRuleChainTrash(customer); 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 9847f1b763..138c563631 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -5,41 +20,37 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.utils.Const.ENTITY_NAME; -import static org.thingsboard.server.msa.ui.utils.Const.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class DeleteSeveralCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class DeleteSeveralCustomerTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; + private CustomerPageHelper customerPage; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); } @Test(priority = 10, groups = "smoke") - @Description("Can mark several customers in the checkbox near the names and then click on the trash can icon in the menu that appears at the top") + @Description public void canDeleteSeveralCustomersByTopBtn() { String title1 = ENTITY_NAME + "1"; String title2 = ENTITY_NAME + "2"; - int count = 2; - customerPage.createCustomer(title1); - customerPage.createCustomer(title2); + testRestClient.postCustomer(defaultCustomerPrototype(title1)); + testRestClient.postCustomer(defaultCustomerPrototype(title2)); sideBarMenuView.customerBtn().click(); - customerPage.clickOnCheckBoxes(count); - - Assert.assertEquals(customerPage.markCheckbox().size(), count); - customerPage.markCheckbox().forEach(x -> Assert.assertTrue(x.isDisplayed())); - + customerPage.clickOnCheckBoxes(2); customerPage.deleteSelectedBtn().click(); customerPage.warningPopUpYesBtn().click(); customerPage.refreshBtn().click(); @@ -49,7 +60,7 @@ public class DeleteSeveralCustomerAbstractDiverBaseTest extends AbstractDiverBas } @Test(priority = 10, groups = "smoke") - @Description("Can mark several rule chains in the checkbox near the names and then click on the trash can icon in the menu that appears at the top") + @Description public void selectAllCustomers() { sideBarMenuView.customerBtn().click(); customerPage.selectAllCheckBox().click(); @@ -61,17 +72,15 @@ public class DeleteSeveralCustomerAbstractDiverBaseTest extends AbstractDiverBas } @Test(priority = 30, groups = "smoke") - @Description("The rule chains are deleted immediately after clicking remove (no need to refresh the page)") + @Description public void deleteSeveralCustomersByTopBtnWithoutRefresh() { String title1 = ENTITY_NAME + "1"; String title2 = ENTITY_NAME + "2"; - int count = 2; - customerPage.createCustomer(title1); - customerPage.createCustomer(title2); + testRestClient.postCustomer(defaultCustomerPrototype(title1)); + testRestClient.postCustomer(defaultCustomerPrototype(title2)); sideBarMenuView.customerBtn().click(); - customerPage.clickOnCheckBoxes(count); - + customerPage.clickOnCheckBoxes(2); customerPage.deleteSelectedBtn().click(); customerPage.warningPopUpYesBtn().click(); 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 785ee8c813..7b85771c23 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -5,28 +20,28 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.utils.Const.URL; -public class ManageCustomersAssetsAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class ManageCustomersAssetsTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; + private CustomerPageHelper customerPage; private final String manage = "Assets"; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); } @Test(groups = "smoke") - @Description("Can go to the 'Customer assets' window by clicking on the 'Manage customer users' icon in the right corner") + @Description public void openWindowByRightCornerBtn() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); @@ -39,7 +54,7 @@ public class ManageCustomersAssetsAbstractDiverBaseTest extends AbstractDiverBas } @Test(groups = "smoke") - @Description("Can go to the 'Customer Assets' window by clicking on the name/row of the customer and click on the 'Manage users' button") + @Description public void openWindowByView() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); 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 68fe281d0b..9ac2986fd0 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -5,27 +20,27 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.utils.Const.URL; -public class ManageCustomersDashboardsAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class ManageCustomersDashboardsTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; + private CustomerPageHelper customerPage; private final String manage = "Dashboards"; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); } @Test(groups = "smoke") - @Description("Can go to the 'Customer Dashboards' window by clicking on the 'Manage customer users' icon in the right corner") + @Description public void openWindowByRightCornerBtn() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); @@ -38,7 +53,7 @@ public class ManageCustomersDashboardsAbstractDiverBaseTest extends AbstractDive } @Test(groups = "smoke") - @Description("Can go to the 'Customer Dashboards' window by clicking on the name/row of the customer and click on the 'Manage users' button") + @Description public void openWindowByView() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); 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 d62b5fe4cf..30b451899e 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -5,27 +20,27 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.utils.Const.URL; -public class ManageCustomersDevicesAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class ManageCustomersDevicesTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; + private CustomerPageHelper customerPage; private final String manage = "Devices"; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); } @Test(groups = "smoke") - @Description("Can go to the 'Customer Devices' window by clicking on the 'Manage customer users' icon in the right corner") + @Description public void openWindowByRightCornerBtn() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); @@ -38,7 +53,7 @@ public class ManageCustomersDevicesAbstractDiverBaseTest extends AbstractDiverBa } @Test(groups = "smoke") - @Description("Can go to the 'Customer Devices' window by clicking on the name/row of the customer and click on the 'Manage users' button") + @Description public void openWindowByView() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); 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 ff0ac3e4f1..044f809f77 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -5,28 +20,28 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.utils.Const.URL; -public class ManageCustomersEdgesAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class ManageCustomersEdgesTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; - private String iconText = "Edge instances"; + private CustomerPageHelper customerPage; + private final String iconText = "Edge instances"; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); } @Test(groups = "smoke") - @Description("Can go to the 'Customer Edges' window by clicking on the 'Manage customer users' icon in the right corner") + @Description public void openWindowByRightCornerBtn() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); @@ -39,7 +54,7 @@ public class ManageCustomersEdgesAbstractDiverBaseTest extends AbstractDiverBase } @Test(groups = "smoke") - @Description("Can go to the 'Customer Edges' window by clicking on the name/row of the customer and click on the 'Manage users' button") + @Description public void openWindowByView() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); 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 855e227b5e..42d03bda1e 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -5,28 +20,28 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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.utils.Const.URL; -public class ManageCustomersUsersAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class ManageCustomersUsersTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; - private String iconText = "Customer Users"; + private CustomerPageHelper customerPage; + private final String iconText = "Customer Users"; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); } @Test(groups = "smoke") - @Description("Can go to the 'Customer Users' window by clicking on the 'Manage customer users' icon in the right corner") + @Description public void openWindowByRightCornerBtn() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); @@ -39,7 +54,7 @@ public class ManageCustomersUsersAbstractDiverBaseTest extends AbstractDiverBase } @Test(groups = "smoke") - @Description("Can go to the 'Customer Users' window by clicking on the name/row of the customer and click on the 'Manage users' button") + @Description public void openWindowByView() { sideBarMenuView.customerBtn().click(); customerPage.setCustomerName(); 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 6db022da62..97a4c6f85f 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 @@ -1,39 +1,49 @@ +/** + * 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.customerSmoke; 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.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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 org.thingsboard.server.msa.ui.utils.DataProviderCredential; -import static org.thingsboard.server.msa.ui.utils.Const.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class SearchCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class SearchCustomerTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; - private String entityName; + private CustomerPageHelper customerPage; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); - } - - @AfterMethod - public void deleteCustomer() { - customerPage.deleteCustomer(entityName); + customerPage = new CustomerPageHelper(driver); } @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "customerNameForSearchByFirstAndSecondWord") - @Description("Can search by the first/second word of the name") + @Description public void searchFirstWord(String namePath) { sideBarMenuView.customerBtn().click(); customerPage.searchEntity(namePath); @@ -42,15 +52,17 @@ public class SearchCustomerAbstractDiverBaseTest extends AbstractDiverBaseTest { } @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSearchBySymbolAndNumber") - @Description("Can search by number/symbol") + @Description public void searchNumber(String name, String namePath) { - customerPage.createCustomer(name); + testRestClient.postCustomer(defaultCustomerPrototype(name)); sideBarMenuView.customerBtn().click(); customerPage.searchEntity(namePath); customerPage.setCustomerName(); - entityName = name; + boolean customerNameContainsPath = customerPage.getCustomerName().contains(namePath); + + testRestClient.deleteCustomer(getCustomerByName(name).getId()); - Assert.assertTrue(customerPage.getCustomerName().contains(namePath)); + Assert.assertTrue(customerNameContainsPath); } } 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 8ab49b6c68..3a71ca5ddb 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 @@ -1,3 +1,18 @@ +/** + * 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.customerSmoke; import io.qameta.allure.Description; @@ -6,30 +21,32 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.CustomerPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; +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 org.thingsboard.server.msa.ui.utils.DataProviderCredential; -import static org.thingsboard.server.msa.ui.utils.Const.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class SortByNameTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private CustomerPageHelperAbstract customerPage; + private CustomerPageHelper customerPage; private String customerName; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - customerPage = new CustomerPageHelperAbstract(driver); + customerPage = new CustomerPageHelper(driver); } @AfterMethod public void delete() { if (customerName != null) { - customerPage.deleteCustomer(customerName); + testRestClient.deleteCustomer(getCustomerByName(customerName).getId()); customerName = null; } } @@ -37,12 +54,12 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") @Description public void specialCharacterUp(String title) { - customerPage.createCustomer(title); + customerName = title; + testRestClient.postCustomer(defaultCustomerPrototype(title)); sideBarMenuView.customerBtn().click(); customerPage.sortByTitleBtn().click(); customerPage.setCustomerName(); - customerName = title; Assert.assertEquals(customerPage.getCustomerName(), title); } @@ -50,9 +67,9 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") @Description public void allSortUp(String customer, String customerSymbol, String customerNumber) { - customerPage.createCustomer(customerSymbol); - customerPage.createCustomer(customer); - customerPage.createCustomer(customerNumber); + testRestClient.postCustomer(defaultCustomerPrototype(customerSymbol)); + testRestClient.postCustomer(defaultCustomerPrototype(customer)); + testRestClient.postCustomer(defaultCustomerPrototype(customerNumber)); sideBarMenuView.customerBtn().click(); customerPage.sortByTitleBtn().click(); @@ -67,9 +84,9 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { boolean secondEquals = secondCustomer.equals(customerNumber); boolean thirdEquals = thirdCustomer.equals(customer); - customerPage.deleteCustomer(customer); - customerPage.deleteCustomer(customerNumber); - customerPage.deleteCustomer(customerSymbol); + testRestClient.deleteCustomer(getCustomerByName(customer).getId()); + testRestClient.deleteCustomer(getCustomerByName(customerNumber).getId()); + testRestClient.deleteCustomer(getCustomerByName(customerSymbol).getId()); Assert.assertTrue(firstEquals); Assert.assertTrue(secondEquals); @@ -79,12 +96,12 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") @Description public void specialCharacterDown(String title) { - customerPage.createCustomer(title); + customerName = title; + testRestClient.postCustomer(defaultCustomerPrototype(title)); sideBarMenuView.customerBtn().click(); customerPage.sortByNameDown(); customerPage.setCustomerName(customerPage.allEntity().size() - 1); - customerName = title; Assert.assertEquals(customerPage.getCustomerName(), title); } @@ -92,9 +109,9 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") @Description public void allSortDown(String customer, String customerSymbol, String customerNumber) { - customerPage.createCustomer(customerSymbol); - customerPage.createCustomer(customer); - customerPage.createCustomer(customerNumber); + testRestClient.postCustomer(defaultCustomerPrototype(customerSymbol)); + testRestClient.postCustomer(defaultCustomerPrototype(customer)); + testRestClient.postCustomer(defaultCustomerPrototype(customerNumber)); sideBarMenuView.customerBtn().click(); int lastIndex = customerPage.allEntity().size() - 1; @@ -110,9 +127,9 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { boolean secondEquals = secondCustomer.equals(customerNumber); boolean thirdEquals = thirdCustomer.equals(customer); - customerPage.deleteCustomer(customer); - customerPage.deleteCustomer(customerNumber); - customerPage.deleteCustomer(customerSymbol); + testRestClient.deleteCustomer(getCustomerByName(customer).getId()); + testRestClient.deleteCustomer(getCustomerByName(customerNumber).getId()); + testRestClient.deleteCustomer(getCustomerByName(customerSymbol).getId()); Assert.assertTrue(firstEquals); Assert.assertTrue(secondEquals); 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 2b05fb8867..a027267469 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -6,17 +21,20 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelper; +import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelper; +import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; +import java.util.ArrayList; + import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class CreateRuleChainImportAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class CreateRuleChainImportTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; - private OpenRuleChainPageHelperAbstract openRuleChainPage; + private RuleChainsPageHelper ruleChainsPage; + private OpenRuleChainPageHelper openRuleChainPage; private final String absolutePathToFileImportRuleChain = getClass().getClassLoader().getResource(IMPORT_RULE_CHAIN_FILE_NAME).getPath(); private final String absolutePathToFileImportTxt = getClass().getClassLoader().getResource(IMPORT_TXT_FILE_NAME).getPath(); private String ruleChainName; @@ -24,22 +42,23 @@ public class CreateRuleChainImportAbstractDiverBaseTest extends AbstractDiverBas @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); - openRuleChainPage = new OpenRuleChainPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); + openRuleChainPage = new OpenRuleChainPageHelper(driver); } @AfterMethod public void delete() { if (ruleChainName != null) { - ruleChainsPage.deleteRuleChain(ruleChainName); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); ruleChainName = null; } } @Test(priority = 10, groups = "smoke") - @Description("Can drop a JSON file and import it") + @Description public void importRuleChain() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openImportRuleChainView(); @@ -50,7 +69,7 @@ public class CreateRuleChainImportAbstractDiverBaseTest extends AbstractDiverBas } @Test(priority = 20, groups = "smoke") - @Description("Can delete a file by clicking on the icon Remove") + @Description public void importRuleChainAndDeleteFile() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openImportRuleChainView(); @@ -63,7 +82,7 @@ public class CreateRuleChainImportAbstractDiverBaseTest extends AbstractDiverBas } @Test(priority = 20, groups = "smoke") - @Description("Can`t Select / drop a file of a different format than JSON") + @Description public void importTxtFile() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openImportRuleChainView(); @@ -74,7 +93,7 @@ public class CreateRuleChainImportAbstractDiverBaseTest extends AbstractDiverBas } @Test(priority = 30, groups = "smoke") - @Description("After clicking on Import - imported rule chain opens (need to save by clicking on the Apply changes icon)") + @Description public void importRuleChainAndSave() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openImportRuleChainView(); @@ -90,9 +109,11 @@ public class CreateRuleChainImportAbstractDiverBaseTest extends AbstractDiverBas } @Test(priority = 40, groups = "smoke") - @Description("Can create a rule chain with the same name") + @Description public void importRuleChainAndSaveWithSameName() { - ruleChainsPage.createRuleChain(IMPORT_RULE_CHAIN_NAME); + ruleChainName = IMPORT_RULE_CHAIN_NAME; + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); + ; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openImportRuleChainView(); @@ -101,10 +122,16 @@ public class CreateRuleChainImportAbstractDiverBaseTest extends AbstractDiverBas openRuleChainPage.doneBtn().click(); openRuleChainPage.waitUntilDoneBtnDisable(); sideBarMenuView.ruleChainsBtn().click(); - boolean sizeBigger1 = ruleChainsPage.entities(IMPORT_RULE_CHAIN_NAME).size() > 1; - ruleChainsPage.deleteAllRuleChain(IMPORT_RULE_CHAIN_NAME); + boolean entityNotNull = ruleChainsPage.entity(ruleChainName) != null; + boolean entitiesSizeMoreOne = ruleChainsPage.entities(ruleChainName).size() > 1; + ArrayList entityIsDisplayed = new ArrayList<>(); + ruleChainsPage.entities(ruleChainName).forEach(x -> entityIsDisplayed.add(x.isDisplayed())); + + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); - Assert.assertTrue(sizeBigger1); + Assert.assertTrue(entityNotNull); + Assert.assertTrue(entitiesSizeMoreOne); + entityIsDisplayed.forEach(Assert::assertTrue); } } 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 32470c86f9..d3d71a45b0 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -6,54 +21,57 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.EntityPrototypes; + +import java.util.ArrayList; import static org.thingsboard.server.msa.ui.utils.Const.*; -public class CreateRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class CreateRuleChainTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; + private RuleChainsPageHelper ruleChainsPage; private String ruleChainName; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @AfterMethod public void delete() { if (ruleChainName != null) { - ruleChainsPage.deleteRuleChain(ruleChainName); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); ruleChainName = null; } } @Test(priority = 10, groups = "smoke") - @Description("Can click on Add after specifying the name (text/numbers /special characters)") + @Description public void createRuleChain() { - String ruleChainName = ENTITY_NAME; + ruleChainName = ENTITY_NAME; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); ruleChainsPage.nameField().sendKeys(ruleChainName); ruleChainsPage.addBtnC().click(); ruleChainsPage.refreshBtn().click(); - this.ruleChainName = ruleChainName; Assert.assertNotNull(ruleChainsPage.entity(ruleChainName)); Assert.assertTrue(ruleChainsPage.entity(ruleChainName).isDisplayed()); } @Test(priority = 10, groups = "smoke") - @Description() + @Description public void createRuleChainWithDescription() { - String ruleChainName = ENTITY_NAME; + ruleChainName = ENTITY_NAME; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); @@ -63,14 +81,13 @@ public class CreateRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest ruleChainsPage.refreshBtn().click(); ruleChainsPage.entity(ENTITY_NAME).click(); ruleChainsPage.setHeaderName(); - this.ruleChainName = ruleChainName; Assert.assertEquals(ruleChainsPage.getHeaderName(), ruleChainName); Assert.assertEquals(ruleChainsPage.descriptionEntityView().getAttribute("value"), ruleChainName); } @Test(priority = 20, groups = "smoke") - @Description("Can`t add rule chain without the name (empty field or just space)") + @Description public void createRuleChainWithoutName() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); @@ -79,7 +96,7 @@ public class CreateRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description() + @Description public void createRuleChainWithOnlySpace() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); @@ -94,38 +111,45 @@ public class CreateRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description("Can create a rule chain with the same name") + @Description public void createRuleChainWithSameName() { + ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(ruleChainName)); + sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.setRuleChainNameWithoutRoot(); ruleChainsPage.openCreateRuleChainView(); - String ruleChainName = ruleChainsPage.getRuleChainName(); ruleChainsPage.nameField().sendKeys(ruleChainName); ruleChainsPage.addBtnC().click(); ruleChainsPage.refreshBtn().click(); - this.ruleChainName = ruleChainName; - Assert.assertNotNull(ruleChainsPage.entity(ruleChainName)); - Assert.assertTrue(ruleChainsPage.entities(ruleChainName).size() > 1); + boolean entityNotNull = ruleChainsPage.entity(ruleChainName) != null; + boolean entitiesSizeMoreOne = ruleChainsPage.entities(ruleChainName).size() > 1; + ArrayList entityIsDisplayed = new ArrayList<>(); + ruleChainsPage.entities(ruleChainName).forEach(x -> entityIsDisplayed.add(x.isDisplayed())); + + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); + + Assert.assertTrue(entityNotNull); + Assert.assertTrue(entitiesSizeMoreOne); + entityIsDisplayed.forEach(Assert::assertTrue); } @Test(priority = 30, groups = "smoke") - @Description("After clicking on Add - appears immediately in the list (no need to refresh the page)") + @Description public void createRuleChainWithoutRefresh() { - String ruleChainName = ENTITY_NAME; + ruleChainName = ENTITY_NAME; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); ruleChainsPage.nameField().sendKeys(ruleChainName); ruleChainsPage.addBtnC().click(); - this.ruleChainName = ruleChainName; Assert.assertNotNull(ruleChainsPage.entity(ruleChainName)); Assert.assertTrue(ruleChainsPage.entity(ruleChainName).isDisplayed()); } @Test(priority = 40, groups = "smoke") - @Description("Question mark icon leads to rule chain documentation (PE)") + @Description public void documentation() { String urlPath = "docs/user-guide/ui/rule-chains/"; 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 f2fe8c7c1c..92da98af1b 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -5,41 +20,44 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class DeleteRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class DeleteRuleChainTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; + private RuleChainsPageHelper ruleChainsPage; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @Test(priority = 10, groups = "smoke") - @Description("Can remove the rule chain by clicking on the trash can icon in the right corner") + @Description public void removeRuleChainByRightSideBtn() { - ruleChainsPage.createRuleChain(ENTITY_NAME); + String ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); - String deletedRuleChain = ruleChainsPage.deleteRuleChainTrash(ENTITY_NAME); + String deletedRuleChain = ruleChainsPage.deleteRuleChainTrash(ruleChainName); ruleChainsPage.refreshBtn().click(); Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedRuleChain)); } @Test(priority = 20, groups = "smoke") - @Description("Can mark the rule chain in the checkbox and then click on the trash can icon in the menu that appears at the top") + @Description public void removeSelectedRuleChain() { String ruleChainName = ENTITY_NAME; - ruleChainsPage.createRuleChain(ruleChainName); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); String deletedRuleChain = ruleChainsPage.deleteSelected(ruleChainName); @@ -49,20 +67,21 @@ public class DeleteRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description("Can click on the name of the rule chain and click on the 'Delete rule chain' button") + @Description public void removeFromRuleChainView() { - ruleChainsPage.createRuleChain(ENTITY_NAME); + String ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.entity(ENTITY_NAME).click(); - String deletedRuleChain = ruleChainsPage.deleteRuleChainFromView(ENTITY_NAME); + String deletedRuleChain = ruleChainsPage.deleteRuleChainFromView(ruleChainName); ruleChainsPage.refreshBtn().click(); Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedRuleChain)); } @Test(priority = 20, groups = "smoke") - @Description("Can`t remove Root Rule Chain (the trash can is disabled in the right corner)") + @Description public void removeRootRuleChain() { sideBarMenuView.ruleChainsBtn().click(); @@ -70,7 +89,7 @@ public class DeleteRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description("Can`t remove Root Rule Chain (can`t mark the rule chain in the checkbox )") + @Description public void removeSelectedRootRuleChain() { sideBarMenuView.ruleChainsBtn().click(); @@ -78,17 +97,17 @@ public class DeleteRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description("Can`t remove Root Rule Chain (missing delete button)") + @Description public void removeFromRootRuleChainView() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.entity(ROOT_RULE_CHAIN_NAME).click(); ruleChainsPage.deleteBtnFromView(); - ruleChainsPage.assertDeleteBtnInRootRuleChainIsNotDisplayed(); + Assert.assertTrue(ruleChainsPage.deleteBtnInRootRuleChainIsNotDisplayed()); } @Test(priority = 10, groups = "smoke") - @Description("Can remove the rule chain by clicking on the trash can icon in the right corner") + @Description public void removeProfileRuleChainByRightSideBtn() { String deletedRuleChain = "Thermostat"; @@ -105,7 +124,7 @@ public class DeleteRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description("Can mark the rule chain in the checkbox and then click on the trash can icon in the menu that appears at the top") + @Description public void removeSelectedProfileRuleChain() { sideBarMenuView.ruleChainsBtn().click(); String deletedRuleChain = ruleChainsPage.deleteSelected("Thermostat"); @@ -119,7 +138,7 @@ public class DeleteRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 20, groups = "smoke") - @Description("Can click on the name of the rule chain and click on the 'Delete rule chain' button") + @Description public void removeFromProfileRuleChainView() { String deletedRuleChain = "Thermostat"; @@ -135,10 +154,10 @@ public class DeleteRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 30, groups = "smoke") - @Description("The rule chain is deleted immediately after clicking remove (no need to refresh the page)") + @Description public void removeRuleChainByRightSideBtnWithoutRefresh() { String ruleChainName = ENTITY_NAME; - ruleChainsPage.createRuleChain(ruleChainName); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); String deletedRuleChain = ruleChainsPage.deleteRuleChainTrash(ruleChainName); 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 8481d9cde6..5b8667580e 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -5,35 +20,36 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class DeleteSeveralRuleChainsAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class DeleteSeveralRuleChainsTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; + private RuleChainsPageHelper ruleChainsPage; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @Test(priority = 10, groups = "smoke") - @Description("Can mark several rule chains in the checkbox near the names and then click on the trash can icon in the menu that appears at the top") + @Description public void canDeleteSeveralRuleChainsByTopBtn() { String ruleChainName = ENTITY_NAME; - int count = 2; - ruleChainsPage.createRuleChains(ruleChainName, count); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName + 1)); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.clickOnCheckBoxes(count); - + ruleChainsPage.clickOnCheckBoxes(2); ruleChainsPage.deleteSelectedBtn().click(); ruleChainsPage.warningPopUpYesBtn().click(); ruleChainsPage.refreshBtn().click(); @@ -42,11 +58,11 @@ public class DeleteSeveralRuleChainsAbstractDiverBaseTest extends AbstractDiverB } @Test(priority = 10, groups = "smoke") - @Description("Can mark several rule chains in the checkbox near the names and then click on the trash can icon in the menu that appears at the top") + @Description public void selectAllRuleChain() { String ruleChainName = ENTITY_NAME; - int count = 2; - ruleChainsPage.createRuleChains(ruleChainName, count); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName + 1)); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.selectAllCheckBox().click(); @@ -58,7 +74,7 @@ public class DeleteSeveralRuleChainsAbstractDiverBaseTest extends AbstractDiverB } @Test(priority = 20, groups = "smoke") - @Description("Can`t remove Root Rule Chain (the trash can is disabled in the right corner)") + @Description public void removeRootRuleChain() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.selectAllCheckBox().click(); @@ -67,7 +83,7 @@ public class DeleteSeveralRuleChainsAbstractDiverBaseTest extends AbstractDiverB } @Test(priority = 20, groups = "smoke") - @Description("Can`t remove Root Rule Chain (can`t mark the rule chain in the checkbox )") + @Description public void removeSelectedRootRuleChain() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.selectAllCheckBox().click(); @@ -76,14 +92,14 @@ public class DeleteSeveralRuleChainsAbstractDiverBaseTest extends AbstractDiverB } @Test(priority = 30, groups = "smoke") - @Description("The rule chains are deleted immediately after clicking remove (no need to refresh the page)") + @Description public void deleteSeveralRuleChainsByTopBtnWithoutRefresh() { String ruleChainName = ENTITY_NAME; - int count = 2; - ruleChainsPage.createRuleChains(ruleChainName, count); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName + 1)); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.clickOnCheckBoxes(count); + ruleChainsPage.clickOnCheckBoxes(2); ruleChainsPage.deleteSelectedBtn().click(); ruleChainsPage.warningPopUpYesBtn().click(); 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 8a71a11232..7eb75de8f8 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -6,32 +21,33 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; -public class MakeRuleChainRootAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class MakeRuleChainRootTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; + private RuleChainsPageHelper ruleChainsPage; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @AfterMethod public void makeRoot() { - ruleChainsPage.makeRoot(); + testRestClient.setRootRuleChain(getRuleChainByName("Root Rule Chain").getId()); } @Test(priority = 10, groups = "smoke") - @Description("Can make rule chain root by clicking on the 'Make rule chain root' icon in the right corner") + @Description public void makeRuleChainRootByRightCornerBtn() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(0); @@ -43,7 +59,7 @@ public class MakeRuleChainRootAbstractDiverBaseTest extends AbstractDiverBaseTes } @Test(priority = 20, groups = "smoke") - @Description("Can make rule chain by clicking on the name/row of the rule chain and click on the 'make rule chain root' button") + @Description public void makeRuleChainRootFromView() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(0); @@ -57,11 +73,8 @@ public class MakeRuleChainRootAbstractDiverBaseTest extends AbstractDiverBaseTes } @Test(priority = 30, groups = "smoke") - @Description("Can't make multiple root rule chains (only one rule chain can be root)") + @Description public void multiplyRoot() { - SideBarMenuViewElements sideBarMenuView = new SideBarMenuViewElements(driver); - RuleChainsPageHelperAbstract ruleChainsPage = new RuleChainsPageHelperAbstract(driver); - sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(0); String ruleChain = ruleChainsPage.getRuleChainName(); 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 f38f20bdff..7810c7bf5a 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -5,30 +20,31 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +import org.thingsboard.server.msa.ui.pages.LoginPageHelper; +import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelper; +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.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; -public class OpenRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class OpenRuleChainTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; - private OpenRuleChainPageHelperAbstract openRuleChainPage; + private RuleChainsPageHelper ruleChainsPage; + private OpenRuleChainPageHelper openRuleChainPage; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); - openRuleChainPage = new OpenRuleChainPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); + openRuleChainPage = new OpenRuleChainPageHelper(driver); } @Test(priority = 10, groups = "smoke") - @Description("Can open the rule chain by clicking on the 'Open rule chain' icon in the right corner") + @Description public void openRuleChainByRightCornerBtn() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(0); @@ -36,14 +52,14 @@ public class OpenRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { ruleChainsPage.openRuleChainBtn(ruleChain).click(); openRuleChainPage.setHeadName(); - Assert.assertTrue(urlContains(ruleChainsPage.getRuleChainId(ruleChainsPage.getRuleChainName()))); + Assert.assertTrue(urlContains(String.valueOf(getRuleChainByName(ruleChainsPage.getRuleChainName()).getId()))); Assert.assertTrue(openRuleChainPage.headRuleChainName().isDisplayed()); Assert.assertTrue(openRuleChainPage.inputNode().isDisplayed()); Assert.assertEquals(ruleChainsPage.getRuleChainName(), openRuleChainPage.getHeadName()); } @Test(priority = 10, groups = "smoke") - @Description("Can open the rule chain by clicking on the name/row of the rule chain and click on the 'Open rule chain' button") + @Description public void openRuleChainByViewBtn() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(0); @@ -52,14 +68,14 @@ public class OpenRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { ruleChainsPage.openRuleChainFromViewBtn().click(); openRuleChainPage.setHeadName(); - Assert.assertTrue(urlContains(ruleChainsPage.getRuleChainId(ruleChain))); + Assert.assertTrue(urlContains(String.valueOf(getRuleChainByName(ruleChainsPage.getRuleChainName()).getId()))); Assert.assertTrue(openRuleChainPage.headRuleChainName().isDisplayed()); Assert.assertTrue(openRuleChainPage.inputNode().isDisplayed()); Assert.assertEquals(ruleChain, openRuleChainPage.getHeadName()); } @Test(priority = 20, groups = "smoke") - @Description("Can`t open the rule chain by clicking twice on the row/name") + @Description public void openRuleChainDoubleClick() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(0); 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 9a080d7435..12e442c3b0 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -6,38 +21,41 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class RuleChainEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class RuleChainEditMenuTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; + private RuleChainsPageHelper ruleChainsPage; private String ruleChainName; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @AfterMethod public void delete() { if (ruleChainName != null) { - ruleChainsPage.deleteRuleChain(ruleChainName); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); ruleChainName = null; } } @Test(priority = 10, groups = "smoke") - @Description("Can click by pencil icon and edit the name (change the name) and save the changes. All changes have been applied") + @Description public void changeName() { - ruleChainsPage.createRuleChain(ENTITY_NAME); + testRestClient.postRuleChain(defaultRuleChainPrototype(ENTITY_NAME)); + ; String name = "Changed"; sideBarMenuView.ruleChainsBtn().click(); @@ -56,7 +74,7 @@ public class RuleChainEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTes } @Test(priority = 20, groups = "smoke") - @Description("Can`t delete the name and save changes") + @Description public void deleteName() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.notRootRuleChainsNames().get(0).click(); @@ -67,7 +85,7 @@ public class RuleChainEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTes } @Test(priority = 20, groups = "smoke") - @Description("Can`t save just a space in the name") + @Description public void saveOnlyWithSpace() { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.notRootRuleChainsNames().get(0).click(); @@ -81,10 +99,10 @@ public class RuleChainEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTes } @Test(priority = 20, groups = "smoke") - @Description("Can write/change/delete the descriptionEntityView and save the changes. All changes have been applied") + @Description public void editDescription() { - String name = ENTITY_NAME; - ruleChainsPage.createRuleChain(name); + ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); String description = "Description"; sideBarMenuView.ruleChainsBtn().click(); @@ -100,7 +118,6 @@ public class RuleChainEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTes ruleChainsPage.editPencilBtn().click(); ruleChainsPage.changeDescription(""); ruleChainsPage.doneBtnEditView().click(); - ruleChainName = name; Assert.assertTrue(ruleChainsPage.descriptionEntityView().getAttribute("value").isEmpty()); Assert.assertEquals(description, description1); @@ -108,10 +125,10 @@ public class RuleChainEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTes } @Test(priority = 20, groups = "smoke") - @Description("Can enable / disable debug and save changes. All changes have been applied") + @Description public void debugMode() { - String name = ENTITY_NAME; - ruleChainsPage.createRuleChain(name); + ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.notRootRuleChainsNames().get(0).click(); @@ -122,7 +139,6 @@ public class RuleChainEditMenuAbstractDiverBaseTest extends AbstractDiverBaseTes ruleChainsPage.editPencilBtn().click(); ruleChainsPage.debugCheckboxEdit().click(); ruleChainsPage.doneBtnEditView().click(); - ruleChainName = name; Assert.assertFalse(Boolean.parseBoolean(ruleChainsPage.debugCheckboxView().getAttribute("aria-checked"))); Assert.assertTrue(debugMode); 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 0a8dc6d96b..f39d54cd63 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -5,28 +20,30 @@ import org.testng.Assert; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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 static org.thingsboard.server.msa.ui.utils.Const.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class SearchRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class SearchRuleChainTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; + private RuleChainsPageHelper ruleChainsPage; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "ruleChainNameForSearchByFirstAndSecondWord") - @Description("Can search by the first/second word of the name") + @Description public void searchFirstWord(String namePath) { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.searchEntity(namePath); @@ -36,16 +53,16 @@ public class SearchRuleChainAbstractDiverBaseTest extends AbstractDiverBaseTest } @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSearchBySymbolAndNumber") - @Description("Can search by number/symbol") + @Description public void searchNumber(String name, String namePath) { - ruleChainsPage.createRuleChain(name); + testRestClient.postRuleChain(defaultRuleChainPrototype(name)); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.searchEntity(namePath); ruleChainsPage.setRuleChainName(0); boolean ruleChainContainsNamePath = ruleChainsPage.getRuleChainName().contains(namePath); - ruleChainsPage.deleteRuleChain(name); + testRestClient.deleteRuleChain(getRuleChainByName(name).getId()); Assert.assertTrue(ruleChainContainsNamePath); } 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 a8f381c494..1a11ed9552 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -6,31 +21,33 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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 static org.thingsboard.server.msa.ui.utils.Const.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class SortByNameTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; + private RuleChainsPageHelper ruleChainsPage; private String ruleChainName; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @AfterMethod public void delete() { if (ruleChainName != null) { - ruleChainsPage.deleteRuleChain(ruleChainName); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); ruleChainName = null; } } @@ -38,7 +55,8 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") @Description public void specialCharacterUp(String ruleChainName) { - ruleChainsPage.createRuleChain(ruleChainName); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); + ; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.sortByNameBtn().click(); @@ -51,9 +69,9 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") @Description public void allSortUp(String ruleChain, String ruleChainSymbol, String ruleChainNumber) { - ruleChainsPage.createRuleChain(ruleChainSymbol); - ruleChainsPage.createRuleChain(ruleChain); - ruleChainsPage.createRuleChain(ruleChainNumber); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainSymbol)); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChain)); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainNumber)); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.sortByNameBtn().click(); @@ -68,9 +86,9 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { boolean secondEquals = secondRuleChain.equals(ruleChainNumber); boolean thirdEquals = thirdRuleChain.equals(ruleChain); - ruleChainsPage.deleteRuleChain(ruleChain); - ruleChainsPage.deleteRuleChain(ruleChainNumber); - ruleChainsPage.deleteRuleChain(ruleChainSymbol); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChain).getId()); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainNumber).getId()); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainSymbol).getId()); Assert.assertTrue(firstEquals); Assert.assertTrue(secondEquals); @@ -80,7 +98,7 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { @Test(priority = 10, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForSort") @Description public void specialCharacterDown(String ruleChainName) { - ruleChainsPage.createRuleChain(ruleChainName); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.sortByNameDown(); @@ -93,9 +111,9 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "nameForAllSort") @Description public void allSortDown(String ruleChain, String ruleChainSymbol, String ruleChainNumber) { - ruleChainsPage.createRuleChain(ruleChainSymbol); - ruleChainsPage.createRuleChain(ruleChain); - ruleChainsPage.createRuleChain(ruleChainNumber); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainSymbol)); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChain)); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainNumber)); sideBarMenuView.ruleChainsBtn().click(); int lastIndex = ruleChainsPage.allNames().size() - 1; @@ -111,9 +129,9 @@ public class SortByNameAbstractDiverBaseTest extends AbstractDiverBaseTest { boolean secondEquals = secondRuleChain.equals(ruleChainNumber); boolean thirdEquals = thirdRuleChain.equals(ruleChain); - ruleChainsPage.deleteRuleChain(ruleChain); - ruleChainsPage.deleteRuleChain(ruleChainNumber); - ruleChainsPage.deleteRuleChain(ruleChainSymbol); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChain).getId()); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainNumber).getId()); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainSymbol).getId()); Assert.assertTrue(firstEquals); Assert.assertTrue(secondEquals); 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 3fc33e3ac0..d05bd11b39 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 @@ -1,3 +1,18 @@ +/** + * 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.ruleChainsSmoke; import io.qameta.allure.Description; @@ -6,31 +21,32 @@ import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; -import org.thingsboard.server.msa.ui.pages.LoginPageHelperAbstract; -import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelperAbstract; +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.ENTITY_NAME; -import static org.thingsboard.server.msa.ui.utils.Const.URL; +import static org.thingsboard.server.msa.ui.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class SortByTimeAbstractDiverBaseTest extends AbstractDiverBaseTest { +public class SortByTimeTest extends AbstractDiverBaseTest { private SideBarMenuViewElements sideBarMenuView; - private RuleChainsPageHelperAbstract ruleChainsPage; + private RuleChainsPageHelper ruleChainsPage; private String ruleChainName; @BeforeMethod public void login() { openUrl(URL); - new LoginPageHelperAbstract(driver).authorizationTenant(); + new LoginPageHelper(driver).authorizationTenant(); + testRestClient.login(TENANT_EMAIL, TENANT_PASSWORD); sideBarMenuView = new SideBarMenuViewElements(driver); - ruleChainsPage = new RuleChainsPageHelperAbstract(driver); + ruleChainsPage = new RuleChainsPageHelper(driver); } @AfterMethod public void delete() { if (ruleChainName != null) { - ruleChainsPage.deleteRuleChain(ruleChainName); + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); ruleChainName = null; } } @@ -39,7 +55,7 @@ public class SortByTimeAbstractDiverBaseTest extends AbstractDiverBaseTest { @Description public void sortByTimeDown() { String ruleChain = ENTITY_NAME; - ruleChainsPage.createRuleChain(ruleChain); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChain)); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setSort(); @@ -55,7 +71,7 @@ public class SortByTimeAbstractDiverBaseTest extends AbstractDiverBaseTest { @Description public void sortByTimeUp() { String ruleChain = ENTITY_NAME; - ruleChainsPage.createRuleChain(ruleChain); + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChain)); sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.sortByTimeBtn().click(); 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 db6bd40084..351423d950 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 @@ -1,8 +1,23 @@ -package utils; +/** + * 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.utils; -import base.Base; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; -public class Const extends Base { +public class Const { public static final String URL = "http://localhost:8080/"; public static final String TENANT_EMAIL = "tenant@thingsboard.org"; 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 1509250abf..5536338fe5 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 @@ -1,9 +1,24 @@ -package utils; +/** + * 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.utils; import org.testng.annotations.DataProvider; -import static base.Base.getRandomSymbol; -import static utils.Const.ENTITY_NAME; +import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomSymbol; +import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME; public class DataProviderCredential { 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 683dca511c..5fcfe8f4f9 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 @@ -1,9 +1,24 @@ +/** + * 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.utils; import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.rule.RuleChain; -public class CustomerPrototypes { +public class EntityPrototypes { public static Customer defaultCustomerPrototype(String entityName){ Customer customer = new Customer(); diff --git a/msa/black-box-tests/src/test/resources/connectivity.xml b/msa/black-box-tests/src/test/resources/connectivity.xml index e69de29bb2..c2c12c4efb 100644 --- a/msa/black-box-tests/src/test/resources/connectivity.xml +++ b/msa/black-box-tests/src/test/resources/connectivity.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/forImport.txt b/msa/black-box-tests/src/test/resources/forImport.txt index e69de29bb2..908a557812 100644 --- a/msa/black-box-tests/src/test/resources/forImport.txt +++ b/msa/black-box-tests/src/test/resources/forImport.txt @@ -0,0 +1,16 @@ +==== + 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. +==== + diff --git a/msa/black-box-tests/src/test/resources/smokeTests.xml b/msa/black-box-tests/src/test/resources/smokeTests.xml index 1194791760..85080e2bfd 100644 --- a/msa/black-box-tests/src/test/resources/smokeTests.xml +++ b/msa/black-box-tests/src/test/resources/smokeTests.xml @@ -1,7 +1,7 @@ - - - - - - + + + + \ No newline at end of file diff --git a/msa/pom.xml b/msa/pom.xml index e527566683..8bc033fcbc 100644 --- a/msa/pom.xml +++ b/msa/pom.xml @@ -46,6 +46,8 @@ web-ui tb-node transport + black-box-tests + From 17d6522571aab7d997f3a9b6554ad37b15324bbb Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 22 Nov 2022 13:24:23 +0200 Subject: [PATCH 03/44] add ui tests --- msa/pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/msa/pom.xml b/msa/pom.xml index 8bc033fcbc..e527566683 100644 --- a/msa/pom.xml +++ b/msa/pom.xml @@ -46,8 +46,6 @@ web-ui tb-node transport - black-box-tests - From f3e927e9c5abfe300b3f7bdf28ccebe37988fa13 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 22 Nov 2022 18:12:19 +0200 Subject: [PATCH 04/44] updated README.md --- msa/black-box-tests/README.md | 7 ++++++- msa/black-box-tests/src/test/resources/testNG.xml | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/msa/black-box-tests/README.md b/msa/black-box-tests/README.md index a60e7405a8..856bd08f4a 100644 --- a/msa/black-box-tests/README.md +++ b/msa/black-box-tests/README.md @@ -30,9 +30,14 @@ As result, in REPOSITORY column, next images should be present: mvn clean install -DblackBoxTests.skip=false -DblackBoxTests.hybridMode=true -To run the black box tests with using local env run tests in the [msa/black-box-tests](../black-box-tests) directory with runLocal property: +- To run the black box tests with using local env run tests in the [msa/black-box-tests](../black-box-tests) directory with runLocal property: mvn clean install -DblackBoxTests.skip=false -DrunLocal=true +- To run ui tests run tests in the [msa/black-box-tests](../black-box-tests) directory specifying suiteFile property: + + mvn clean install -DblackBoxTests.skip=false -DsuiteFile=src/test/resources/smokeTests.xml + + diff --git a/msa/black-box-tests/src/test/resources/testNG.xml b/msa/black-box-tests/src/test/resources/testNG.xml index f94bc7485c..45e93f76f1 100644 --- a/msa/black-box-tests/src/test/resources/testNG.xml +++ b/msa/black-box-tests/src/test/resources/testNG.xml @@ -17,9 +17,11 @@ --> + - - - - + + + + + \ No newline at end of file From ca4ae89367f006a1775487a599575a6410d7daac Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Thu, 24 Nov 2022 17:21:22 +0200 Subject: [PATCH 05/44] add chrome options for run in https --- msa/black-box-tests/README.md | 2 +- msa/black-box-tests/pom.xml | 18 +++++----------- .../msa/ui/base/AbstractDiverBaseTest.java | 5 ++++- .../server/msa/ui/utils/Const.java | 3 ++- pom.xml | 21 +++++++++++++++++++ 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/msa/black-box-tests/README.md b/msa/black-box-tests/README.md index 856bd08f4a..c91e1203fb 100644 --- a/msa/black-box-tests/README.md +++ b/msa/black-box-tests/README.md @@ -34,7 +34,7 @@ As result, in REPOSITORY column, next images should be present: mvn clean install -DblackBoxTests.skip=false -DrunLocal=true -- To run ui tests run tests in the [msa/black-box-tests](../black-box-tests) directory specifying suiteFile property: +- To run ui smoke tests in the [msa/black-box-tests](../black-box-tests) directory specifying suiteFile property: mvn clean install -DblackBoxTests.skip=false -DsuiteFile=src/test/resources/smokeTests.xml diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml index c6952f05ba..f99fb21343 100644 --- a/msa/black-box-tests/pom.xml +++ b/msa/black-box-tests/pom.xml @@ -34,6 +34,7 @@ UTF-8 ${basedir}/../.. + src/test/resources/testNG.xml @@ -163,28 +164,19 @@ org.seleniumhq.selenium selenium-java - 4.5.3 + test io.github.bonigarcia webdrivermanager - 5.3.0 + test io.qameta.allure allure-testng - 2.19.0 + test - - - - com.google.guava - guava - 31.0.1-jre - - - @@ -192,7 +184,7 @@ maven-surefire-plugin - src/test/resources/testNG.xml + ${suiteFile} ${blackBoxTests.skip} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java index 4079ec264c..438443cfde 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java @@ -56,14 +56,17 @@ abstract public class AbstractDiverBaseTest extends AbstractContainerTest { log.info("*----------------------* Setup driver *----------------------*"); if (HEADLESS == true) { ChromeOptions options = new ChromeOptions(); + options.addArguments("--ignore-certificate-errors"); options.addArguments("--no-sandbox"); options.addArguments("--disable-dev-shm-usage"); options.addArguments("--headless"); WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(options); } else { + ChromeOptions options = new ChromeOptions(); + options.addArguments("--ignore-certificate-errors"); WebDriverManager.chromedriver().setup(); - driver = new ChromeDriver(); + driver = new ChromeDriver(options); } driver.manage().window().setSize(dimension); } 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 351423d950..8868d53768 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 @@ -15,11 +15,12 @@ */ package org.thingsboard.server.msa.ui.utils; +import static org.thingsboard.server.msa.TestProperties.getBaseUrl; import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; public class Const { - public static final String URL = "http://localhost:8080/"; + 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(); diff --git a/pom.xml b/pom.xml index 411e9be7cc..c23e4cf661 100755 --- a/pom.xml +++ b/pom.xml @@ -144,6 +144,9 @@ 6.1.0.202203080745-r 0.4.8 1.0.0 + 4.1.1 + 5.3.0 + 2.19.0 @@ -1656,6 +1659,24 @@ ${rest-assured.version} test + + org.seleniumhq.selenium + selenium-java + ${selenium.version} + test + + + io.github.bonigarcia + webdrivermanager + ${webdrivermanager.version} + test + + + io.qameta.allure + allure-testng + ${allure-testng.version} + test + org.hamcrest hamcrest-all From b02f6bc9b35ba481d90966d5d56ff8f9c7b15b99 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Mon, 28 Nov 2022 12:52:12 +0200 Subject: [PATCH 06/44] remove imports with '*' --- .../msa/ui/tests/customerSmoke/CreateCustomerTest.java | 7 ++++++- .../msa/ui/tests/customerSmoke/CustomerEditMenuTest.java | 7 ++++++- .../msa/ui/tests/customerSmoke/DeleteCustomerTest.java | 5 ++++- .../ui/tests/customerSmoke/DeleteSeveralCustomerTest.java | 5 ++++- .../msa/ui/tests/customerSmoke/SearchCustomerTest.java | 4 +++- .../server/msa/ui/tests/customerSmoke/SortByNameTest.java | 4 +++- .../tests/ruleChainsSmoke/CreateRuleChainImportTest.java | 8 +++++++- .../msa/ui/tests/ruleChainsSmoke/CreateRuleChainTest.java | 6 +++++- .../msa/ui/tests/ruleChainsSmoke/DeleteRuleChainTest.java | 7 ++++++- .../ruleChainsSmoke/DeleteSeveralRuleChainsTest.java | 6 +++++- .../ui/tests/ruleChainsSmoke/MakeRuleChainRootTest.java | 4 +++- .../msa/ui/tests/ruleChainsSmoke/OpenRuleChainTest.java | 4 +++- .../ui/tests/ruleChainsSmoke/RuleChainEditMenuTest.java | 7 +++++-- .../msa/ui/tests/ruleChainsSmoke/SearchRuleChainTest.java | 4 +++- .../msa/ui/tests/ruleChainsSmoke/SortByNameTest.java | 4 +++- .../msa/ui/tests/ruleChainsSmoke/SortByTimeTest.java | 5 ++++- 16 files changed, 70 insertions(+), 17 deletions(-) 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 9a604416d9..a8f2a34659 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 @@ -25,7 +25,12 @@ 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.utils.Const.*; +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; +import static org.thingsboard.server.msa.ui.utils.Const.URL; public class CreateCustomerTest extends AbstractDiverBaseTest { 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 2bfd157773..289a8d02df 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 @@ -28,7 +28,12 @@ import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import org.thingsboard.server.msa.ui.utils.DataProviderCredential; import static org.thingsboard.server.msa.ui.base.AbstractBasePage.getRandomNumber; -import static org.thingsboard.server.msa.ui.utils.Const.*; +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.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; public class CustomerEditMenuTest extends AbstractDiverBaseTest { 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 27e8605926..5fb851216d 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,7 +25,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.utils.Const.*; +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.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; public class DeleteCustomerTest extends AbstractDiverBaseTest { 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 138c563631..7afdbf7daa 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,7 +24,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.utils.Const.*; +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.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; public class DeleteSeveralCustomerTest extends AbstractDiverBaseTest { 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 97a4c6f85f..9d21d65a4f 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,7 +25,9 @@ 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.*; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; +import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; public class SearchCustomerTest extends AbstractDiverBaseTest { 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 3a71ca5ddb..5a08561e5b 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,7 +26,9 @@ 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.*; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; +import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; public class SortByNameTest extends AbstractDiverBaseTest { 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 a027267469..71f3e01f88 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 @@ -28,7 +28,13 @@ import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; import java.util.ArrayList; -import static org.thingsboard.server.msa.ui.utils.Const.*; +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.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; public class CreateRuleChainImportTest extends AbstractDiverBaseTest { 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 d3d71a45b0..716934a3a4 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,7 +28,11 @@ import org.thingsboard.server.msa.ui.utils.EntityPrototypes; import java.util.ArrayList; -import static org.thingsboard.server.msa.ui.utils.Const.*; +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.Const.URL; public class CreateRuleChainTest extends AbstractDiverBaseTest { 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 92da98af1b..8a8c40d64d 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,7 +24,12 @@ 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.*; +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.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; public class DeleteRuleChainTest extends AbstractDiverBaseTest { 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 5b8667580e..9d4be40ec0 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,7 +24,11 @@ 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.*; +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.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; public class DeleteSeveralRuleChainsTest extends AbstractDiverBaseTest { 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 7eb75de8f8..a0d2a3ac9f 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,7 +25,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.utils.Const.*; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; +import static org.thingsboard.server.msa.ui.utils.Const.URL; public class MakeRuleChainRootTest extends AbstractDiverBaseTest { 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 7810c7bf5a..9e63bc95f0 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 @@ -25,7 +25,9 @@ import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelper; 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.*; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; +import static org.thingsboard.server.msa.ui.utils.Const.URL; public class OpenRuleChainTest extends AbstractDiverBaseTest { 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 12e442c3b0..84812f31ea 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 @@ -25,7 +25,11 @@ 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.*; +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.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; public class RuleChainEditMenuTest extends AbstractDiverBaseTest { @@ -55,7 +59,6 @@ public class RuleChainEditMenuTest extends AbstractDiverBaseTest { @Description public void changeName() { testRestClient.postRuleChain(defaultRuleChainPrototype(ENTITY_NAME)); - ; String name = "Changed"; sideBarMenuView.ruleChainsBtn().click(); 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 f39d54cd63..a214ee2396 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,7 +25,9 @@ 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.*; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; +import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; public class SearchRuleChainTest extends AbstractDiverBaseTest { 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 1a11ed9552..fa2bf82a32 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,7 +26,9 @@ 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.*; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; +import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; +import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; public class SortByNameTest extends AbstractDiverBaseTest { 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 d05bd11b39..3d3d0f572b 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 @@ -25,7 +25,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.utils.Const.*; +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.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; public class SortByTimeTest extends AbstractDiverBaseTest { From de4cc224a6f0ca11ec6eabc6b898376a44e22f54 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 29 Nov 2022 16:12:12 +0200 Subject: [PATCH 07/44] add suite for all tests --- msa/black-box-tests/README.md | 8 ++++-- msa/black-box-tests/pom.xml | 4 +-- .../msa/ui/pages/CustomerPageElements.java | 5 ++++ .../customerSmoke/CustomerEditMenuTest.java | 1 - .../customerSmoke/DeleteCustomerTest.java | 7 ++--- .../CreateRuleChainImportTest.java | 3 +-- .../src/test/resources/all.xml | 26 +++++++++++++++++++ .../resources/{testNG.xml => blackBox.xml} | 0 .../resources/{smokeTests.xml => uiTests.xml} | 2 +- 9 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 msa/black-box-tests/src/test/resources/all.xml rename msa/black-box-tests/src/test/resources/{testNG.xml => blackBox.xml} (100%) rename msa/black-box-tests/src/test/resources/{smokeTests.xml => uiTests.xml} (95%) diff --git a/msa/black-box-tests/README.md b/msa/black-box-tests/README.md index c91e1203fb..a4bbe48961 100644 --- a/msa/black-box-tests/README.md +++ b/msa/black-box-tests/README.md @@ -34,9 +34,13 @@ As result, in REPOSITORY column, next images should be present: mvn clean install -DblackBoxTests.skip=false -DrunLocal=true -- To run ui smoke tests in the [msa/black-box-tests](../black-box-tests) directory specifying suiteFile property: +- To run ui smoke tests in the [msa/black-box-tests](../black-box-tests) directory specifying suite name: - mvn clean install -DblackBoxTests.skip=false -DsuiteFile=src/test/resources/smokeTests.xml + mvn clean install -DblackBoxTests.skip=false -Dsuite=uiTests + +- To run all tests in the [msa/black-box-tests](../black-box-tests) directory specifying suite name: + + mvn clean install -DblackBoxTests.skip=false -Dsuite=all diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml index f99fb21343..380f9abbaa 100644 --- a/msa/black-box-tests/pom.xml +++ b/msa/black-box-tests/pom.xml @@ -34,7 +34,7 @@ UTF-8 ${basedir}/../.. - src/test/resources/testNG.xml + blackBox @@ -184,7 +184,7 @@ maven-surefire-plugin - ${suiteFile} + src/test/resources/${suite}.xml ${blackBoxTests.skip} diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java index e10fb7d1ed..05da22e4db 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/pages/CustomerPageElements.java @@ -70,6 +70,7 @@ public class CustomerPageElements extends OtherPageElementsHelper { private static final String MANAGE_CUSTOMERS_DEVICE_BTN_VIEW = "Manage devices"; private static final String MANAGE_CUSTOMERS_DASHBOARD_BTN_VIEW = "Manage dashboards"; private static final String MANAGE_CUSTOMERS_EDGE_BTN_VIEW = "Manage edges "; + private static final String DELETE_FROM_VIEW_BTN = "//tb-customer//span[contains(text(),' Delete')]"; public WebElement titleFieldAddEntityView() { return waitUntilElementToBeClickable(ADD_ENTITY_VIEW + String.format(INPUT_FIELD, INPUT_FIELD_NAME_TITLE)); @@ -274,4 +275,8 @@ public class CustomerPageElements extends OtherPageElementsHelper { public WebElement manageCustomersEdgeBtnView() { return waitUntilElementToBeClickable(String.format(MANAGE_BTN_VIEW, MANAGE_CUSTOMERS_EDGE_BTN_VIEW)); } + + public WebElement customerViewDeleteBtn() { + return waitUntilElementToBeClickable(DELETE_FROM_VIEW_BTN); + } } 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 289a8d02df..582a2f797f 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 @@ -256,7 +256,6 @@ public class CustomerEditMenuTest extends AbstractDiverBaseTest { public void addAllInformation() { customerName = ENTITY_NAME; testRestClient.postCustomer(defaultCustomerPrototype(customerName)); - ; String text = "Text"; String email = "email@mail.com"; String number = "2015550123"; 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 5fb851216d..d801b58638 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 @@ -81,10 +81,11 @@ public class DeleteCustomerTest extends AbstractDiverBaseTest { sideBarMenuView.customerBtn().click(); customerPage.entity(customerName).click(); - String deletedCustomer = ruleChainsPage.deleteRuleChainFromView(customerName); - ruleChainsPage.refreshBtn().click(); + customerPage.customerViewDeleteBtn().click(); + customerPage.warningPopUpYesBtn().click(); + customerPage.refreshBtn().click(); - Assert.assertTrue(ruleChainsPage.entityIsNotPresent(deletedCustomer)); + Assert.assertTrue(customerPage.entityIsNotPresent(customerName)); } @Test(priority = 20, groups = "smoke") 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 71f3e01f88..cff351387e 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 @@ -101,6 +101,7 @@ public class CreateRuleChainImportTest extends AbstractDiverBaseTest { @Test(priority = 30, groups = "smoke") @Description public void importRuleChainAndSave() { + ruleChainName = IMPORT_RULE_CHAIN_NAME; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openImportRuleChainView(); ruleChainsPage.browseFile().sendKeys(absolutePathToFileImportRuleChain); @@ -108,7 +109,6 @@ public class CreateRuleChainImportTest extends AbstractDiverBaseTest { openRuleChainPage.doneBtn().click(); openRuleChainPage.waitUntilDoneBtnDisable(); sideBarMenuView.ruleChainsBtn().click(); - ruleChainName = IMPORT_RULE_CHAIN_NAME; Assert.assertNotNull(ruleChainsPage.entity(IMPORT_RULE_CHAIN_NAME)); Assert.assertTrue(ruleChainsPage.entity(IMPORT_RULE_CHAIN_NAME).isDisplayed()); @@ -119,7 +119,6 @@ public class CreateRuleChainImportTest extends AbstractDiverBaseTest { public void importRuleChainAndSaveWithSameName() { ruleChainName = IMPORT_RULE_CHAIN_NAME; testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); - ; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openImportRuleChainView(); diff --git a/msa/black-box-tests/src/test/resources/all.xml b/msa/black-box-tests/src/test/resources/all.xml new file mode 100644 index 0000000000..3a35ec5c16 --- /dev/null +++ b/msa/black-box-tests/src/test/resources/all.xml @@ -0,0 +1,26 @@ + + + + + + + + + + \ No newline at end of file diff --git a/msa/black-box-tests/src/test/resources/testNG.xml b/msa/black-box-tests/src/test/resources/blackBox.xml similarity index 100% rename from msa/black-box-tests/src/test/resources/testNG.xml rename to msa/black-box-tests/src/test/resources/blackBox.xml diff --git a/msa/black-box-tests/src/test/resources/smokeTests.xml b/msa/black-box-tests/src/test/resources/uiTests.xml similarity index 95% rename from msa/black-box-tests/src/test/resources/smokeTests.xml rename to msa/black-box-tests/src/test/resources/uiTests.xml index 85080e2bfd..73754c8381 100644 --- a/msa/black-box-tests/src/test/resources/smokeTests.xml +++ b/msa/black-box-tests/src/test/resources/uiTests.xml @@ -18,7 +18,7 @@ --> - + From 473cfd7462cda9212510dcd547b35048abe656bd Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 29 Nov 2022 16:15:54 +0200 Subject: [PATCH 08/44] headless mode = true --- .../thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java index 438443cfde..204794b340 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java @@ -47,7 +47,7 @@ abstract public class AbstractDiverBaseTest extends AbstractContainerTest { private final Dimension dimension = new Dimension(WIDTH, HEIGHT); private static final int WIDTH = 1680; private static final int HEIGHT = 1050; - private static final boolean HEADLESS = false; + private static final boolean HEADLESS = true; protected static final PageLink pageLink = new PageLink(10); From 373db7a0864db65acaab34005ecbd097b1a6b4e7 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 29 Nov 2022 16:39:42 +0200 Subject: [PATCH 09/44] rename base ui test class --- ...tDiverBaseTest.java => AbstractDriverBaseTest.java} | 2 +- .../server/msa/ui/listeners/TestListener.java | 10 +++++----- .../msa/ui/tests/customerSmoke/CreateCustomerTest.java | 4 ++-- .../ui/tests/customerSmoke/CustomerEditMenuTest.java | 4 ++-- .../msa/ui/tests/customerSmoke/DeleteCustomerTest.java | 4 ++-- .../tests/customerSmoke/DeleteSeveralCustomerTest.java | 4 ++-- .../tests/customerSmoke/ManageCustomersAssetsTest.java | 4 ++-- .../customerSmoke/ManageCustomersDashboardsTest.java | 4 ++-- .../customerSmoke/ManageCustomersDevicesTest.java | 4 ++-- .../tests/customerSmoke/ManageCustomersEdgesTest.java | 4 ++-- .../tests/customerSmoke/ManageCustomersUsersTest.java | 4 ++-- .../msa/ui/tests/customerSmoke/SearchCustomerTest.java | 4 ++-- .../msa/ui/tests/customerSmoke/SortByNameTest.java | 4 ++-- .../ruleChainsSmoke/CreateRuleChainImportTest.java | 4 ++-- .../ui/tests/ruleChainsSmoke/CreateRuleChainTest.java | 4 ++-- .../ui/tests/ruleChainsSmoke/DeleteRuleChainTest.java | 4 ++-- .../ruleChainsSmoke/DeleteSeveralRuleChainsTest.java | 4 ++-- .../tests/ruleChainsSmoke/MakeRuleChainRootTest.java | 4 ++-- .../ui/tests/ruleChainsSmoke/OpenRuleChainTest.java | 4 ++-- .../tests/ruleChainsSmoke/RuleChainEditMenuTest.java | 4 ++-- .../ui/tests/ruleChainsSmoke/SearchRuleChainTest.java | 4 ++-- .../msa/ui/tests/ruleChainsSmoke/SortByNameTest.java | 4 ++-- .../msa/ui/tests/ruleChainsSmoke/SortByTimeTest.java | 4 ++-- 23 files changed, 48 insertions(+), 48 deletions(-) rename msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/{AbstractDiverBaseTest.java => AbstractDriverBaseTest.java} (98%) diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java similarity index 98% rename from msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java rename to msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java index 204794b340..4cb557d394 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDiverBaseTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/base/AbstractDriverBaseTest.java @@ -41,7 +41,7 @@ import java.util.stream.Collectors; @Slf4j @Listeners(TestListener.class) -abstract public class AbstractDiverBaseTest extends AbstractContainerTest { +abstract public class AbstractDriverBaseTest extends AbstractContainerTest { protected WebDriver driver; private final Dimension dimension = new Dimension(WIDTH, HEIGHT); diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java index 90ae18bec4..56b15efd67 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java @@ -22,9 +22,9 @@ import org.openqa.selenium.WebDriver; import org.testng.ITestContext; import org.testng.ITestListener; import org.testng.ITestResult; -import org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; -import static org.thingsboard.server.msa.ui.base.AbstractDiverBaseTest.captureScreen; +import static org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest.captureScreen; @Slf4j public class TestListener implements ITestListener { @@ -37,7 +37,7 @@ public class TestListener implements ITestListener { Allure.getLifecycle().updateTestCase((t) -> { t.setStatusDetails(t.getStatusDetails().setMessage(str)); }); - driver = ((AbstractDiverBaseTest) tr.getInstance()).getDriver(); + driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); captureScreen(driver, "success"); } @@ -50,7 +50,7 @@ public class TestListener implements ITestListener { t.setStatusDetails(t.getStatusDetails().setMessage(str)); t.setStatusDetails(t.getStatusDetails().setMessage(str1)); }); - driver = ((AbstractDiverBaseTest) tr.getInstance()).getDriver(); + driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); captureScreen(driver, "failure"); } @@ -63,7 +63,7 @@ public class TestListener implements ITestListener { t.setStatusDetails(t.getStatusDetails().setMessage(str)); t.setStatusDetails(t.getStatusDetails().setMessage(str1)); }); - driver = ((AbstractDiverBaseTest) tr.getInstance()).getDriver(); + driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); captureScreen(driver, "skipped"); } 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 a8f2a34659..bef792b8d0 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; @@ -32,7 +32,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; -public class CreateCustomerTest extends AbstractDiverBaseTest { +public class CreateCustomerTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; 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 582a2f797f..cd4c81b4bc 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.pages.DashboardPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; @@ -36,7 +36,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class CustomerEditMenuTest extends AbstractDiverBaseTest { +public class CustomerEditMenuTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; 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 d801b58638..66cf328552 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 @@ -19,7 +19,7 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; @@ -31,7 +31,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class DeleteCustomerTest extends AbstractDiverBaseTest { +public class DeleteCustomerTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; 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 7afdbf7daa..e1c839a347 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 @@ -19,7 +19,7 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; @@ -30,7 +30,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class DeleteSeveralCustomerTest extends AbstractDiverBaseTest { +public class DeleteSeveralCustomerTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; 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 7b85771c23..5fcafc6514 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 @@ -19,14 +19,14 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; 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.utils.Const.URL; -public class ManageCustomersAssetsTest extends AbstractDiverBaseTest { +public class ManageCustomersAssetsTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; 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 9ac2986fd0..2328298bc8 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 @@ -19,14 +19,14 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; 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.utils.Const.URL; -public class ManageCustomersDashboardsTest extends AbstractDiverBaseTest { +public class ManageCustomersDashboardsTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; private final String manage = "Dashboards"; 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 30b451899e..df04e2ad8d 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 @@ -19,14 +19,14 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; 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.utils.Const.URL; -public class ManageCustomersDevicesTest extends AbstractDiverBaseTest { +public class ManageCustomersDevicesTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; private final String manage = "Devices"; 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 044f809f77..a005760952 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 @@ -19,14 +19,14 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; 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.utils.Const.URL; -public class ManageCustomersEdgesTest extends AbstractDiverBaseTest { +public class ManageCustomersEdgesTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; 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 42d03bda1e..b0a917135a 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 @@ -19,14 +19,14 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; 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.utils.Const.URL; -public class ManageCustomersUsersTest extends AbstractDiverBaseTest { +public class ManageCustomersUsersTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; 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 9d21d65a4f..71fbae1477 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 @@ -19,7 +19,7 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; @@ -30,7 +30,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class SearchCustomerTest extends AbstractDiverBaseTest { +public class SearchCustomerTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; 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 5a08561e5b..48c1a4dc5c 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.CustomerPageHelper; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.SideBarMenuViewElements; @@ -31,7 +31,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultCustomerPrototype; -public class SortByNameTest extends AbstractDiverBaseTest { +public class SortByNameTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private CustomerPageHelper customerPage; private String customerName; 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 cff351387e..dd986e0798 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelper; import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; @@ -37,7 +37,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class CreateRuleChainImportTest extends AbstractDiverBaseTest { +public class CreateRuleChainImportTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; private OpenRuleChainPageHelper openRuleChainPage; 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 716934a3a4..b29a911e5a 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +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; @@ -34,7 +34,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; -public class CreateRuleChainTest extends AbstractDiverBaseTest { +public class CreateRuleChainTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; 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 8a8c40d64d..3f55a7a4cb 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 @@ -19,7 +19,7 @@ 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.AbstractDiverBaseTest; +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; @@ -32,7 +32,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class DeleteRuleChainTest extends AbstractDiverBaseTest { +public class DeleteRuleChainTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; 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 9d4be40ec0..bfcea53ccc 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 @@ -19,7 +19,7 @@ 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.AbstractDiverBaseTest; +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; @@ -31,7 +31,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class DeleteSeveralRuleChainsTest extends AbstractDiverBaseTest { +public class DeleteSeveralRuleChainsTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; 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 a0d2a3ac9f..9cd9bbb846 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +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; @@ -29,7 +29,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; -public class MakeRuleChainRootTest extends AbstractDiverBaseTest { +public class MakeRuleChainRootTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; 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 9e63bc95f0..4f6a2f8a1c 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 @@ -19,7 +19,7 @@ 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.AbstractDiverBaseTest; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelper; import org.thingsboard.server.msa.ui.pages.RuleChainsPageHelper; @@ -29,7 +29,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_EMAIL; import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; -public class OpenRuleChainTest extends AbstractDiverBaseTest { +public class OpenRuleChainTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; 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 84812f31ea..a0dd8f2b4b 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +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; @@ -32,7 +32,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class RuleChainEditMenuTest extends AbstractDiverBaseTest { +public class RuleChainEditMenuTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; 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 a214ee2396..d6cf13c21d 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 @@ -19,7 +19,7 @@ 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.AbstractDiverBaseTest; +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; @@ -30,7 +30,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class SearchRuleChainTest extends AbstractDiverBaseTest { +public class SearchRuleChainTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; 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 fa2bf82a32..4de0244044 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +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; @@ -31,7 +31,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class SortByNameTest extends AbstractDiverBaseTest { +public class SortByNameTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; 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 3d3d0f572b..ecba81f563 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 @@ -20,7 +20,7 @@ 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.AbstractDiverBaseTest; +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; @@ -31,7 +31,7 @@ import static org.thingsboard.server.msa.ui.utils.Const.TENANT_PASSWORD; import static org.thingsboard.server.msa.ui.utils.Const.URL; import static org.thingsboard.server.msa.ui.utils.EntityPrototypes.defaultRuleChainPrototype; -public class SortByTimeTest extends AbstractDiverBaseTest { +public class SortByTimeTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; From ea0d0418347c23db9d591da7a697592b548bec1a Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 29 Nov 2022 23:34:14 +0200 Subject: [PATCH 10/44] change webdrivermanager version --- .../server/msa/ui/tests/ruleChainsSmoke/OpenRuleChainTest.java | 2 +- pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 4f6a2f8a1c..2f0242c4fd 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 @@ -84,6 +84,6 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { String ruleChain = ruleChainsPage.getRuleChainName(); ruleChainsPage.doubleClickOnRuleChain(ruleChain); - Assert.assertEquals(getUrl(), URL + "ruleChains"); + Assert.assertEquals(getUrl(), URL + "/ruleChains"); } } diff --git a/pom.xml b/pom.xml index c23e4cf661..49f0742bc4 100755 --- a/pom.xml +++ b/pom.xml @@ -145,7 +145,7 @@ 0.4.8 1.0.0 4.1.1 - 5.3.0 + 5.2.0 2.19.0 From 9bcbfb3bd5a2b637f1345d741a0149fb5e156ffa Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Wed, 30 Nov 2022 12:05:44 +0200 Subject: [PATCH 11/44] add screenshot if headless false --- .../msa/ui/base/AbstractDriverBaseTest.java | 7 +++-- .../server/msa/ui/listeners/TestListener.java | 29 ++++++++----------- .../tests/ruleChainsSmoke/SortByNameTest.java | 1 - 3 files changed, 17 insertions(+), 20 deletions(-) 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 4cb557d394..b17b1ad95b 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 @@ -54,18 +54,17 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { @BeforeMethod public void openBrowser() { log.info("*----------------------* Setup driver *----------------------*"); + WebDriverManager.chromedriver().driverVersion("100.0.04896.20").setup(); if (HEADLESS == true) { ChromeOptions options = new ChromeOptions(); options.addArguments("--ignore-certificate-errors"); options.addArguments("--no-sandbox"); options.addArguments("--disable-dev-shm-usage"); options.addArguments("--headless"); - WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(options); } else { ChromeOptions options = new ChromeOptions(); options.addArguments("--ignore-certificate-errors"); - WebDriverManager.chromedriver().setup(); driver = new ChromeDriver(options); } driver.manage().window().setSize(dimension); @@ -89,6 +88,10 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { return driver; } + public boolean getHeadless() { + return HEADLESS; + } + protected boolean urlContains(String urlPath) { WebDriverWait wait = new WebDriverWait(driver, Duration.ofMillis(5000)); try { diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java index 56b15efd67..737022a096 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java @@ -34,11 +34,10 @@ public class TestListener implements ITestListener { public void onTestSuccess(ITestResult tr) { String str = "Test " + tr.getMethod().getMethodName() + " success"; log.info("*----------------------* " + str + " *----------------------*"); - Allure.getLifecycle().updateTestCase((t) -> { - t.setStatusDetails(t.getStatusDetails().setMessage(str)); - }); - driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); - captureScreen(driver, "success"); + if (!((AbstractDriverBaseTest) tr.getInstance()).getHeadless()) { + driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); + captureScreen(driver, "success"); + } } public void onTestFailure(ITestResult tr) { @@ -46,12 +45,10 @@ public class TestListener implements ITestListener { String str1 = "Failed because of - " + tr.getThrowable(); log.info("*----------------------* " + str + " *----------------------*"); log.info("*----------------------* " + str1 + " *----------------------*"); - Allure.getLifecycle().updateTestCase((t) -> { - t.setStatusDetails(t.getStatusDetails().setMessage(str)); - t.setStatusDetails(t.getStatusDetails().setMessage(str1)); - }); - driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); - captureScreen(driver, "failure"); + if (!((AbstractDriverBaseTest) tr.getInstance()).getHeadless()) { + driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); + captureScreen(driver, "failure"); + } } public void onTestSkipped(ITestResult tr) { @@ -59,12 +56,10 @@ public class TestListener implements ITestListener { String str1 = "Skipped because of - " + tr.getThrowable(); log.info("*----------------------* " + str + " *----------------------*"); log.info("*----------------------* " + str1 + " *----------------------*"); - Allure.getLifecycle().updateTestCase((t) -> { - t.setStatusDetails(t.getStatusDetails().setMessage(str)); - t.setStatusDetails(t.getStatusDetails().setMessage(str1)); - }); - driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); - captureScreen(driver, "skipped"); + if (!((AbstractDriverBaseTest) tr.getInstance()).getHeadless()) { + driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); + captureScreen(driver, "skipped"); + } } public void onStart(ITestContext testContext) { 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 4de0244044..df97ffb934 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 @@ -58,7 +58,6 @@ public class SortByNameTest extends AbstractDriverBaseTest { @Description public void specialCharacterUp(String ruleChainName) { testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); - ; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.sortByNameBtn().click(); From ddebab5059553a2c9580ec8a5038951acec19dcf Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Wed, 30 Nov 2022 14:13:42 +0200 Subject: [PATCH 12/44] fix open rule chain tests --- .../msa/ui/base/AbstractDriverBaseTest.java | 2 +- .../ruleChainsSmoke/OpenRuleChainTest.java | 34 +++++++++++++------ 2 files changed, 25 insertions(+), 11 deletions(-) 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 b17b1ad95b..315f482751 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 @@ -54,7 +54,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { @BeforeMethod public void openBrowser() { log.info("*----------------------* Setup driver *----------------------*"); - WebDriverManager.chromedriver().driverVersion("100.0.04896.20").setup(); + WebDriverManager.chromedriver().setup(); if (HEADLESS == true) { ChromeOptions options = new ChromeOptions(); options.addArguments("--ignore-certificate-errors"); 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 2f0242c4fd..6cd70c2b82 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 @@ -17,6 +17,7 @@ package org.thingsboard.server.msa.ui.tests.ruleChainsSmoke; 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; @@ -24,7 +25,9 @@ import org.thingsboard.server.msa.ui.pages.LoginPageHelper; import org.thingsboard.server.msa.ui.pages.OpenRuleChainPageHelper; 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.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.Const.URL; @@ -34,6 +37,7 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { private SideBarMenuViewElements sideBarMenuView; private RuleChainsPageHelper ruleChainsPage; private OpenRuleChainPageHelper openRuleChainPage; + private String ruleChainName; @BeforeMethod public void login() { @@ -45,35 +49,45 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { openRuleChainPage = new OpenRuleChainPageHelper(driver); } + @AfterMethod + public void delete(){ + if (ruleChainName != null) { + testRestClient.deleteRuleChain(getRuleChainByName(ruleChainName).getId()); + ruleChainName = null; + } + } + @Test(priority = 10, groups = "smoke") @Description public void openRuleChainByRightCornerBtn() { + ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(ENTITY_NAME)); + sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.setRuleChainNameWithoutRoot(0); - String ruleChain = ruleChainsPage.getRuleChainName(); - ruleChainsPage.openRuleChainBtn(ruleChain).click(); + ruleChainsPage.openRuleChainBtn(ruleChainName).click(); openRuleChainPage.setHeadName(); - Assert.assertTrue(urlContains(String.valueOf(getRuleChainByName(ruleChainsPage.getRuleChainName()).getId()))); + Assert.assertTrue(urlContains(String.valueOf(getRuleChainByName(ruleChainName).getId()))); Assert.assertTrue(openRuleChainPage.headRuleChainName().isDisplayed()); Assert.assertTrue(openRuleChainPage.inputNode().isDisplayed()); - Assert.assertEquals(ruleChainsPage.getRuleChainName(), openRuleChainPage.getHeadName()); + Assert.assertEquals(ruleChainName, openRuleChainPage.getHeadName()); } @Test(priority = 10, groups = "smoke") @Description public void openRuleChainByViewBtn() { + ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(ENTITY_NAME)); + sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.setRuleChainNameWithoutRoot(0); - String ruleChain = ruleChainsPage.getRuleChainName(); - ruleChainsPage.entity(ruleChain).click(); + ruleChainsPage.entity(ruleChainName).click(); ruleChainsPage.openRuleChainFromViewBtn().click(); openRuleChainPage.setHeadName(); - Assert.assertTrue(urlContains(String.valueOf(getRuleChainByName(ruleChainsPage.getRuleChainName()).getId()))); + Assert.assertTrue(urlContains(String.valueOf(getRuleChainByName(ruleChainName).getId()))); Assert.assertTrue(openRuleChainPage.headRuleChainName().isDisplayed()); Assert.assertTrue(openRuleChainPage.inputNode().isDisplayed()); - Assert.assertEquals(ruleChain, openRuleChainPage.getHeadName()); + Assert.assertEquals(ruleChainName, openRuleChainPage.getHeadName()); } @Test(priority = 20, groups = "smoke") From 8045e136685c78843da43c071687d26e47c3774f Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Wed, 30 Nov 2022 15:40:42 +0200 Subject: [PATCH 13/44] add before suite method --- .../server/msa/ui/base/AbstractDriverBaseTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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 315f482751..6badd78e8e 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 @@ -21,13 +21,18 @@ import io.qameta.allure.Attachment; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; -import org.openqa.selenium.*; +import org.openqa.selenium.Dimension; +import org.openqa.selenium.OutputType; +import org.openqa.selenium.TakesScreenshot; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebDriverException; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeSuite; import org.testng.annotations.Listeners; import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.page.PageLink; @@ -50,11 +55,14 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { private static final boolean HEADLESS = true; protected static final PageLink pageLink = new PageLink(10); + @BeforeSuite + public void beforeUISuite() { + WebDriverManager.chromedriver().setup(); + } @BeforeMethod public void openBrowser() { log.info("*----------------------* Setup driver *----------------------*"); - WebDriverManager.chromedriver().setup(); if (HEADLESS == true) { ChromeOptions options = new ChromeOptions(); options.addArguments("--ignore-certificate-errors"); @@ -68,6 +76,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { driver = new ChromeDriver(options); } driver.manage().window().setSize(dimension); + } @AfterMethod From 5cf5af26b6ea45d5f0166123ede60366f9407583 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Wed, 30 Nov 2022 17:28:30 +0200 Subject: [PATCH 14/44] change suite path --- msa/black-box-tests/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml index 380f9abbaa..1b710940b7 100644 --- a/msa/black-box-tests/pom.xml +++ b/msa/black-box-tests/pom.xml @@ -184,7 +184,7 @@ maven-surefire-plugin - src/test/resources/${suite}.xml + src/test/resources/all.xml ${blackBoxTests.skip} From 9274fff3ec14a1a74e49550758e3f6f2b7f34de1 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Thu, 1 Dec 2022 11:31:07 +0200 Subject: [PATCH 15/44] add ManageCustomerEdgesTest in suite --- .../src/test/resources/smokesCustomer.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/msa/black-box-tests/src/test/resources/smokesCustomer.xml b/msa/black-box-tests/src/test/resources/smokesCustomer.xml index 8d26e1a796..106a552d8e 100644 --- a/msa/black-box-tests/src/test/resources/smokesCustomer.xml +++ b/msa/black-box-tests/src/test/resources/smokesCustomer.xml @@ -1,7 +1,7 @@ - - - - - - - - - \ No newline at end of file From ad895876f084b397dfbcc477da90d72a35c3c465 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Mon, 12 Dec 2022 15:15:13 +0200 Subject: [PATCH 37/44] merge listeners, rm suites from all.xml --- .../server/msa/DisableUIListeners.java | 28 ++++++++ .../thingsboard/server/msa/TestListener.java | 45 ++++++++++--- .../msa/connectivity/CoapClientTest.java | 3 +- .../msa/connectivity/HttpClientTest.java | 2 + .../msa/connectivity/MqttClientTest.java | 2 + .../connectivity/MqttGatewayClientTest.java | 2 + .../msa/ui/base/AbstractDriverBaseTest.java | 8 +-- .../msa/ui/listeners/RetryAnalyzer.java | 7 ++ .../server/msa/ui/listeners/TestListener.java | 66 ------------------- .../src/test/resources/all.xml | 22 +++++-- 10 files changed, 100 insertions(+), 85 deletions(-) create mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/DisableUIListeners.java delete mode 100644 msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/DisableUIListeners.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/DisableUIListeners.java new file mode 100644 index 0000000000..86e9646516 --- /dev/null +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/DisableUIListeners.java @@ -0,0 +1,28 @@ +/** + * 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; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface DisableUIListeners { + +} + diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestListener.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestListener.java index 51bc75c86a..ec23b69812 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestListener.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/TestListener.java @@ -16,18 +16,22 @@ package org.thingsboard.server.msa; import lombok.extern.slf4j.Slf4j; -import org.testng.ITestContext; +import org.openqa.selenium.WebDriver; +import org.testng.ITestListener; import org.testng.ITestResult; -import org.testng.TestListenerAdapter; +import org.testng.internal.ConstructorOrMethod; +import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; import static org.testng.internal.Utils.log; +import static org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest.captureScreen; @Slf4j -public class TestListener extends TestListenerAdapter { +public class TestListener implements ITestListener { + + WebDriver driver; @Override public void onTestStart(ITestResult result) { - super.onTestStart(result); log.info("===>>> Test started: " + result.getName()); } @@ -36,10 +40,14 @@ public class TestListener extends TestListenerAdapter { */ @Override public void onTestSuccess(ITestResult result) { - super.onTestSuccess(result); - if (result != null) { - log.info("<<<=== Test completed successfully: " + result.getName()); + log.info("<<<=== Test completed successfully: " + result.getName()); + ConstructorOrMethod consOrMethod = result.getMethod().getConstructorOrMethod(); + DisableUIListeners disable = consOrMethod.getMethod().getDeclaringClass().getAnnotation(DisableUIListeners.class); + if (disable != null) { + return; } + driver = ((AbstractDriverBaseTest) result.getInstance()).getDriver(); + captureScreen(driver, "success"); } /** @@ -47,7 +55,28 @@ public class TestListener extends TestListenerAdapter { */ @Override public void onTestFailure(ITestResult result) { - super.onTestFailure(result); log.info("<<<=== Test failed: " + result.getName()); + ConstructorOrMethod consOrMethod = result.getMethod().getConstructorOrMethod(); + DisableUIListeners disable = consOrMethod.getMethod().getDeclaringClass().getAnnotation(DisableUIListeners.class); + if (disable != null) { + return; + } + driver = ((AbstractDriverBaseTest) result.getInstance()).getDriver(); + captureScreen(driver, "failure"); + } + + /** + * Invoked when a test skipped + */ + @Override + public void onTestSkipped(ITestResult result) { + log.info("<<<=== Test skipped: " + result.getName()); + ConstructorOrMethod consOrMethod = result.getMethod().getConstructorOrMethod(); + DisableUIListeners disable = consOrMethod.getMethod().getDeclaringClass().getAnnotation(DisableUIListeners.class); + if (disable != null) { + return; + } + driver = ((AbstractDriverBaseTest) result.getInstance()).getDriver(); + captureScreen(driver, "skipped"); } } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/CoapClientTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/CoapClientTest.java index fe3443dd0e..8ddc7e79c0 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/CoapClientTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/CoapClientTest.java @@ -18,7 +18,6 @@ package org.thingsboard.server.msa.connectivity; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.gson.JsonObject; -import io.restassured.path.json.JsonPath; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -29,11 +28,13 @@ import org.thingsboard.server.common.data.DeviceProfileProvisionType; import org.thingsboard.server.common.data.security.DeviceCredentials; import org.thingsboard.server.common.msg.session.FeatureType; import org.thingsboard.server.msa.AbstractContainerTest; +import org.thingsboard.server.msa.DisableUIListeners; import org.thingsboard.server.msa.TestCoapClient; import static org.assertj.core.api.Assertions.assertThat; import static org.thingsboard.server.msa.prototypes.DevicePrototypes.defaultDevicePrototype; +@DisableUIListeners public class CoapClientTest extends AbstractContainerTest { private TestCoapClient client; diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/HttpClientTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/HttpClientTest.java index adaefa887a..36da84e9d2 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/HttpClientTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/HttpClientTest.java @@ -26,6 +26,7 @@ import org.thingsboard.server.common.data.DeviceProfile; import org.thingsboard.server.common.data.DeviceProfileProvisionType; import org.thingsboard.server.common.data.security.DeviceCredentials; import org.thingsboard.server.msa.AbstractContainerTest; +import org.thingsboard.server.msa.DisableUIListeners; import org.thingsboard.server.msa.WsClient; import org.thingsboard.server.msa.mapper.WsTelemetryResponse; @@ -37,6 +38,7 @@ import static org.thingsboard.server.common.data.DataConstants.DEVICE; import static org.thingsboard.server.common.data.DataConstants.SHARED_SCOPE; import static org.thingsboard.server.msa.prototypes.DevicePrototypes.defaultDevicePrototype; +@DisableUIListeners public class HttpClientTest extends AbstractContainerTest { private Device device; @BeforeMethod diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttClientTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttClientTest.java index dff645ddf7..7899372566 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttClientTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttClientTest.java @@ -46,6 +46,7 @@ import org.thingsboard.server.common.data.rule.RuleChainMetaData; import org.thingsboard.server.common.data.rule.RuleNode; import org.thingsboard.server.common.data.security.DeviceCredentials; import org.thingsboard.server.msa.AbstractContainerTest; +import org.thingsboard.server.msa.DisableUIListeners; import org.thingsboard.server.msa.WsClient; import org.thingsboard.server.msa.mapper.AttributesResponse; import org.thingsboard.server.msa.mapper.WsTelemetryResponse; @@ -68,6 +69,7 @@ import static org.thingsboard.server.common.data.DataConstants.DEVICE; import static org.thingsboard.server.common.data.DataConstants.SHARED_SCOPE; import static org.thingsboard.server.msa.prototypes.DevicePrototypes.defaultDevicePrototype; +@DisableUIListeners @Slf4j public class MqttClientTest extends AbstractContainerTest { diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttGatewayClientTest.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttGatewayClientTest.java index 84b2dd7253..6315cad5b0 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttGatewayClientTest.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/connectivity/MqttGatewayClientTest.java @@ -46,6 +46,7 @@ import org.thingsboard.server.common.data.relation.EntityRelation; import org.thingsboard.server.common.data.relation.RelationTypeGroup; import org.thingsboard.server.common.data.security.DeviceCredentials; import org.thingsboard.server.msa.AbstractContainerTest; +import org.thingsboard.server.msa.DisableUIListeners; import org.thingsboard.server.msa.WsClient; import org.thingsboard.server.msa.mapper.WsTelemetryResponse; @@ -66,6 +67,7 @@ import static org.thingsboard.server.common.data.DataConstants.DEVICE; import static org.thingsboard.server.common.data.DataConstants.SHARED_SCOPE; import static org.thingsboard.server.msa.prototypes.DevicePrototypes.defaultGatewayPrototype; +@DisableUIListeners @Slf4j public class MqttGatewayClientTest extends AbstractContainerTest { private Device gatewayDevice; 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 4fa500625e..121acb4e92 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 @@ -34,14 +34,11 @@ import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.Listeners; import org.thingsboard.server.common.data.Customer; import org.thingsboard.server.common.data.page.PageLink; import org.thingsboard.server.common.data.rule.RuleChain; import org.thingsboard.server.msa.AbstractContainerTest; import org.thingsboard.server.msa.ContainerTestSuite; -import org.thingsboard.server.msa.ui.listeners.TestListener; import java.io.File; import java.net.URL; @@ -51,7 +48,6 @@ import java.util.stream.Collectors; import static org.thingsboard.server.msa.TestProperties.getBaseUiUrl; @Slf4j -@Listeners(TestListener.class) abstract public class AbstractDriverBaseTest extends AbstractContainerTest { protected WebDriver driver; @@ -65,7 +61,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { @SneakyThrows @BeforeMethod public void openBrowser() { - log.info("*----------------------* Setup driver *----------------------*"); + log.info("===>>> Setup driver"); ChromeOptions options = new ChromeOptions(); options.setAcceptInsecureCerts(true); if (instance.isActive()) { @@ -81,7 +77,7 @@ abstract public class AbstractDriverBaseTest extends AbstractContainerTest { @AfterMethod public void closeBrowser() { - log.info("*----------------------* Teardown *----------------------*"); + log.info("<<<=== Teardown"); driver.quit(); } diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java index bc3f88d99e..56cd7c91cd 100644 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java +++ b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/RetryAnalyzer.java @@ -17,6 +17,8 @@ package org.thingsboard.server.msa.ui.listeners; import org.testng.IRetryAnalyzer; import org.testng.ITestResult; +import org.testng.internal.ConstructorOrMethod; +import org.thingsboard.server.msa.DisableUIListeners; public class RetryAnalyzer implements IRetryAnalyzer { @@ -25,6 +27,11 @@ public class RetryAnalyzer implements IRetryAnalyzer { @Override public boolean retry(ITestResult result) { + ConstructorOrMethod consOrMethod = result.getMethod().getConstructorOrMethod(); + DisableUIListeners disable = consOrMethod.getMethod().getDeclaringClass().getAnnotation(DisableUIListeners.class); + if (disable != null) { + return false; + } if (retryCount < MAX_RETRY_COUNT) { System.out.printf("Retrying test %s for the %d time(s).%n", result.getName(), retryCount + 1); retryCount++; diff --git a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java b/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java deleted file mode 100644 index 9a0e7aad77..0000000000 --- a/msa/black-box-tests/src/test/java/org/thingsboard/server/msa/ui/listeners/TestListener.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * 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.listeners; - -import lombok.extern.slf4j.Slf4j; -import org.openqa.selenium.WebDriver; -import org.testng.ITestContext; -import org.testng.ITestListener; -import org.testng.ITestResult; -import org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest; - -import static org.thingsboard.server.msa.ui.base.AbstractDriverBaseTest.captureScreen; - -@Slf4j -public class TestListener implements ITestListener { - - WebDriver driver; - - public void onTestSuccess(ITestResult tr) { - String str = "Test " + tr.getMethod().getMethodName() + " success"; - log.info("*----------------------* " + str + " *----------------------*"); - driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); - captureScreen(driver, "success"); - } - - public void onTestFailure(ITestResult tr) { - String str = "Test " + tr.getMethod().getMethodName() + " failure"; - String str1 = "Failed because of - " + tr.getThrowable(); - log.info("*----------------------* " + str + " *----------------------*"); - log.info("*----------------------* " + str1 + " *----------------------*"); - driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); - captureScreen(driver, "failure"); - } - - public void onTestSkipped(ITestResult tr) { - String str = "Test " + tr.getMethod().getMethodName() + " skipped"; - String str1 = "Skipped because of - " + tr.getThrowable(); - log.info("*----------------------* " + str + " *----------------------*"); - log.info("*----------------------* " + str1 + " *----------------------*"); - driver = ((AbstractDriverBaseTest) tr.getInstance()).getDriver(); - captureScreen(driver, "skipped"); - } - - public void onStart(ITestContext testContext) { - String str = "Test " + testContext.getCurrentXmlTest().getName() + " start"; - log.info("*----------------------* " + str + " *----------------------*"); - } - - public void onFinish(ITestContext testContext) { - String str = "Test " + testContext.getCurrentXmlTest().getName() + " finish"; - log.info("*----------------------* " + str + " *----------------------*"); - } -} diff --git a/msa/black-box-tests/src/test/resources/all.xml b/msa/black-box-tests/src/test/resources/all.xml index 41779d6a97..7eac146e4b 100644 --- a/msa/black-box-tests/src/test/resources/all.xml +++ b/msa/black-box-tests/src/test/resources/all.xml @@ -19,8 +19,22 @@ - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file From 832b4064203fd82bb0d07b1cb69e5e1d7a8a3f64 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Wed, 21 Dec 2022 14:24:15 +0200 Subject: [PATCH 38/44] fix tests after changes in UI --- .../msa/ui/pages/OtherPageElements.java | 5 +++ .../ruleChainsSmoke/CreateRuleChainTest.java | 11 +++--- .../ruleChainsSmoke/DeleteRuleChainTest.java | 6 ++-- .../MakeRuleChainRootTest.java | 4 +-- .../ruleChainsSmoke/OpenRuleChainTest.java | 17 ++------- .../RuleChainEditMenuTest.java | 36 ++++++++++++------- .../src/test/resources/all.xml | 10 ++++++ .../src/test/resources/smokesCustomer.xml | 7 +++- .../src/test/resources/smokesRuleChain.xml | 7 +++- .../src/test/resources/uiTests.xml | 10 ++++++ 10 files changed, 75 insertions(+), 38 deletions(-) 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 1f3ecfa208..b6ffd2a14e 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 @@ -28,6 +28,7 @@ public class OtherPageElements extends AbstractBasePage { protected static final String ENTITY = "//mat-row//span[contains(text(),'%s')]"; protected static final String DELETE_BTN = ENTITY + "/../..//mat-icon[contains(text(),' delete')]/../.."; + protected static final String DETAILS_BTN = ENTITY + "/../..//mat-icon[contains(text(),'edit')]/../.."; private static final String ENTITY_COUNT = "//div[@class='mat-paginator-range-label']"; 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"; @@ -214,6 +215,10 @@ public class OtherPageElements extends AbstractBasePage { return waitUntilVisibilityOfElementLocated(String.format(DELETE_BTN, entityName)); } + public WebElement detailsBtn(String entityName) { + return waitUntilVisibilityOfElementLocated(String.format(DETAILS_BTN, entityName)); + } + public WebElement entity(String entityName) { return waitUntilElementToBeClickable(String.format(ENTITY, entityName)); } 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 98963a5c00..b60b4a4a52 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 @@ -63,6 +63,7 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); + ruleChainsPage.nameField().click(); ruleChainsPage.nameField().sendKeys(ruleChainName); ruleChainsPage.addBtnC().click(); ruleChainsPage.refreshBtn().click(); @@ -84,7 +85,7 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { ruleChainsPage.addBtnC().click(); ruleChainsPage.refreshBtn().click(); this.ruleChainName = ruleChainName; - ruleChainsPage.entity(ENTITY_NAME).click(); + ruleChainsPage.detailsBtn(ENTITY_NAME).click(); ruleChainsPage.setHeaderName(); Assert.assertEquals(ruleChainsPage.getHeaderName(), ruleChainName); @@ -118,8 +119,9 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void createRuleChainWithSameName() { - ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME; testRestClient.postRuleChain(EntityPrototypes.defaultRuleChainPrototype(ruleChainName)); + this.ruleChainName = ruleChainName; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); @@ -142,12 +144,13 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { @Test(priority = 30, groups = "smoke") @Description public void createRuleChainWithoutRefresh() { - ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME; sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.openCreateRuleChainView(); ruleChainsPage.nameField().sendKeys(ruleChainName); ruleChainsPage.addBtnC().click(); + this.ruleChainName = ruleChainName; Assert.assertNotNull(ruleChainsPage.entity(ruleChainName)); Assert.assertTrue(ruleChainsPage.entity(ruleChainName).isDisplayed()); @@ -160,7 +163,7 @@ public class CreateRuleChainTest extends AbstractDriverBaseTest { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(); - ruleChainsPage.entity(ruleChainsPage.getRuleChainName()).click(); + ruleChainsPage.detailsBtn(ruleChainsPage.getRuleChainName()).click(); ruleChainsPage.goToHelpPage(); Assert.assertTrue(urlContains(urlPath)); 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 fdecc199ad..d605b6c0e9 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 @@ -77,7 +77,7 @@ public class DeleteRuleChainTest extends AbstractDriverBaseTest { testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.entity(ENTITY_NAME).click(); + ruleChainsPage.detailsBtn(ENTITY_NAME).click(); String deletedRuleChain = ruleChainsPage.deleteRuleChainFromView(ruleChainName); ruleChainsPage.refreshBtn().click(); @@ -104,7 +104,7 @@ public class DeleteRuleChainTest extends AbstractDriverBaseTest { @Description public void removeFromRootRuleChainView() { sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.entity(ROOT_RULE_CHAIN_NAME).click(); + ruleChainsPage.detailsBtn(ROOT_RULE_CHAIN_NAME).click(); ruleChainsPage.deleteBtnFromView(); Assert.assertTrue(ruleChainsPage.deleteBtnInRootRuleChainIsNotDisplayed()); @@ -147,7 +147,7 @@ public class DeleteRuleChainTest extends AbstractDriverBaseTest { String deletedRuleChain = "Thermostat"; sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.entity(deletedRuleChain).click(); + ruleChainsPage.detailsBtn(deletedRuleChain).click(); ruleChainsPage.deleteBtnFromView().click(); ruleChainsPage.warningPopUpYesBtn().click(); 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 a36695b316..f63e65cc25 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 @@ -65,7 +65,7 @@ public class MakeRuleChainRootTest extends AbstractDriverBaseTest { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(0); String ruleChain = ruleChainsPage.getRuleChainName(); - ruleChainsPage.entity(ruleChain).click(); + ruleChainsPage.detailsBtn(ruleChain).click(); ruleChainsPage.makeRootFromViewBtn().click(); ruleChainsPage.warningPopUpYesBtn().click(); ruleChainsPage.closeEntityViewBtn().click(); @@ -79,7 +79,7 @@ public class MakeRuleChainRootTest extends AbstractDriverBaseTest { sideBarMenuView.ruleChainsBtn().click(); ruleChainsPage.setRuleChainNameWithoutRoot(0); String ruleChain = ruleChainsPage.getRuleChainName(); - ruleChainsPage.entity(ruleChain).click(); + ruleChainsPage.detailsBtn(ruleChain).click(); ruleChainsPage.makeRootFromViewBtn().click(); ruleChainsPage.warningPopUpYesBtn().click(); ruleChainsPage.closeEntityViewBtn().click(); 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 481c4ab353..2f23fd8b74 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,11 +27,9 @@ 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.TestProperties.getBaseUiUrl; 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.Const.URL; public class OpenRuleChainTest extends AbstractDriverBaseTest { @@ -66,7 +64,7 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { this.ruleChainName = ruleChainName; sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.openRuleChainBtn(ruleChainName).click(); + ruleChainsPage.entity(ruleChainName).click(); openRuleChainPage.setHeadName(); Assert.assertTrue(urlContains(String.valueOf(getRuleChainByName(ruleChainName).getId()))); @@ -83,7 +81,7 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { this.ruleChainName = ruleChainName; sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.entity(ruleChainName).click(); + ruleChainsPage.detailsBtn(ruleChainName).click(); ruleChainsPage.openRuleChainFromViewBtn().click(); openRuleChainPage.setHeadName(); @@ -92,15 +90,4 @@ public class OpenRuleChainTest extends AbstractDriverBaseTest { Assert.assertTrue(openRuleChainPage.inputNode().isDisplayed()); Assert.assertEquals(ruleChainName, openRuleChainPage.getHeadName()); } - - @Test(priority = 20, groups = "smoke") - @Description - public void openRuleChainDoubleClick() { - sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.setRuleChainNameWithoutRoot(0); - String ruleChain = ruleChainsPage.getRuleChainName(); - ruleChainsPage.doubleClickOnRuleChain(ruleChain); - - Assert.assertEquals(getUrl(), getBaseUiUrl() + "/ruleChains"); - } } 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 5ceb326dba..3a7ea071bb 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 @@ -57,29 +57,35 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 10, groups = "smoke") @Description public void changeName() { - String name = "Changed"; - testRestClient.postRuleChain(defaultRuleChainPrototype(ENTITY_NAME)); - ruleChainName = name; + String newRuleChainName = "Changed"; + String ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); + this.ruleChainName = ruleChainName; sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.detailsBtn(ruleChainName).click(); ruleChainsPage.setHeaderName(); String nameBefore = ruleChainsPage.getHeaderName(); ruleChainsPage.editPencilBtn().click(); - ruleChainsPage.changeNameEditMenu(name); + ruleChainsPage.changeNameEditMenu(newRuleChainName); ruleChainsPage.doneBtnEditView().click(); + this.ruleChainName = newRuleChainName; ruleChainsPage.setHeaderName(); String nameAfter = ruleChainsPage.getHeaderName(); Assert.assertNotEquals(nameBefore, nameAfter); - Assert.assertEquals(name, nameAfter); + Assert.assertEquals(newRuleChainName, nameAfter); } @Test(priority = 20, groups = "smoke") @Description public void deleteName() { + String ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); + this.ruleChainName = ruleChainName; + sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.detailsBtn(ruleChainName).click(); ruleChainsPage.editPencilBtn().click(); ruleChainsPage.changeNameEditMenu(""); @@ -89,8 +95,12 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void saveOnlyWithSpace() { + String ruleChainName = ENTITY_NAME; + testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); + this.ruleChainName = ruleChainName; + sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.detailsBtn(ruleChainName).click(); ruleChainsPage.editPencilBtn().click(); ruleChainsPage.changeNameEditMenu(" "); ruleChainsPage.doneBtnEditView().click(); @@ -103,12 +113,13 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void editDescription() { - ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME; testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); + this.ruleChainName = ruleChainName; String description = "Description"; sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.detailsBtn(ruleChainName).click(); ruleChainsPage.editPencilBtn().click(); ruleChainsPage.descriptionEntityView().sendKeys(description); ruleChainsPage.doneBtnEditView().click(); @@ -129,11 +140,12 @@ public class RuleChainEditMenuTest extends AbstractDriverBaseTest { @Test(priority = 20, groups = "smoke") @Description public void debugMode() { - ruleChainName = ENTITY_NAME; + String ruleChainName = ENTITY_NAME; testRestClient.postRuleChain(defaultRuleChainPrototype(ruleChainName)); + this.ruleChainName = ruleChainName; sideBarMenuView.ruleChainsBtn().click(); - ruleChainsPage.notRootRuleChainsNames().get(0).click(); + ruleChainsPage.detailsBtn(ruleChainName).click(); ruleChainsPage.editPencilBtn().click(); ruleChainsPage.debugCheckboxEdit().click(); ruleChainsPage.doneBtnEditView().click(); diff --git a/msa/black-box-tests/src/test/resources/all.xml b/msa/black-box-tests/src/test/resources/all.xml index 7eac146e4b..fe8b908a86 100644 --- a/msa/black-box-tests/src/test/resources/all.xml +++ b/msa/black-box-tests/src/test/resources/all.xml @@ -28,11 +28,21 @@ + + + + + + + + + + diff --git a/msa/black-box-tests/src/test/resources/smokesCustomer.xml b/msa/black-box-tests/src/test/resources/smokesCustomer.xml index 4ef119c7e6..5ac515c0fe 100644 --- a/msa/black-box-tests/src/test/resources/smokesCustomer.xml +++ b/msa/black-box-tests/src/test/resources/smokesCustomer.xml @@ -22,7 +22,12 @@ - + + + + + + diff --git a/msa/black-box-tests/src/test/resources/smokesRuleChain.xml b/msa/black-box-tests/src/test/resources/smokesRuleChain.xml index 27f55db0ec..5834ad6558 100644 --- a/msa/black-box-tests/src/test/resources/smokesRuleChain.xml +++ b/msa/black-box-tests/src/test/resources/smokesRuleChain.xml @@ -22,7 +22,12 @@ - + + + + + + diff --git a/msa/black-box-tests/src/test/resources/uiTests.xml b/msa/black-box-tests/src/test/resources/uiTests.xml index 8cb25d7094..bd163de930 100644 --- a/msa/black-box-tests/src/test/resources/uiTests.xml +++ b/msa/black-box-tests/src/test/resources/uiTests.xml @@ -23,11 +23,21 @@ + + + + + + + + + + From b9d361f1cf8e40004115b2c14134728addcaa5e6 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 21 Dec 2022 17:23:51 +0200 Subject: [PATCH 39/44] UI: Fixed incorrect updated timewindow in Alarm table --- ui-ngx/src/app/core/api/widget-subscription.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/ui-ngx/src/app/core/api/widget-subscription.ts b/ui-ngx/src/app/core/api/widget-subscription.ts index d40dc95db7..332b8db14f 100644 --- a/ui-ngx/src/app/core/api/widget-subscription.ts +++ b/ui-ngx/src/app/core/api/widget-subscription.ts @@ -204,6 +204,7 @@ export class WidgetSubscription implements IWidgetSubscription { this.timeWindow = {}; this.useDashboardTimewindow = options.useDashboardTimewindow; this.useTimewindow = true; + this.onTimewindowChangeFunction = options.onTimewindowChangeFunction || ((timewindow) => timewindow); if (this.useDashboardTimewindow) { this.timeWindowConfig = deepClone(options.dashboardTimewindow); } else { From 36793c432d60a48f66745e67b775235839a757a3 Mon Sep 17 00:00:00 2001 From: YevhenBondarenko Date: Fri, 23 Dec 2022 15:07:44 +0100 Subject: [PATCH 40/44] fixed device sessions dump --- .../service/session/DefaultDeviceSessionCacheService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java b/application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java index 9e5667aa19..51f21be98f 100644 --- a/application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java +++ b/application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java @@ -52,7 +52,7 @@ public class DefaultDeviceSessionCacheService implements DeviceSessionCacheServi @Override public DeviceSessionsCacheEntry put(DeviceId deviceId, DeviceSessionsCacheEntry sessions) { log.debug("[{}] Pushing session data to cache: {}", deviceId, sessions); - cache.putIfAbsent(deviceId, sessions); + cache.put(deviceId, sessions); return sessions; } } From f04753d3f970272e3a4ff9ad92451dcce4ffb35a Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Fri, 23 Dec 2022 16:35:15 +0200 Subject: [PATCH 41/44] Fixed incorrect index creation for edge event migration --- application/src/main/data/upgrade/3.4.1/schema_update.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/src/main/data/upgrade/3.4.1/schema_update.sql b/application/src/main/data/upgrade/3.4.1/schema_update.sql index 45a75c6bd9..2b7a4bdf26 100644 --- a/application/src/main/data/upgrade/3.4.1/schema_update.sql +++ b/application/src/main/data/upgrade/3.4.1/schema_update.sql @@ -88,7 +88,7 @@ $$ -- in case of running the upgrade script a second time: IF NOT (SELECT exists(SELECT FROM pg_tables WHERE tablename = 'old_edge_event')) THEN ALTER TABLE edge_event RENAME TO old_edge_event; - CREATE INDEX IF NOT EXISTS idx_old_blob_entity_created_time_tmp ON old_blob_entity(created_time); + CREATE INDEX IF NOT EXISTS idx_old_edge_event_created_time_tmp ON old_edge_event(created_time); ALTER INDEX IF EXISTS idx_edge_event_tenant_id_and_created_time RENAME TO idx_old_edge_event_tenant_id_and_created_time; FOR table_partition IN SELECT tablename AS name, split_part(tablename, '_', 3) AS partition_ts From 89bb6cafce06c191343c76925536fb7c53ac9660 Mon Sep 17 00:00:00 2001 From: Andrii Landiak Date: Tue, 27 Dec 2022 11:15:00 +0200 Subject: [PATCH 42/44] Improve swagger description for SaveAttributes --- .../controller/ControllerConstants.java | 11 +++++++---- .../controller/TelemetryController.java | 19 +++++++++---------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/controller/ControllerConstants.java b/application/src/main/java/org/thingsboard/server/controller/ControllerConstants.java index e00ccaa4bc..2409a19ac5 100644 --- a/application/src/main/java/org/thingsboard/server/controller/ControllerConstants.java +++ b/application/src/main/java/org/thingsboard/server/controller/ControllerConstants.java @@ -1433,7 +1433,8 @@ public class ControllerConstants { protected static final String ATTRIBUTES_SCOPE_DESCRIPTION = "A string value representing the attributes scope. For example, 'SERVER_SCOPE'."; protected static final String ATTRIBUTES_KEYS_DESCRIPTION = "A string value representing the comma-separated list of attributes keys. For example, 'active,inactivityAlarmTime'."; - protected static final String ATTRIBUTES_SCOPE_ALLOWED_VALUES = "SERVER_SCOPE, CLIENT_SCOPE, SHARED_SCOPE"; + protected static final String ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES = "SERVER_SCOPE, SHARED_SCOPE"; + protected static final String ATTRIBUTES_SCOPE_ALLOWED_VALUES = ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES + ", CLIENT_SCOPE"; protected static final String ATTRIBUTES_JSON_REQUEST_DESCRIPTION = "A string value representing the json object. For example, '{\"key\":\"value\"}'. See API call description for more details."; protected static final String TELEMETRY_KEYS_BASE_DESCRIPTION = "A string value representing the comma-separated list of telemetry keys."; @@ -1459,10 +1460,12 @@ public class ControllerConstants { protected static final String SAVE_ENTITY_TIMESERIES_STATUS_INTERNAL_SERVER_ERROR = "The exception was thrown during processing the request. " + "Platform creates an audit log event about entity timeseries updates with action type 'TIMESERIES_UPDATED' that includes an error stacktrace."; - protected static final String ENTITY_ATTRIBUTE_SCOPES = " List of possible attribute scopes depends on the entity type: " + + protected static final String ENTITY_ATTRIBUTE_SCOPES_TEMPLATE = " List of possible attribute scopes depends on the entity type: " + "\n\n * SERVER_SCOPE - supported for all entity types;" + - "\n * CLIENT_SCOPE - supported for devices;" + - "\n * SHARED_SCOPE - supported for devices. "+ "\n\n"; + "\n * SHARED_SCOPE - supported for devices"; + protected static final String ENTITY_SAVE_ATTRIBUTE_SCOPES = ENTITY_ATTRIBUTE_SCOPES_TEMPLATE + ".\n\n"; + protected static final String ENTITY_GET_ATTRIBUTE_SCOPES = ENTITY_ATTRIBUTE_SCOPES_TEMPLATE + + ";\n * CLIENT_SCOPE - supported for devices. " + "\n\n"; protected static final String ATTRIBUTE_DATA_EXAMPLE = "[\n" + " {\"key\": \"stringAttributeKey\", \"value\": \"value\", \"lastUpdateTs\": 1609459200000},\n" + diff --git a/application/src/main/java/org/thingsboard/server/controller/TelemetryController.java b/application/src/main/java/org/thingsboard/server/controller/TelemetryController.java index 6f6c4dda85..f843e891be 100644 --- a/application/src/main/java/org/thingsboard/server/controller/TelemetryController.java +++ b/application/src/main/java/org/thingsboard/server/controller/TelemetryController.java @@ -58,7 +58,6 @@ import org.thingsboard.server.common.data.id.EntityIdFactory; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.UUIDBased; import org.thingsboard.server.common.data.kv.Aggregation; -import org.thingsboard.server.common.data.kv.AttributeKey; import org.thingsboard.server.common.data.kv.AttributeKvEntry; import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; import org.thingsboard.server.common.data.kv.BaseDeleteTsKvQuery; @@ -92,11 +91,9 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -104,13 +101,15 @@ import java.util.stream.Collectors; import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_JSON_REQUEST_DESCRIPTION; import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_KEYS_DESCRIPTION; +import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES; import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_SCOPE_ALLOWED_VALUES; import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTES_SCOPE_DESCRIPTION; import static org.thingsboard.server.controller.ControllerConstants.ATTRIBUTE_DATA_EXAMPLE; import static org.thingsboard.server.controller.ControllerConstants.DEVICE_ID; import static org.thingsboard.server.controller.ControllerConstants.DEVICE_ID_PARAM_DESCRIPTION; -import static org.thingsboard.server.controller.ControllerConstants.ENTITY_ATTRIBUTE_SCOPES; +import static org.thingsboard.server.controller.ControllerConstants.ENTITY_GET_ATTRIBUTE_SCOPES; import static org.thingsboard.server.controller.ControllerConstants.ENTITY_ID_PARAM_DESCRIPTION; +import static org.thingsboard.server.controller.ControllerConstants.ENTITY_SAVE_ATTRIBUTE_SCOPES; import static org.thingsboard.server.controller.ControllerConstants.ENTITY_TYPE_PARAM_DESCRIPTION; import static org.thingsboard.server.controller.ControllerConstants.INVALID_ENTITY_ID_OR_ENTITY_TYPE_DESCRIPTION; import static org.thingsboard.server.controller.ControllerConstants.INVALID_STRUCTURE_OF_THE_REQUEST; @@ -241,7 +240,7 @@ public class TelemetryController extends BaseController { @ApiOperation(value = "Get attributes by scope (getAttributesByScope)", notes = "Returns all attributes of a specified scope that belong to specified entity." + - ENTITY_ATTRIBUTE_SCOPES + + ENTITY_GET_ATTRIBUTE_SCOPES + "Use optional 'keys' parameter to return specific attributes." + "\n Example of the result: \n\n" + MARKDOWN_CODE_BLOCK_START @@ -383,7 +382,7 @@ public class TelemetryController extends BaseController { @ResponseBody public DeferredResult saveDeviceAttributes( @ApiParam(value = DEVICE_ID_PARAM_DESCRIPTION, required = true) @PathVariable("deviceId") String deviceIdStr, - @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES, required = true) @PathVariable("scope") String scope, + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES, required = true) @PathVariable("scope") String scope, @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION, required = true) @RequestBody JsonNode request) throws ThingsboardException { try { EntityId entityId = EntityIdFactory.getByTypeAndUuid(EntityType.DEVICE, deviceIdStr); @@ -395,7 +394,7 @@ public class TelemetryController extends BaseController { @ApiOperation(value = "Save entity attributes (saveEntityAttributesV1)", notes = "Creates or updates the entity attributes based on Entity Id and the specified attribute scope. " + - ENTITY_ATTRIBUTE_SCOPES + + ENTITY_SAVE_ATTRIBUTE_SCOPES + SAVE_ATTRIBUTES_REQUEST_PAYLOAD + INVALID_ENTITY_ID_OR_ENTITY_TYPE_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, produces = MediaType.APPLICATION_JSON_VALUE) @@ -411,7 +410,7 @@ public class TelemetryController extends BaseController { public DeferredResult saveEntityAttributesV1( @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true, defaultValue = "DEVICE") @PathVariable("entityType") String entityType, @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @PathVariable("entityId") String entityIdStr, - @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope, + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES) @PathVariable("scope") String scope, @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION, required = true) @RequestBody JsonNode request) throws ThingsboardException { try { EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); @@ -423,7 +422,7 @@ public class TelemetryController extends BaseController { @ApiOperation(value = "Save entity attributes (saveEntityAttributesV2)", notes = "Creates or updates the entity attributes based on Entity Id and the specified attribute scope. " + - ENTITY_ATTRIBUTE_SCOPES + + ENTITY_SAVE_ATTRIBUTE_SCOPES + SAVE_ATTRIBUTES_REQUEST_PAYLOAD + INVALID_ENTITY_ID_OR_ENTITY_TYPE_DESCRIPTION + TENANT_OR_CUSTOMER_AUTHORITY_PARAGRAPH, produces = MediaType.APPLICATION_JSON_VALUE) @@ -439,7 +438,7 @@ public class TelemetryController extends BaseController { public DeferredResult saveEntityAttributesV2( @ApiParam(value = ENTITY_TYPE_PARAM_DESCRIPTION, required = true, defaultValue = "DEVICE") @PathVariable("entityType") String entityType, @ApiParam(value = ENTITY_ID_PARAM_DESCRIPTION, required = true) @PathVariable("entityId") String entityIdStr, - @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SCOPE_ALLOWED_VALUES, required = true) @PathVariable("scope") String scope, + @ApiParam(value = ATTRIBUTES_SCOPE_DESCRIPTION, allowableValues = ATTRIBUTES_SAVE_SCOPE_ALLOWED_VALUES, required = true) @PathVariable("scope") String scope, @ApiParam(value = ATTRIBUTES_JSON_REQUEST_DESCRIPTION, required = true) @RequestBody JsonNode request) throws ThingsboardException { try { EntityId entityId = EntityIdFactory.getByTypeAndId(entityType, entityIdStr); From 42df526966cce30353564838638ee3bb742a77c8 Mon Sep 17 00:00:00 2001 From: Serafym Tuhai Date: Tue, 27 Dec 2022 15:11:43 +0200 Subject: [PATCH 43/44] add tests on delete phone number --- .../customerSmoke/CreateCustomerTest.java | 18 ++++++++++++++++++ .../customerSmoke/CustomerEditMenuTest.java | 19 +++++++++++++++++++ .../server/msa/ui/utils/EntityPrototypes.java | 7 +++++++ 3 files changed, 44 insertions(+) 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..0f1ee5ac58 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 @@ -114,6 +114,24 @@ public class CreateCustomerTest extends AbstractDriverBaseTest { Assert.assertEquals(customerPage.getCustomerCity(), text); } + @Test(priority = 20, groups = "smoke") + @Description + public void createCustomerAddAndRemovePhoneNumber() { + String customerName = ENTITY_NAME; + String number = "12015550123"; + + sideBarMenuView.customerBtn().click(); + customerPage.plusBtn().click(); + customerPage.titleFieldAddEntityView().sendKeys(customerName); + customerPage.phoneNumberAddEntityView().sendKeys(number); + customerPage.phoneNumberAddEntityView().clear(); + customerPage.addBtnC().click(); + this.customerName = customerName; + customerPage.entity(customerName).click(); + + Assert.assertEquals(customerPage.phoneNumberEntityView().getAttribute("value"), ""); + } + @Test(priority = 20, groups = "smoke") @Description public void createCustomerWithoutName() { 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..778cd69dc6 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 @@ -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; @@ -240,6 +241,24 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { Assert.assertTrue(customerPage.phoneNumberEntityView().getAttribute("value").contains(number)); } + @Test(priority = 20, groups = "smoke") + @Description + public void deletePhoneNumber() { + String customerName = ENTITY_NAME; + String number = "+12015550123"; + testRestClient.postCustomer(defaultCustomerPrototype(customerName, number)); + this.customerName = customerName; + + sideBarMenuView.customerBtn().click(); + customerPage.entity(customerName).click(); + customerPage.editPencilBtn().click(); + customerPage.phoneNumberEntityView().click(); + customerPage.phoneNumberEntityView().sendKeys(Keys.CONTROL + "A" + Keys.BACK_SPACE); + customerPage.doneBtnEditView().click(); + + Assert.assertEquals(customerPage.phoneNumberEntityView().getAttribute("value"), ""); + } + @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "incorrectPhoneNumber") @Description public void addIncorrectPhoneNumber(String number) { 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..1398a2ca44 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 @@ -26,6 +26,13 @@ public class EntityPrototypes { return customer; } + public static Customer defaultCustomerPrototype(String entityName, String phoneNumber){ + Customer customer = new Customer(); + customer.setTitle(entityName); + customer.setPhone(phoneNumber); + return customer; + } + public static RuleChain defaultRuleChainPrototype(String entityName){ RuleChain ruleChain = new RuleChain(); ruleChain.setName(entityName); From 6acc9c9ca467b0d7f3d342f4cd505b9e69861072 Mon Sep 17 00:00:00 2001 From: Andrew Shvayka Date: Wed, 28 Dec 2022 12:29:53 +0200 Subject: [PATCH 44/44] Revert "[WIP][3.5] Add tests on delete phone number" --- .../customerSmoke/CreateCustomerTest.java | 18 ------------------ .../customerSmoke/CustomerEditMenuTest.java | 19 ------------------- .../server/msa/ui/utils/EntityPrototypes.java | 7 ------- 3 files changed, 44 deletions(-) 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 0f1ee5ac58..50aac8de11 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 @@ -114,24 +114,6 @@ public class CreateCustomerTest extends AbstractDriverBaseTest { Assert.assertEquals(customerPage.getCustomerCity(), text); } - @Test(priority = 20, groups = "smoke") - @Description - public void createCustomerAddAndRemovePhoneNumber() { - String customerName = ENTITY_NAME; - String number = "12015550123"; - - sideBarMenuView.customerBtn().click(); - customerPage.plusBtn().click(); - customerPage.titleFieldAddEntityView().sendKeys(customerName); - customerPage.phoneNumberAddEntityView().sendKeys(number); - customerPage.phoneNumberAddEntityView().clear(); - customerPage.addBtnC().click(); - this.customerName = customerName; - customerPage.entity(customerName).click(); - - Assert.assertEquals(customerPage.phoneNumberEntityView().getAttribute("value"), ""); - } - @Test(priority = 20, groups = "smoke") @Description public void createCustomerWithoutName() { 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 778cd69dc6..66a5bd5004 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 @@ -16,7 +16,6 @@ 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; @@ -241,24 +240,6 @@ public class CustomerEditMenuTest extends AbstractDriverBaseTest { Assert.assertTrue(customerPage.phoneNumberEntityView().getAttribute("value").contains(number)); } - @Test(priority = 20, groups = "smoke") - @Description - public void deletePhoneNumber() { - String customerName = ENTITY_NAME; - String number = "+12015550123"; - testRestClient.postCustomer(defaultCustomerPrototype(customerName, number)); - this.customerName = customerName; - - sideBarMenuView.customerBtn().click(); - customerPage.entity(customerName).click(); - customerPage.editPencilBtn().click(); - customerPage.phoneNumberEntityView().click(); - customerPage.phoneNumberEntityView().sendKeys(Keys.CONTROL + "A" + Keys.BACK_SPACE); - customerPage.doneBtnEditView().click(); - - Assert.assertEquals(customerPage.phoneNumberEntityView().getAttribute("value"), ""); - } - @Test(priority = 20, groups = "smoke", dataProviderClass = DataProviderCredential.class, dataProvider = "incorrectPhoneNumber") @Description public void addIncorrectPhoneNumber(String number) { 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 1398a2ca44..5fcfe8f4f9 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 @@ -26,13 +26,6 @@ public class EntityPrototypes { return customer; } - public static Customer defaultCustomerPrototype(String entityName, String phoneNumber){ - Customer customer = new Customer(); - customer.setTitle(entityName); - customer.setPhone(phoneNumber); - return customer; - } - public static RuleChain defaultRuleChainPrototype(String entityName){ RuleChain ruleChain = new RuleChain(); ruleChain.setName(entityName);