diff --git a/domiSMP-ui-tests/src/main/java/pages/DomainsPage/DomainTab.java b/domiSMP-ui-tests/src/main/java/pages/DomainsPage/DomainTab.java index cedb165ad23c7e8c036ce039a18ffb3004486033..1253fa58e73f6da23b45aa4dfc7df1b40fffc9a7 100644 --- a/domiSMP-ui-tests/src/main/java/pages/DomainsPage/DomainTab.java +++ b/domiSMP-ui-tests/src/main/java/pages/DomainsPage/DomainTab.java @@ -57,6 +57,8 @@ public class DomainTab extends DComponent { } else { LOG.error("Domain tab changes were not saved"); } + } else { + LOG.error("Save domain button is disabled"); } } diff --git a/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropGrid.java b/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropGrid.java index 176ad1c4524bb0946b95e229dcaff2d8a2b6f559..2fcbff624a6ca11161eb96d5c64ae88a396e2677 100644 --- a/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropGrid.java +++ b/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropGrid.java @@ -14,7 +14,7 @@ public class PropGrid extends BasicGrid { super(driver, container); } - public PropertyPopup selectValue(String propertyValue) { + public PropertyPopup doubleClickValue(String propertyValue) { this.doubleClickRow(propertyValue); return new PropertyPopup(driver); } diff --git a/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropertiesPage.java b/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropertiesPage.java index ab60bb507200589e394a0dfd85a8839c7a54d82e..85d561f4996bca624532748c4ec4c96f4df33d4a 100644 --- a/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropertiesPage.java +++ b/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropertiesPage.java @@ -25,6 +25,8 @@ public class PropertiesPage extends DomiSMPPage { private WebElement searchPropertyField; @FindBy(id = "searchbutton_id") private WebElement searchBtn; + @FindBy(css = "smp-search-table [id=\"editButton\"]") + private WebElement editBtn; public PropertiesPage(WebDriver driver) { @@ -42,16 +44,27 @@ public class PropertiesPage extends DomiSMPPage { wait.forElementToBeClickable(searchBtn).click(); } - public void setPropertyValue(String propertyName, String propertyValue) { - PropertyPopup popup = grid().selectValue(propertyName); - popup.editInputField(propertyValue); + public PropertyPopup openEditPropertyPopupup(String propertyName) { + return grid().doubleClickValue(propertyName); + } + + public PropertyPopup clickEdit() { try { - popup.clickOK(); + if (!weToDButton(editBtn).isEnabled()) { + LOG.error("Edit property button is not enabled"); + return null; + } + weToDButton(editBtn).click(); } catch (Exception e) { - LOG.error("Cannot set value for property {1}", propertyName); + LOG.error("Edit property button is not enabled"); + throw new RuntimeException(e); } + return new PropertyPopup(driver); + + } + public String getPropertyValue(String propertyName) { return grid().getPropertyValue(propertyName); @@ -61,6 +74,5 @@ public class PropertiesPage extends DomiSMPPage { weToDButton(saveBtn).click(); ConfirmationDialog confirmationDialog = new ConfirmationDialog(driver); confirmationDialog.confirm(); - } } diff --git a/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropertyPopup.java b/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropertyPopup.java index 4e830cab48a610b7c1b3ceb2619f1a17944f6924..0db1c40dde60038d01ca4ac46602cdfe1517b494 100644 --- a/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropertyPopup.java +++ b/domiSMP-ui-tests/src/main/java/pages/propertiesPage/PropertyPopup.java @@ -22,6 +22,9 @@ public class PropertyPopup extends DComponent { WebElement propertyCheckbox; @FindBy(css = "property-details-dialog input") WebElement propertryEditInput; + @FindBy(css = "property-details-dialog .alert-message-error") + WebElement errorMessageLbl; + public PropertyPopup(WebDriver driver) { super(driver); @@ -53,8 +56,11 @@ public class PropertyPopup extends DComponent { LOG.info("click OK"); wait.forElementToBeClickable(popupOkBtn); weToDButton(popupOkBtn).click(); - wait.forElementToBeGone(popupOkBtn); - return new PropertiesPage(driver); + if (!errorMessageLbl.isDisplayed()) { + wait.forElementToBeGone(popupOkBtn); + return new PropertiesPage(driver); + } + return null; } public PropertiesPage clickCancel() { @@ -99,4 +105,11 @@ public class PropertyPopup extends DComponent { propertryEditInput.clear(); propertryEditInput.sendKeys(string); } + + public String getErrorMessage() { + if (!errorMessageLbl.isDisplayed()) { + return null; + } + return errorMessageLbl.getText(); + } } diff --git a/domiSMP-ui-tests/src/test/java/domiSMPTests/ui/ProfilePgTests.java b/domiSMP-ui-tests/src/test/java/domiSMPTests/ui/ProfilePgTests.java index a03493b2c35022c3b8cd2dc8eea090600721db9d..6a2a64793f971aa5ccfc7d4b346fd7bc5458e1fd 100644 --- a/domiSMP-ui-tests/src/test/java/domiSMPTests/ui/ProfilePgTests.java +++ b/domiSMP-ui-tests/src/test/java/domiSMPTests/ui/ProfilePgTests.java @@ -8,6 +8,7 @@ import org.testng.annotations.Test; import pages.LoginPage; import pages.profilePage.ProfilePage; import pages.propertiesPage.PropertiesPage; +import pages.propertiesPage.PropertyPopup; import rest.models.UserModel; import utils.Generator; @@ -106,7 +107,7 @@ public class ProfilePgTests extends SeleniumTest { @Test(description = "PROF-03 Password validation is accord to the smp propeties values") public void PasswordValidationsShouldBeAccordingToPropertiesValue() throws Exception { - String propertyValue = "smp.passwordPolicy.validationRegex"; + String propertyName = "smp.passwordPolicy.validationRegex"; String newPropertyValue = "^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[~`!@#$%^&+=\\-_<>.,?:;*/()|\\[\\]{}'\"\\\\]).{16,40}$"; String new40CharactersPasswordValue = "Edeltest!23456789Edeltest!234567890sssf"; @@ -119,9 +120,11 @@ public class ProfilePgTests extends SeleniumTest { loginPage.login(adminUser.getUsername(), data.getNewPassword()); PropertiesPage propertiesPage = homePage.getSidebar().navigateTo(Pages.SYSTEM_SETTINGS_PROPERTIES); - propertiesPage.propertySearch(propertyValue); - if (!propertiesPage.getPropertyValue(propertyValue).equals(newPropertyValue)) { - propertiesPage.setPropertyValue("smp.passwordPolicy.validationRegex", newPropertyValue); + propertiesPage.propertySearch(propertyName); + if (!propertiesPage.getPropertyValue(propertyName).equals(newPropertyValue)) { + PropertyPopup propertyEditPoup = propertiesPage.openEditPropertyPopupup(propertyName); + propertyEditPoup.editInputField(newPropertyValue); + propertyEditPoup.clickOK(); propertiesPage.save(); } diff --git a/domiSMP-ui-tests/src/test/java/domiSMPTests/ui/PropertiesPgTests.java b/domiSMP-ui-tests/src/test/java/domiSMPTests/ui/PropertiesPgTests.java new file mode 100644 index 0000000000000000000000000000000000000000..fdb0429bfb8d2536cb5f3dec2998abcbb8577c95 --- /dev/null +++ b/domiSMP-ui-tests/src/test/java/domiSMPTests/ui/PropertiesPgTests.java @@ -0,0 +1,216 @@ +package domiSMPTests.ui; + +import ddsl.DomiSMPPage; +import ddsl.enums.Pages; +import domiSMPTests.SeleniumTest; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; +import org.testng.asserts.SoftAssert; +import pages.LoginPage; +import pages.propertiesPage.PropertiesPage; +import pages.propertiesPage.PropertyPopup; +import rest.models.UserModel; +import utils.Generator; + +public class PropertiesPgTests extends SeleniumTest { + + DomiSMPPage homePage; + UserModel adminUser; + PropertiesPage propertiesPage; + SoftAssert soft; + + @BeforeClass(alwaysRun = true) + public void beforeClass() { + adminUser = UserModel.generateUserWithADMINrole(); + rest.users().createUser(adminUser); + } + + @BeforeMethod(alwaysRun = true) + public void beforeTest() throws Exception { + soft = new SoftAssert(); + homePage = new DomiSMPPage(driver); + LoginPage loginPage = homePage.goToLoginPage(); + loginPage.login(adminUser.getUsername(), data.getNewPassword()); + propertiesPage = homePage.getSidebar().navigateTo(Pages.SYSTEM_SETTINGS_PROPERTIES); + } + + @Test(description = "PRP-2 - Admin doubleclicks or selects a property and clicks edit button and Edit property dialog is opened") + public void AdminDoubleClicksOrSelectsAPropertyAndClicksEditButtonandEditPropertyDialogIsOpened() throws Exception { + + String property = "bdmsl.integration.url"; + propertiesPage.propertySearch(property); + + //Check if popup opens when double click property + PropertyPopup propertyEditPoup = propertiesPage.openEditPropertyPopupup(property); + propertyEditPoup.clickCancel(); + soft.assertNotNull(propertyEditPoup); + + //Check if popup opens when clicking EDIT button + propertyEditPoup = null; + propertyEditPoup = propertiesPage.clickEdit(); + soft.assertNotNull(propertyEditPoup); + soft.assertAll(); + } + + @Test(description = "PRP-5 Value is validated according to expected format (URL") + public void PropertyValueURLIsValidatedAccordingToExpectedFormat() throws Exception { + + String property = "bdmsl.integration.url"; + String wrongValue1 = Generator.randomAlphaNumeric(6); + String wrongValue2 = wrongValue1 + ".com"; + String wrongValue3 = "www." + wrongValue1 + ".com"; + + propertiesPage.propertySearch(property); + String currentValue = propertiesPage.getPropertyValue(property); + PropertyPopup propertyEditPoup = propertiesPage.openEditPropertyPopupup(property); + + + propertyEditPoup.editInputField(wrongValue1); + propertyEditPoup.clickOK(); + String error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid URL address: [" + wrongValue1 + "]. Error:MalformedURLException: no protocol: " + wrongValue1 + "]!"); + + + propertyEditPoup.editInputField(wrongValue2); + propertyEditPoup.clickOK(); + error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid URL address: [" + wrongValue2 + "]. Error:MalformedURLException: no protocol: " + wrongValue2 + "]!"); + + propertyEditPoup.editInputField(wrongValue3); + propertyEditPoup.clickOK(); + error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid URL address: [" + wrongValue3 + "]. Error:MalformedURLException: no protocol: " + wrongValue3 + "]!"); + + //Check if property value hasn't changed. + propertyEditPoup.clickCancel(); + propertiesPage.refreshPage(); + + propertiesPage.propertySearch(property); + String valueAfterEdit = propertiesPage.getPropertyValue(property); + soft.assertEquals(valueAfterEdit, currentValue); + + soft.assertAll(); + } + + @Test(description = "PRP-5 Value is validated according to expected format (email)") + public void PropertyValueEmailIsValidatedAccordingToExpectedFormat() throws Exception { + + String property = "smp.alert.mail.from"; + String wrongValue1 = Generator.randomAlphaNumeric(6); + String wrongValue2 = wrongValue1 + "@yahoo"; + String wrongValue3 = wrongValue1 + ".com"; + + propertiesPage.propertySearch(property); + String currentValue = propertiesPage.getPropertyValue(property); + PropertyPopup propertyEditPoup = propertiesPage.openEditPropertyPopupup(property); + + + propertyEditPoup.editInputField(wrongValue1); + propertyEditPoup.clickOK(); + String error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid email address: [" + wrongValue1 + "].]!"); + + + propertyEditPoup.editInputField(wrongValue2); + propertyEditPoup.clickOK(); + error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid email address: [" + wrongValue2 + "].]!"); + + propertyEditPoup.editInputField(wrongValue3); + propertyEditPoup.clickOK(); + error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid email address: [" + wrongValue3 + "].]!"); + + //Check if property value hasn't changed. + propertyEditPoup.clickCancel(); + propertiesPage.refreshPage(); + + propertiesPage.propertySearch(property); + String valueAfterEdit = propertiesPage.getPropertyValue(property); + soft.assertEquals(valueAfterEdit, currentValue); + + soft.assertAll(); + } + + @Test(description = "PRP-5 Value is validated according to expected format (cron expression)") + public void PropertyValueCRONexpressionIsValidatedAccordingToExpectedFormat() throws Exception { + + String property = "smp.alert.credentials.cronJobExpression"; + String wrongValue1 = Generator.randomAlphaNumeric(6); + String wrongValue2 = "0 0/1 * * * * *"; + String wrongValue3 = "0 A * * * * "; + + propertiesPage.propertySearch(property); + String currentValue = propertiesPage.getPropertyValue(property); + PropertyPopup propertyEditPoup = propertiesPage.openEditPropertyPopupup(property); + + + propertyEditPoup.editInputField(wrongValue1); + propertyEditPoup.clickOK(); + String error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [cron expression: [" + wrongValue1 + "]. Error:IllegalArgumentException: Cron expression must consist of 6 fields (found 1 in \"" + wrongValue1 + "\")]!"); + + + propertyEditPoup.editInputField(wrongValue2); + propertyEditPoup.clickOK(); + error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [cron expression: [" + wrongValue2 + "]. Error:IllegalArgumentException: Cron expression must consist of 6 fields (found 7 in \"" + wrongValue2 + "\")]!"); + + propertyEditPoup.editInputField(wrongValue3); + propertyEditPoup.clickOK(); + error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [cron expression: [" + wrongValue3 + "]. Error:NumberFormatException: For input string: \"A\"]!"); + + //Check if property value hasn't changed. + propertyEditPoup.clickCancel(); + propertiesPage.refreshPage(); + + propertiesPage.propertySearch(property); + String valueAfterEdit = propertiesPage.getPropertyValue(property); + soft.assertEquals(valueAfterEdit, currentValue); + + soft.assertAll(); + } + + @Test(description = "PRP-5 Value is validated according to expected format (numeric)") + public void PropertyValueNumericIsValidatedAccordingToExpectedFormat() throws Exception { + + String property = "smp.ui.session.idle_timeout.user"; + String wrongValue1 = Generator.randomAlphaNumeric(6); + String wrongValue2 = "333333333333333333333333333333333333333333333333333333"; + String wrongValue3 = "0 A * * * * "; + + propertiesPage.propertySearch(property); + String currentValue = propertiesPage.getPropertyValue(property); + PropertyPopup propertyEditPoup = propertiesPage.openEditPropertyPopupup(property); + + + propertyEditPoup.editInputField(wrongValue1); + propertyEditPoup.clickOK(); + String error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid integer: [" + wrongValue1 + "]. Error:NumberFormatException: For input string: \"" + wrongValue1 + "\"]!"); + + + propertyEditPoup.editInputField(wrongValue2); + propertyEditPoup.clickOK(); + error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid integer: [" + wrongValue2 + "]. Error:NumberFormatException: For input string: \"" + wrongValue2 + "\"]!"); + + propertyEditPoup.editInputField(wrongValue3); + propertyEditPoup.clickOK(); + error = propertyEditPoup.getErrorMessage(); + soft.assertEquals(error, "Configuration error: [Invalid integer: [" + wrongValue3 + "]. Error:NumberFormatException: For input string: \"" + wrongValue3 + "\"]!"); + + //Check if property value hasn't changed. + propertyEditPoup.clickCancel(); + propertiesPage.refreshPage(); + + propertiesPage.propertySearch(property); + String valueAfterEdit = propertiesPage.getPropertyValue(property); + soft.assertEquals(valueAfterEdit, currentValue); + + soft.assertAll(); + } + +}