committed by
GitHub
12 changed files with 406 additions and 5 deletions
@ -0,0 +1,39 @@ |
|||
/** |
|||
* 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.pages; |
|||
|
|||
import org.openqa.selenium.WebDriver; |
|||
import org.openqa.selenium.WebElement; |
|||
|
|||
public class AlarmWidgetElements extends AlarmDetailsEntityTabHelper { |
|||
public AlarmWidgetElements(WebDriver driver) { |
|||
super(driver); |
|||
} |
|||
|
|||
private static final String ASSIGN_USER_DISPLAY_NAME = "//span[contains(@class,'assigned-container')]/span[contains(text(),'%s')]"; |
|||
private static final String UNASSIGNED = "//span[text() = '%s']/ancestor::mat-row//span[contains(@class,'assigned-container')]" + |
|||
"//mat-icon[text() = 'account_circle']/following-sibling::span"; |
|||
|
|||
@Override |
|||
public WebElement assignedUser(String userEmail) { |
|||
return waitUntilElementToBeClickable(String.format(ASSIGN_USER_DISPLAY_NAME, userEmail)); |
|||
} |
|||
|
|||
@Override |
|||
public WebElement unassigned(String alarmType) { |
|||
return waitUntilVisibilityOfElementLocated(String.format(UNASSIGNED, alarmType)); |
|||
} |
|||
} |
|||
@ -0,0 +1,72 @@ |
|||
/** |
|||
* 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.pages; |
|||
|
|||
import org.openqa.selenium.WebDriver; |
|||
import org.openqa.selenium.WebElement; |
|||
import org.thingsboard.server.msa.ui.base.AbstractBasePage; |
|||
|
|||
public class CreateWidgetPopupElements extends AbstractBasePage { |
|||
public CreateWidgetPopupElements(WebDriver driver) { |
|||
super(driver); |
|||
} |
|||
|
|||
private static final String ENTITY_ALIAS = "//input[@formcontrolname='entityAlias']"; |
|||
private static final String CREATE_NEW_ALIAS_BTN = "//a[text() = 'Create a new one!']/parent::span"; |
|||
private static final String FILTER_TYPE_FIELD = "//div[contains(@class,'tb-entity-filter')]//mat-select//span"; |
|||
private static final String TYPE_FIELD = "//mat-select[@formcontrolname='entityType']//span"; |
|||
private static final String OPTION_FROM_DROPDOWN = "//span[text() = ' %s ']"; |
|||
private static final String ENTITY_FIELD = "//input[@formcontrolname='entity']"; |
|||
private static final String ADD_ALIAS_BTN = "//tb-entity-alias-dialog//span[text() = ' Add ']/parent::button"; |
|||
private static final String ADD_WIDGET_BTN = "//tb-add-widget-dialog//span[text() = ' Add ']/parent::button"; |
|||
private static final String ENTITY_FROM_DROPDOWN = "//b[text() = '%s']"; |
|||
|
|||
public WebElement entityAlias() { |
|||
return waitUntilElementToBeClickable(ENTITY_ALIAS); |
|||
} |
|||
|
|||
public WebElement createNewAliasBtn() { |
|||
return waitUntilElementToBeClickable(CREATE_NEW_ALIAS_BTN); |
|||
} |
|||
|
|||
public WebElement filterTypeFiled() { |
|||
return waitUntilElementToBeClickable(FILTER_TYPE_FIELD); |
|||
} |
|||
|
|||
public WebElement typeFiled() { |
|||
return waitUntilElementToBeClickable(TYPE_FIELD); |
|||
} |
|||
|
|||
public WebElement optionFromDropdown(String type) { |
|||
return waitUntilElementToBeClickable(String.format(OPTION_FROM_DROPDOWN, type)); |
|||
} |
|||
|
|||
public WebElement entityFiled() { |
|||
return waitUntilElementToBeClickable(ENTITY_FIELD); |
|||
} |
|||
|
|||
public WebElement addAliasBtn() { |
|||
return waitUntilElementToBeClickable(ADD_ALIAS_BTN); |
|||
} |
|||
|
|||
public WebElement addWidgetBtn() { |
|||
return waitUntilElementToBeClickable(ADD_WIDGET_BTN); |
|||
} |
|||
|
|||
public WebElement entityFromDropdown(String entityName) { |
|||
return waitUntilVisibilityOfElementLocated(String.format(ENTITY_FROM_DROPDOWN, entityName)); |
|||
} |
|||
} |
|||
@ -0,0 +1,48 @@ |
|||
/** |
|||
* 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.pages; |
|||
|
|||
import org.openqa.selenium.Keys; |
|||
import org.openqa.selenium.WebDriver; |
|||
import org.testcontainers.shaded.org.apache.commons.lang3.RandomStringUtils; |
|||
|
|||
public class CreateWidgetPopupHelper extends CreateWidgetPopupElements { |
|||
public CreateWidgetPopupHelper(WebDriver driver) { |
|||
super(driver); |
|||
} |
|||
|
|||
public void goToCreateEntityAliasPopup(String aliasName) { |
|||
entityAlias().sendKeys(aliasName + RandomStringUtils.randomAlphanumeric(7)); |
|||
createNewAliasBtn().click(); |
|||
} |
|||
|
|||
public void selectFilterType(String filterType) { |
|||
filterTypeFiled().click(); |
|||
optionFromDropdown(filterType).click(); |
|||
} |
|||
|
|||
public void selectType(String entityType) { |
|||
typeFiled().click(); |
|||
optionFromDropdown(entityType).click(); |
|||
} |
|||
|
|||
public void selectEntity(String entityName) { |
|||
entityFiled().sendKeys(entityName); |
|||
entityFromDropdown(entityName); |
|||
entityFiled().sendKeys(Keys.ARROW_DOWN); |
|||
entityFiled().sendKeys(Keys.ENTER); |
|||
} |
|||
} |
|||
@ -0,0 +1,146 @@ |
|||
/** |
|||
* 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.assignee; |
|||
|
|||
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.common.data.Dashboard; |
|||
import org.thingsboard.server.msa.ui.pages.AlarmWidgetElements; |
|||
import org.thingsboard.server.msa.ui.pages.CreateWidgetPopupHelper; |
|||
import org.thingsboard.server.msa.ui.pages.DashboardPageHelper; |
|||
import org.thingsboard.server.msa.ui.utils.Const; |
|||
import org.thingsboard.server.msa.ui.utils.EntityPrototypes; |
|||
|
|||
import static org.assertj.core.api.Assertions.assertThat; |
|||
|
|||
@Feature("Assign from details tab of entity") |
|||
public class AssignFromAlarmWidgetTest extends AbstractAssignTest { |
|||
|
|||
private Dashboard dashboard; |
|||
private DashboardPageHelper dashboardPage; |
|||
private AlarmWidgetElements alarmWidget; |
|||
|
|||
@BeforeClass |
|||
public void create() { |
|||
dashboardPage = new DashboardPageHelper(driver); |
|||
CreateWidgetPopupHelper createWidgetPopup = new CreateWidgetPopupHelper(driver); |
|||
alarmWidget = new AlarmWidgetElements(driver); |
|||
|
|||
dashboard = testRestClient.postDashboard(EntityPrototypes.defaultDashboardPrototype("Dashboard")); |
|||
sideBarMenuView.dashboardBtn().click(); |
|||
dashboardPage.entity(dashboard.getName()).click(); |
|||
dashboardPage.editBtn().click(); |
|||
dashboardPage.openSelectWidgetsBundleMenu(); |
|||
dashboardPage.openCreateWidgetPopup(); |
|||
createWidgetPopup.goToCreateEntityAliasPopup("Alias"); |
|||
createWidgetPopup.selectFilterType("Single entity"); |
|||
createWidgetPopup.selectType("Device"); |
|||
createWidgetPopup.selectEntity(deviceName); |
|||
createWidgetPopup.addAliasBtn().click(); |
|||
createWidgetPopup.addWidgetBtn().click(); |
|||
dashboardPage.increaseSizeOfTheWidget(); |
|||
dashboardPage.doneBtn().click(); |
|||
} |
|||
|
|||
@AfterClass |
|||
public void delete() { |
|||
deleteDashboardById(dashboard.getId()); |
|||
} |
|||
|
|||
@BeforeMethod |
|||
public void goToDashboardPage() { |
|||
sideBarMenuView.dashboardBtn().click(); |
|||
dashboardPage.entity(dashboard.getName()).click(); |
|||
} |
|||
|
|||
@Description("Can assign alarm to yourself") |
|||
@Test |
|||
public void assignAlarmToYourself() { |
|||
alarmWidget.assignAlarmTo(alarmType, Const.TENANT_EMAIL); |
|||
|
|||
assertIsDisplayed(alarmWidget.assignedUser(Const.TENANT_EMAIL)); |
|||
} |
|||
|
|||
@Description("Can reassign alarm to another user") |
|||
@Test |
|||
public void reassignAlarm() { |
|||
alarmWidget.assignAlarmTo(assignedAlarmType, userWithNameEmail); |
|||
|
|||
assertIsDisplayed(alarmWidget.assignedUser(userName)); |
|||
} |
|||
|
|||
@Description("Can unassign alarm") |
|||
@Test |
|||
public void unassignedAlarm() { |
|||
alarmWidget.unassignedAlarm(assignedAlarmType); |
|||
|
|||
assertIsDisplayed(alarmWidget.unassigned(assignedAlarmType)); |
|||
} |
|||
|
|||
@Description("Assign alarm to yourself from details of alarm") |
|||
@Test |
|||
public void assignAlarmToYourselfFromDetails() { |
|||
alarmWidget.alarmDetailsBtn(alarmType).click(); |
|||
alarmDetailsView.assignAlarmTo(Const.TENANT_EMAIL); |
|||
alarmDetailsView.closeAlarmDetailsViewBtn().click(); |
|||
|
|||
assertIsDisplayed(alarmWidget.assignedUser(Const.TENANT_EMAIL)); |
|||
} |
|||
|
|||
@Description("Reassign alarm to another user from details of alarm") |
|||
@Test |
|||
public void reassignAlarmFromDetails() { |
|||
alarmWidget.alarmDetailsBtn(assignedAlarmType).click(); |
|||
alarmDetailsView.assignAlarmTo(userWithNameEmail); |
|||
alarmDetailsView.closeAlarmDetailsViewBtn().click(); |
|||
|
|||
assertIsDisplayed(alarmWidget.assignedUser(userName)); |
|||
} |
|||
|
|||
@Description("Unassign alarm from details of alarm") |
|||
@Test |
|||
public void unassignedAlarmFromDetails() { |
|||
alarmWidget.alarmDetailsBtn(assignedAlarmType).click(); |
|||
alarmDetailsView.unassignedAlarm(); |
|||
alarmDetailsView.closeAlarmDetailsViewBtn().click(); |
|||
|
|||
assertIsDisplayed(alarmWidget.unassigned(assignedAlarmType)); |
|||
} |
|||
|
|||
@Description("Search by email") |
|||
@Test |
|||
public void searchByEmail() { |
|||
alarmWidget.searchAlarm(alarmType, Const.TENANT_EMAIL); |
|||
alarmWidget.setUsers(); |
|||
|
|||
assertThat(alarmWidget.getUsers()).hasSize(1).as("Search result contains search input").contains(Const.TENANT_EMAIL); |
|||
alarmWidget.assignUsers().forEach(this::assertIsDisplayed); |
|||
} |
|||
|
|||
@Description("Search by name") |
|||
@Test(groups = "broken") |
|||
public void searchByName() { |
|||
alarmWidget.searchAlarm(alarmType, userName); |
|||
alarmWidget.setUsers(); |
|||
|
|||
assertThat(alarmWidget.getUsers()).hasSize(1).as("Search result contains search input").contains(userName); |
|||
alarmWidget.assignUsers().forEach(this::assertIsDisplayed); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue