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 +