Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 0d625f73 authored by Mihai BOZ's avatar Mihai BOZ
Browse files

Pull request #31: added PropertiesPageTests.

Merge in EDELIVERY/smp from EDELIVERY-11943-Progress-on-the-automation-of-the-DomiSMP-UI-tests---Part-4 to development

* commit 'c09b817d':
  added PropertiesPageTests.
parents 4da51387 c09b817d
No related branches found
No related tags found
No related merge requests found
Pipeline #87914 passed with warnings
......@@ -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");
}
}
......
......@@ -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);
}
......
......@@ -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();
}
}
......@@ -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();
}
}
......@@ -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();
}
......
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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment