Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

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

added tests for Edit resource page configuration tab

parent b95c9c8a
No related branches found
No related tags found
No related merge requests found
......@@ -24,7 +24,7 @@ public class GridWithoutPagination extends DComponent {
super(driver);
PageFactory.initElements(driver, this);
this.parentElement = parentElement;
wait.forXMillis(200);
}
public List<WebElement> getGridHeaders() {
......@@ -54,7 +54,6 @@ public class GridWithoutPagination extends DComponent {
LOG.error("No element found");
throw new NoSuchElementException("Column not found");
}
boolean isElementPresent = false;
List<WebElement> rows = getRows();
......@@ -62,7 +61,6 @@ public class GridWithoutPagination extends DComponent {
List<WebElement> cells = getCells(row);
WebElement currentCell = cells.get(columnIndex);
if (currentCell.getText().equalsIgnoreCase(value)) {
isElementPresent = true;
LOG.debug("Value: " + value + " has been found");
//Double Click on top right corner of element to prevent clicking on tooltip
Actions act = new Actions(driver);
......
......@@ -4,6 +4,8 @@ import ddsl.CommonPageWithTabsAndGrid;
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pages.systemSettings.domainsPage.ConfigurationTab.ConfigurationTab;
/**
* Page object for the Edit domains page. This contains the locators of the page and the methods for the behaviour of the page
*/
......@@ -20,6 +22,12 @@ public class EditDomainsPage extends CommonPageWithTabsAndGrid {
return new DomainMembersTab(driver);
}
public ConfigurationTab getConfigurationTab() {
return new ConfigurationTab(driver);
}
public GroupTab getGroupTab() {
return new GroupTab(driver);
......
......@@ -46,12 +46,17 @@ public class CreateResourceDetailsDialog extends DComponent {
}
public Boolean tryClickOnSave() {
wait.forElementToBeClickable(saveBtn);
if (weToDButton(saveBtn).isEnabled()) {
weToDButton(saveBtn).click();
return true;
} else {
try {
wait.forElementToBeClickable(saveBtn);
if (weToDButton(saveBtn).isEnabled()) {
weToDButton(saveBtn).click();
return true;
} else {
return false;
}
} catch (Exception e) {
return false;
}
}
}
......@@ -13,7 +13,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Page object for the Configuration tab of Domains page. This contains the locators of the page and the methods for the behaviour of the page
* Page object for the Configuration tab of Domains/Edit Domains page. This contains the locators of the page and the methods for the behaviour of the page
*/
public class ConfigurationTab extends DComponent {
private final static Logger LOG = LoggerFactory.getLogger(ConfigurationTab.class);
......@@ -27,7 +27,6 @@ public class ConfigurationTab extends DComponent {
public ConfigurationTab(WebDriver driver) {
super(driver);
PageFactory.initElements(new AjaxElementLocatorFactory(driver, data.getWaitTimeShort()), this);
}
private GridWithoutPagination getConfigurationGrid() {
......
......@@ -14,8 +14,10 @@ import pages.systemSettings.domainsPage.ConfigurationTab.ConfigurationTab;
*/
public class DomainsPage extends CommonPageWithTabsAndGrid {
private final static Logger LOG = LoggerFactory.getLogger(DomainsPage.class);
@FindBy(css = "smp-warning-panel span")
private WebElement warningLabel;
public DomainsPage(WebDriver driver) {
super(driver);
LOG.debug("Loading Domains page.");
......
......@@ -35,7 +35,7 @@ public class DomainClient extends BaseRestClient {
ClientResponse response = jsonPUT(resource.path(createDomainPath), domainJson);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not create domain", response);
throw new SMPRestException("Could not create domain", response.getStatus(), response.getEntity(String.class));
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
......@@ -52,7 +52,7 @@ public class DomainClient extends BaseRestClient {
ClientResponse response = jsonPUT(resource.path(addMemberPath), membersJson);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not create domain", response);
throw new SMPRestException("Could not create domain", response.getStatus(), response.getEntity(String.class));
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
......@@ -73,7 +73,7 @@ public class DomainClient extends BaseRestClient {
ClientResponse response = requestPOST(resource.path(addMemberPath), resourceTypes);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not add resource!", response);
throw new SMPRestException("Could not add resource!", response.getStatus(), response.getEntity(String.class));
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
......@@ -88,7 +88,7 @@ public class DomainClient extends BaseRestClient {
ClientResponse response = jsonPUT(resource.path(createGroupPath), groupJson);
if (response.getStatus() != 200) {
try {
throw new SMPRestException("Could not create group!", response);
throw new SMPRestException("Could not create group!", response.getStatus(), response.getEntity(String.class));
} catch (SMPRestException e) {
throw new RuntimeException(e);
}
......
package domiSMPTests.ui;
import ddsl.DomiSMPPage;
import ddsl.dcomponents.commonComponents.domanPropertyEditDialog.DomainPropertyEditDialog;
import ddsl.dcomponents.commonComponents.members.InviteMembersWithGridPopup;
import ddsl.enums.Pages;
import ddsl.enums.ResourceTypes;
import domiSMPTests.SeleniumTest;
import org.openqa.selenium.WebElement;
import org.testng.annotations.BeforeMethod;
......@@ -11,11 +13,13 @@ import org.testng.asserts.SoftAssert;
import pages.LoginPage;
import pages.administration.editDomainsPage.CreateGroupDetailsDialog;
import pages.administration.editDomainsPage.EditDomainsPage;
import pages.administration.editGroupsPage.CreateResourceDetailsDialog;
import pages.administration.editGroupsPage.EditGroupsPage;
import rest.models.DomainModel;
import rest.models.GroupModel;
import rest.models.MemberModel;
import rest.models.UserModel;
import rest.models.*;
import utils.TestRunData;
import java.util.Arrays;
import java.util.List;
/**
* Test class for Edit domains page tests.
......@@ -28,6 +32,10 @@ public class EditDomainsPgTests extends SeleniumTest {
EditDomainsPage editDomainPage;
DomainModel domainModel;
UserModel adminUser;
UserModel normalUser;
MemberModel memberAdmin;
MemberModel memberUser;
SoftAssert soft;
@BeforeMethod(alwaysRun = true)
......@@ -35,14 +43,24 @@ public class EditDomainsPgTests extends SeleniumTest {
soft = new SoftAssert();
domainModel = DomainModel.generatePublicDomainModelWithSML();
adminUser = UserModel.generateUserWithADMINrole();
normalUser = UserModel.generateUserWithUSERrole();
memberAdmin = new MemberModel();
memberAdmin.setUsername(adminUser.getUsername());
memberAdmin.setRoleType("ADMIN");
MemberModel domainMember = new MemberModel();
domainMember.setUsername(adminUser.getUsername());
domainMember.setRoleType("ADMIN");
memberUser = new MemberModel();
memberUser.setUsername(normalUser.getUsername());
memberUser.setRoleType("ADMIN");
rest.users().createUser(adminUser);
rest.users().createUser(normalUser);
domainModel = rest.domains().createDomain(domainModel);
rest.domains().addMembersToDomain(domainModel, domainMember);
rest.domains().addMembersToDomain(domainModel, memberAdmin);
rest.domains().addMembersToDomain(domainModel, memberUser);
homePage = new DomiSMPPage(driver);
loginPage = homePage.goToLoginPage();
......@@ -134,4 +152,161 @@ public class EditDomainsPgTests extends SeleniumTest {
soft.assertEquals(deleteMessage, String.format("Domain group [%s] deleted", groupToBeDeleted.getGroupName()));
soft.assertAll();
}
@Test(description = "EDTDOM-09 Domain admins are able to change default properties for domains")
public void domainAdminsAreAbleToChangeDefaultPropertiesForDomains() throws Exception {
DomainModel currentDomainModel = DomainModel.generatePublicDomainModelWithSML();
//create domain
currentDomainModel = rest.domains().createDomain(currentDomainModel);
// rest.domains().addMembersToDomain(domainModel, adminMember);
rest.domains().addMembersToDomain(currentDomainModel, memberUser);
//add resources to domain
List<ResourceTypes> resourcesToBeAdded = Arrays.asList(ResourceTypes.OASIS1, ResourceTypes.OASIS3, ResourceTypes.OASIS2);
currentDomainModel = rest.domains().addResourcesToDomain(currentDomainModel, resourcesToBeAdded);
editDomainPage.logout();
//Login with user role which is domain admin
loginPage.login(normalUser.getUsername(), data.getNewPassword());
editDomainPage = homePage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_DOMAINS);
editDomainPage
.getLeftSideGrid().searchAndClickElementInColumn("Domain code", currentDomainModel.getDomainCode());
editDomainPage.goToTab("Configuration");
//Check is modifying boolean values
String boolPropertyName = "identifiersBehaviour.scheme.mandatory";
DomainPropertyEditDialog domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(boolPropertyName);
domainPropertyEditDialog.setDomainValue(false);
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertFalse(editDomainPage.getConfigurationTab().isSystemValueUsed(boolPropertyName), "Property is marked as it's using system value");
soft.assertEquals("false", editDomainPage.getConfigurationTab().getCurrentPropertyValue(boolPropertyName));
//Verify disabling system property
String useDomainProperty = "identifiersBehaviour.ParticipantIdentifierScheme.validationRegex";
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(useDomainProperty);
domainPropertyEditDialog.disableSystemValue();
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertFalse(editDomainPage.getConfigurationTab().isSystemValueUsed(useDomainProperty), "Property is marked as it's using system value");
//Verify change to enabling system property
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(useDomainProperty);
domainPropertyEditDialog.enableSystemValue();
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
//verify changes
soft.assertTrue(editDomainPage.getConfigurationTab().isSystemValueUsed(useDomainProperty));
// String property value
String stringProperty = "identifiersBehaviour.caseSensitive.DocumentIdentifierSchemes";
String defaultPropertyValue = editDomainPage.getConfigurationTab().getCurrentPropertyValue(stringProperty);
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(stringProperty);
domainPropertyEditDialog.setDomainValue("${identifier}${identifier}");
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
soft.assertFalse(editDomainPage.getConfigurationTab().isSystemValueUsed(stringProperty), "Property is marked as it's using system value");
soft.assertTrue(editDomainPage.getConfigurationTab().getCurrentPropertyValue(stringProperty).equalsIgnoreCase("${identifier}${identifier}"), "Configuration table is not showing updated value");
//Check if the property value is updated with system value after use system value is enabled
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(stringProperty);
domainPropertyEditDialog.enableSystemValue();
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
soft.assertTrue(editDomainPage.getConfigurationTab().getCurrentPropertyValue(stringProperty).equalsIgnoreCase(defaultPropertyValue), "Configuration table is not showing system value");
soft.assertAll();
}
@Test(description = "EDTDOM-11 Domain properties values are applied")
public void domanPropertiesAreApplied() throws Exception {
DomainModel currentDomainModel = DomainModel.generatePublicDomainModelWithSML();
GroupModel currentGroupModel = GroupModel.generatePublicGroup();
MemberModel superMember = new MemberModel();
superMember.setUsername(TestRunData.getInstance().getAdminUsername());
superMember.setRoleType("ADMIN");
//create domain
currentDomainModel = rest.domains().createDomain(currentDomainModel);
rest.domains().addMembersToDomain(currentDomainModel, memberUser);
rest.domains().addMembersToDomain(currentDomainModel, superMember);
//add resources to domain
List<ResourceTypes> resourcesToBeAdded = Arrays.asList(ResourceTypes.OASIS1, ResourceTypes.OASIS3, ResourceTypes.OASIS2);
currentDomainModel = rest.domains().addResourcesToDomain(currentDomainModel, resourcesToBeAdded);
//create group for domain
currentGroupModel = rest.domains().createGroupForDomain(currentDomainModel, currentGroupModel);
//add users to groups
rest.groups().addMembersToGroup(currentDomainModel, currentGroupModel, memberUser);
editDomainPage.logout();
//Login with user role which is domain admin
loginPage.login(normalUser.getUsername(), data.getNewPassword());
editDomainPage = homePage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_DOMAINS);
editDomainPage
.getLeftSideGrid().searchAndClickElementInColumn("Domain code", currentDomainModel.getDomainCode());
editDomainPage.goToTab("Configuration");
//Remove resource schema mandatory
String boolPropertyName = "identifiersBehaviour.scheme.mandatory";
DomainPropertyEditDialog domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(boolPropertyName);
domainPropertyEditDialog.setDomainValue(false);
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
EditGroupsPage editGroupsPage = editDomainPage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_GROUPS);
editGroupsPage.selectDomain(currentDomainModel, currentGroupModel);
editGroupsPage.goToTab("Resources");
CreateResourceDetailsDialog createResourceDetailsDialog = editGroupsPage.getResourceTab().clickOnCreateNewResource();
//create resource without Resource schema field
ResourceModel resourceModel = ResourceModel.generatePublicResource();
resourceModel.setIdentifierScheme("");
createResourceDetailsDialog.fillResourceDetails(resourceModel);
createResourceDetailsDialog.tryClickOnSave();
soft.assertTrue(editGroupsPage.getResourceTab().getGrid().isValuePresentInColumn("Identifier", resourceModel.getIdentifierValue()), "Resource was not found in the grid");
//Enable resource schema mandatory
editGroupsPage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_DOMAINS);
editDomainPage
.getLeftSideGrid().searchAndClickElementInColumn("Domain code", currentDomainModel.getDomainCode());
editDomainPage.goToTab("Configuration");
domainPropertyEditDialog = editDomainPage.getConfigurationTab().openProperty(boolPropertyName);
domainPropertyEditDialog.enableSystemValue();
domainPropertyEditDialog.pressOk();
editDomainPage.getConfigurationTab().saveChanges();
//verify is schema is mandatory - using system property value
editGroupsPage.getSidebar().navigateTo(Pages.ADMINISTRATION_EDIT_GROUPS);
editGroupsPage.selectDomain(currentDomainModel, currentGroupModel);
editGroupsPage.goToTab("Resources");
createResourceDetailsDialog = editGroupsPage.getResourceTab().clickOnCreateNewResource();
//create resource without Resource schema field
ResourceModel resourceModel2 = ResourceModel.generatePublicResource();
resourceModel2.setIdentifierScheme("");
createResourceDetailsDialog.fillResourceDetails(resourceModel2);
Boolean saveisDisabled = createResourceDetailsDialog.tryClickOnSave();
soft.assertFalse(saveisDisabled, "Save action didn't worked");
soft.assertFalse(editGroupsPage.getResourceTab().getGrid().isValuePresentInColumn("Identifier", resourceModel2.getIdentifierValue()), "Resource is present in the grid");
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