add tests on make device public/private
This commit is contained in:
		
							parent
							
								
									ceda0f14e6
								
							
						
					
					
						commit
						6a7af5cc12
					
				@ -60,6 +60,12 @@ public class DevicePageElements extends OtherPageElementsHelper {
 | 
			
		||||
    private static final String DEVICE_STATE_SELECT = "//div[contains(@class,'tb-filter-panel')]//mat-select[@role='combobox']";
 | 
			
		||||
    private static final String LIST_OF_DEVICES_STATE = "//div[@class='status']";
 | 
			
		||||
    private static final String LIST_OF_DEVICES_PROFILE = "//mat-cell[contains(@class,'deviceProfileName')]";
 | 
			
		||||
    private static final String MAKE_DEVICE_PUBLIC_BTN = DEVICE + "/ancestor::mat-row//mat-icon[contains(text(),'share')]/parent::button";
 | 
			
		||||
    private static final String DEVICE_IS_PUBLIC_CHECKBOX = DEVICE + "/ancestor::mat-row//mat-icon[contains(text(),'check_box')]";
 | 
			
		||||
    private static final String MAKE_DEVICE_PUBLIC_BTN_DETAILS_TAB = "//span[contains(text(),'Make device public')]/parent::button";
 | 
			
		||||
    private static final String MAKE_DEVICE_PRIVATE_BTN = DEVICE + "/ancestor::mat-row//mat-icon[contains(text(),'reply')]/parent::button";
 | 
			
		||||
    private static final String DEVICE_IS_PRIVATE_CHECKBOX = DEVICE + "/ancestor::mat-row//mat-icon[contains(text(),'check_box_outline_blank')]";
 | 
			
		||||
    private static final String MAKE_DEVICE_PRIVATE_BTN_DETAILS_TAB = "//span[contains(text(),'Make device private')]/parent::button";
 | 
			
		||||
 | 
			
		||||
    public WebElement device(String deviceName) {
 | 
			
		||||
        return waitUntilElementToBeClickable(String.format(DEVICE, deviceName));
 | 
			
		||||
@ -204,4 +210,28 @@ public class DevicePageElements extends OtherPageElementsHelper {
 | 
			
		||||
    public List<WebElement> listOfDevicesProfile() {
 | 
			
		||||
        return waitUntilVisibilityOfElementsLocated(LIST_OF_DEVICES_PROFILE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement makeDevicePublicBtn(String deviceName) {
 | 
			
		||||
        return waitUntilElementToBeClickable(String.format(MAKE_DEVICE_PUBLIC_BTN, deviceName));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement deviceIsPublicCheckbox(String deviceName) {
 | 
			
		||||
        return waitUntilVisibilityOfElementLocated(String.format(DEVICE_IS_PUBLIC_CHECKBOX, deviceName));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement makeDevicePublicBtnDetailsTab() {
 | 
			
		||||
        return waitUntilElementToBeClickable(MAKE_DEVICE_PUBLIC_BTN_DETAILS_TAB);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement makeDevicePrivateBtn(String deviceName) {
 | 
			
		||||
        return waitUntilElementToBeClickable(String.format(MAKE_DEVICE_PRIVATE_BTN, deviceName));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement deviceIsPrivateCheckbox(String deviceName) {
 | 
			
		||||
        return waitUntilVisibilityOfElementLocated(String.format(DEVICE_IS_PRIVATE_CHECKBOX, deviceName));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public WebElement makeDevicePrivateBtnDetailsTab() {
 | 
			
		||||
        return waitUntilElementToBeClickable(MAKE_DEVICE_PRIVATE_BTN_DETAILS_TAB);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -123,4 +123,24 @@ public class DevicePageHelper extends DevicePageElements {
 | 
			
		||||
        sleep(2); //wait until the action is counted
 | 
			
		||||
        submitBtn().click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void makeDevicePublicByRightSideBtn(String deviceName) {
 | 
			
		||||
        makeDevicePublicBtn(deviceName).click();
 | 
			
		||||
        warningPopUpYesBtn().click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void makeDevicePublicFromDetailsTab() {
 | 
			
		||||
        makeDevicePublicBtnDetailsTab().click();
 | 
			
		||||
        warningPopUpYesBtn().click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void makeDevicePrivateByRightSideBtn(String deviceName) {
 | 
			
		||||
        makeDevicePrivateBtn(deviceName).click();
 | 
			
		||||
        warningPopUpYesBtn().click();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void makeDevicePrivateFromDetailsTab() {
 | 
			
		||||
        makeDevicePrivateBtnDetailsTab().click();
 | 
			
		||||
        warningPopUpYesBtn().click();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -34,6 +34,7 @@ import java.util.List;
 | 
			
		||||
import static org.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random;
 | 
			
		||||
import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME;
 | 
			
		||||
import static org.thingsboard.server.msa.ui.utils.Const.PUBLIC_CUSTOMER_NAME;
 | 
			
		||||
 | 
			
		||||
@Feature("Assign to customer")
 | 
			
		||||
public class AssignToCustomerTest extends AbstractDeviceTest {
 | 
			
		||||
@ -58,7 +59,7 @@ public class AssignToCustomerTest extends AbstractDeviceTest {
 | 
			
		||||
    @AfterClass
 | 
			
		||||
    public void deleteCustomer() {
 | 
			
		||||
        deleteCustomerById(customerId);
 | 
			
		||||
        deleteCustomerByName("Public");
 | 
			
		||||
        deleteCustomerByName(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
        deleteDeviceByName(device1.getName());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,79 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2023 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.devicessmoke;
 | 
			
		||||
 | 
			
		||||
import io.qameta.allure.Description;
 | 
			
		||||
import io.qameta.allure.Epic;
 | 
			
		||||
import org.openqa.selenium.WebElement;
 | 
			
		||||
import org.testng.annotations.AfterClass;
 | 
			
		||||
import org.testng.annotations.BeforeMethod;
 | 
			
		||||
import org.testng.annotations.Test;
 | 
			
		||||
import org.thingsboard.server.common.data.Device;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.CustomerPageHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.utils.EntityPrototypes;
 | 
			
		||||
 | 
			
		||||
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random;
 | 
			
		||||
import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME;
 | 
			
		||||
import static org.thingsboard.server.msa.ui.utils.Const.PUBLIC_CUSTOMER_NAME;
 | 
			
		||||
 | 
			
		||||
@Epic("Make device private")
 | 
			
		||||
public class MakeDevicePrivateTest extends AbstractDeviceTest {
 | 
			
		||||
 | 
			
		||||
    private CustomerPageHelper customerPage;
 | 
			
		||||
 | 
			
		||||
    @BeforeMethod
 | 
			
		||||
    public void createPublicDevice() {
 | 
			
		||||
        customerPage = new CustomerPageHelper(driver);
 | 
			
		||||
        Device device = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype(ENTITY_NAME + random()));
 | 
			
		||||
        testRestClient.setDevicePublic(device.getId());
 | 
			
		||||
        deviceName = device.getName();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @AfterClass
 | 
			
		||||
    public void deletePublicCustomer() {
 | 
			
		||||
        deleteCustomerByName(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(groups = "smoke")
 | 
			
		||||
    @Description("Make device private by right side btn")
 | 
			
		||||
    public void makeDevicePrivateByRightSideBtn() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.makeDevicePrivateByRightSideBtn(deviceName);
 | 
			
		||||
        WebElement customerInColumn = devicePage.deviceCustomerOnPage(deviceName);
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceIsPrivateCheckbox(deviceName));
 | 
			
		||||
        assertInvisibilityOfElement(customerInColumn);
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.customerBtn().click();
 | 
			
		||||
        customerPage.manageCustomersDevicesBtn(PUBLIC_CUSTOMER_NAME).click();
 | 
			
		||||
        devicePage.assertEntityIsNotPresent(deviceName);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(groups = "smoke")
 | 
			
		||||
    @Description("Make device public by btn on details tab")
 | 
			
		||||
    public void makeDevicePrivateFromDetailsTab() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.device(deviceName).click();
 | 
			
		||||
        WebElement customerInColumn = devicePage.deviceCustomerOnPage(deviceName);
 | 
			
		||||
        devicePage.makeDevicePrivateFromDetailsTab();
 | 
			
		||||
        devicePage.closeDeviceDetailsViewBtn().click();
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceIsPrivateCheckbox(deviceName));
 | 
			
		||||
        assertInvisibilityOfElement(customerInColumn);
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.customerBtn().click();
 | 
			
		||||
        customerPage.manageCustomersDevicesBtn(PUBLIC_CUSTOMER_NAME).click();
 | 
			
		||||
        devicePage.assertEntityIsNotPresent(deviceName);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -0,0 +1,127 @@
 | 
			
		||||
/**
 | 
			
		||||
 * Copyright © 2016-2023 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.devicessmoke;
 | 
			
		||||
 | 
			
		||||
import io.qameta.allure.Description;
 | 
			
		||||
import io.qameta.allure.Feature;
 | 
			
		||||
import org.testng.annotations.AfterClass;
 | 
			
		||||
import org.testng.annotations.BeforeClass;
 | 
			
		||||
import org.testng.annotations.BeforeMethod;
 | 
			
		||||
import org.testng.annotations.Test;
 | 
			
		||||
import org.thingsboard.server.msa.ui.pages.CustomerPageHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.tabs.AssignDeviceTabHelper;
 | 
			
		||||
import org.thingsboard.server.msa.ui.utils.EntityPrototypes;
 | 
			
		||||
 | 
			
		||||
import static org.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
import static org.thingsboard.server.msa.ui.base.AbstractBasePage.random;
 | 
			
		||||
import static org.thingsboard.server.msa.ui.utils.Const.ENTITY_NAME;
 | 
			
		||||
import static org.thingsboard.server.msa.ui.utils.Const.PUBLIC_CUSTOMER_NAME;
 | 
			
		||||
 | 
			
		||||
@Feature("Make device public")
 | 
			
		||||
public class MakeDevicePublicTest extends AbstractDeviceTest {
 | 
			
		||||
 | 
			
		||||
    private CustomerPageHelper customerPage;
 | 
			
		||||
    private AssignDeviceTabHelper assignDeviceTab;
 | 
			
		||||
    private String deviceName1;
 | 
			
		||||
 | 
			
		||||
    @BeforeClass
 | 
			
		||||
    public void createFirstDevice() {
 | 
			
		||||
        customerPage = new CustomerPageHelper(driver);
 | 
			
		||||
        assignDeviceTab = new AssignDeviceTabHelper(driver);
 | 
			
		||||
 | 
			
		||||
        deviceName1 = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype(ENTITY_NAME + random())).getName();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @AfterClass
 | 
			
		||||
    public void cleanUp() {
 | 
			
		||||
        deleteCustomerByName(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
        deleteDeviceByName(deviceName1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @BeforeMethod
 | 
			
		||||
    public void createSecondDevice() {
 | 
			
		||||
        deviceName = testRestClient.postDevice("", EntityPrototypes.defaultDevicePrototype(ENTITY_NAME + random())).getName();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(groups = "smoke", priority = 10)
 | 
			
		||||
    @Description("Make device public by right side btn")
 | 
			
		||||
    public void makeDevicePublicByRightSideBtn() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.makeDevicePublicByRightSideBtn(deviceName);
 | 
			
		||||
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceIsPublicCheckbox(deviceName));
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceCustomerOnPage(deviceName));
 | 
			
		||||
        assertThat(devicePage.deviceCustomerOnPage(deviceName).getText())
 | 
			
		||||
                .as("Customer in customer column is Public customer")
 | 
			
		||||
                .isEqualTo(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.customerBtn().click();
 | 
			
		||||
        customerPage.manageCustomersDevicesBtn(PUBLIC_CUSTOMER_NAME).click();
 | 
			
		||||
        assertIsDisplayed(devicePage.device(deviceName));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(groups = "smoke", priority = 10)
 | 
			
		||||
    @Description("Make device public by btn on details tab")
 | 
			
		||||
    public void makeDevicePublicFromDetailsTab() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.device(deviceName).click();
 | 
			
		||||
        devicePage.makeDevicePublicFromDetailsTab();
 | 
			
		||||
        devicePage.closeDeviceDetailsViewBtn().click();
 | 
			
		||||
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceIsPublicCheckbox(deviceName));
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceCustomerOnPage(deviceName));
 | 
			
		||||
        assertThat(devicePage.deviceCustomerOnPage(deviceName).getText())
 | 
			
		||||
                .as("Customer in customer column is Public customer")
 | 
			
		||||
                .isEqualTo(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.customerBtn().click();
 | 
			
		||||
        customerPage.manageCustomersDevicesBtn(PUBLIC_CUSTOMER_NAME).click();
 | 
			
		||||
        assertIsDisplayed(devicePage.device(deviceName));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(groups = "smoke", priority = 20)
 | 
			
		||||
    @Description("Make device public by assign to public customer")
 | 
			
		||||
    public void makeDevicePublicByAssignToPublicCustomer() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.assignBtn(deviceName).click();
 | 
			
		||||
        assignDeviceTab.assignOnCustomer(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceIsPublicCheckbox(deviceName));
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceCustomerOnPage(deviceName));
 | 
			
		||||
        assertThat(devicePage.deviceCustomerOnPage(deviceName).getText()).isEqualTo(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.customerBtn().click();
 | 
			
		||||
        customerPage.manageCustomersDevicesBtn(PUBLIC_CUSTOMER_NAME).click();
 | 
			
		||||
        assertIsDisplayed(devicePage.device(deviceName));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test(groups = "smoke", priority = 20)
 | 
			
		||||
    @Description("Make several devices public by assign to public customer")
 | 
			
		||||
    public void makePublicSeveralDevicesByAssignOnPublicCustomer() {
 | 
			
		||||
        sideBarMenuView.goToDevicesPage();
 | 
			
		||||
        devicePage.assignSelectedDevices(deviceName, deviceName1);
 | 
			
		||||
        assignDeviceTab.assignOnCustomer(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceIsPublicCheckbox(deviceName));
 | 
			
		||||
        assertIsDisplayed(devicePage.deviceCustomerOnPage(deviceName));
 | 
			
		||||
        assertThat(devicePage.deviceCustomerOnPage(deviceName).getText())
 | 
			
		||||
                .as("Customer in customer column is Public customer")
 | 
			
		||||
                .isEqualTo(PUBLIC_CUSTOMER_NAME);
 | 
			
		||||
 | 
			
		||||
        sideBarMenuView.customerBtn().click();
 | 
			
		||||
        customerPage.manageCustomersDevicesBtn(PUBLIC_CUSTOMER_NAME).click();
 | 
			
		||||
        assertIsDisplayed(devicePage.device(deviceName));
 | 
			
		||||
        assertIsDisplayed(devicePage.device(deviceName1));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@ -47,4 +47,5 @@ public class Const {
 | 
			
		||||
    public static final String DEVICE_PROFILE_IS_REQUIRED_MESSAGE = "Device profile is required";
 | 
			
		||||
    public static final String DEVICE_ACTIVE_STATE = "Active";
 | 
			
		||||
    public static final String DEVICE_INACTIVE_STATE = "Inactive";
 | 
			
		||||
    public static final String PUBLIC_CUSTOMER_NAME = "Public";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user