diff --git a/src/main/java/framework/ui/locators/simplOpen/Authority.java b/src/main/java/framework/ui/locators/simplOpen/Authority.java index cd40957483655e39ae71ef9edf708a9fa719c515..91efe1296e4ca764023bfd8d2d12c09382239263 100644 --- a/src/main/java/framework/ui/locators/simplOpen/Authority.java +++ b/src/main/java/framework/ui/locators/simplOpen/Authority.java @@ -104,6 +104,10 @@ public class Authority { public static final String IDENTITY_ATTRIBUTE_LIST_CREATION_DATE_HEADER_LOCATOR = "//div[contains(text(),'Creation date')]"; public static final String IDENTITY_ATTRIBUTE_LIST_LAST_CHANGE_DATE_HEADER_LOCATOR = "//div[contains(text(),'Last change date')]"; public static final String IDENTITY_ATTRIBUTE_LIST_ACTIONS_HEADER_LOCATOR = "//div[contains(text(),'Actions')]"; + public static final String IDENTITY_ATTRIBUTE_LIST_DELETE_COLUMN_LOCATOR = "td > div > button > mat-icon"; + public static final String IDENTITY_ATTRIBUTE_LIST_DELETE_DIALOG_LOCATOR = "[role=dialog]"; + public static final String IDENTITY_ATTRIBUTE_LIST_DELETE_DIALOG_TITLE_LOCATOR = "h2[mat-dialog-title]"; + public static final String IDENTITY_ATTRIBUTE_LIST_DELETE_DIALOG_MESSAGE_LOCATOR = "mat-dialog-content p"; public static final String EMPTY_LIST_MESSAGE_LOCATOR = "div.p-5.text-center"; public static final String LIST_IDENTITY_ATTRIBUTE_ID_LOCATOR = "//td[@class='mat-mdc-cell mdc-data-table__cell cdk-cell cdk-column-id mat-column-id ng-star-inserted']"; public static final String IDENTITY_ATTRIBUTE_EDIT_BUTTON_LOCATOR = "//span[normalize-space()='Edit Attribute']"; diff --git a/src/main/java/framework/ui/pages/simplOpen/AuthorityPage.java b/src/main/java/framework/ui/pages/simplOpen/AuthorityPage.java index 4e94294c046a6ccc359c5aa3ace3ade3c657a7ba..051e636192ac905b43574a186b6680b875152907 100644 --- a/src/main/java/framework/ui/pages/simplOpen/AuthorityPage.java +++ b/src/main/java/framework/ui/pages/simplOpen/AuthorityPage.java @@ -17,6 +17,7 @@ import static configuration.ui.data.simplOpen.Authority.ALERT_DISPLAYING_SUCCESS import static framework.common.Assertions.*; import static framework.ui.locators.simplOpen.Authority.*; import static framework.ui.locators.simplOpen.Authority.REQUEST_STATUS_LOCATOR; +import static org.junit.Assert.assertTrue; public class AuthorityPage { private final Page page = UiSetup.getPage(); @@ -440,4 +441,36 @@ public class AuthorityPage { throw new AssertionError("The status: " + expectedStatus + " is not displayed. Found: " + actualStatus); } } + + /*** + *Validates values in an Identity Attribute table column. + * Basically, it validates that for the "Assignable to Role" and "In Use" columns boolean values are displayed + * and for the "Action" column the button with an image is displayed to delete the row. + * @param columnName + */ + public void validateColumnValueForEachIdentityAttribute(String columnName) { + + Locator columnLocator = switch (columnName) { + case "Assignable to Role" -> page.locator(IDENTITY_ATTRIBUTE_LIST_ASSIGNABLE_TO_ROLE_COLUMN_LOCATOR); + case "In use" -> page.locator(IDENTITY_ATTRIBUTE_LIST_IN_USE_COLUMN_LOCATOR); + case "Action" -> page.locator(IDENTITY_ATTRIBUTE_LIST_DELETE_COLUMN_LOCATOR); + default -> throw new IllegalArgumentException("Unknown column: " + columnName); + }; + + List<String> columnValues = columnLocator.allTextContents(); + int rowSize = columnLocator.count(); + if (columnName.equals("Action")) { + for (int i = 1; i <= rowSize; i++) { + String spanValue = columnValues.get(i).trim(); + String roleValue = columnLocator.nth(i).getAttribute("role"); + assertTrue(String.format("No 'Delete' buttons found in column '%s'", columnName), "delete".equals(spanValue)); + assertTrue(String.format("The role attribute is not correct '%s'", columnName), "img".equals(roleValue)); + } + } else if (columnName.equals("Assignable to Role") || columnName.equals("In use")) { + for (String value : columnValues) { + value = value.trim(); + assertTrue(String.format("Invalid boolean value found."), "true".equals(value) || "false".equals(value)); + } + } + } } diff --git a/src/test/java/features/ui/simplOpen/Authority.feature b/src/test/java/features/ui/simplOpen/Authority.feature index b95763b8bac141b7aa46509b157affea6a22c604..96d275c4be019459cf0a0dd4f76ced2cf46749bb 100644 --- a/src/test/java/features/ui/simplOpen/Authority.feature +++ b/src/test/java/features/ui/simplOpen/Authority.feature @@ -422,16 +422,17 @@ Feature: Authority | Data Provider | | Infrastructure Provider | - @TCA28 @SIMPL-3146 @SIMPL-3148 - Scenario Outline: Displaying Boolean Value in the <columnName> Column + @TCA28 @SIMPL-3146 @SIMPL-3148 @SIMPL-3450 + Scenario Outline: Displaying the correct values in the Identity Attribute table for <columnName> column Given the user navigates to the "Identity Attributes" page And the user logs in with a user with "IATTR_M" role - Then the list displays a boolean value for each Identity Attribute in the "<columnName>" column + Then the list displays "<valueDisplayed>" for each Identity Attribute in the "<columnName>" column Examples: - | columnName | - | Assignable to Role | - | In use | + | columnName | valueDisplayed | + | Assignable to Role | a boolean value | + | In use | a boolean value | + | Action | icon delete | @TCA29 @SIMPL-3106 @SIMPL-3107 @SIMPL-3108 @SIMPL-3109 Scenario Outline: User sorts Participant List requests by <columnToSort> in <sortDirection> order @@ -471,4 +472,11 @@ Feature: Authority | The user selects 5 elements by page | 5 | | The user selects 10 elements by page | 10 | | The user selects 25 elements by page | 25 | - | The user selects 100 elements by page | 100 | \ No newline at end of file + | The user selects 100 elements by page | 100 | + + @TCA31 @SIMPL-3451 + Scenario: Confirm Deletion dialog box displays successfully. + Given the user navigates to the "Identity Attributes" page + And the user logs in with a user with "IATTR_M" role + When the user presses on the delete button + Then the dialog for the delete action is displayed successfully diff --git a/src/test/java/stepDefinitions/ui/simplOpen/AuthoritySteps.java b/src/test/java/stepDefinitions/ui/simplOpen/AuthoritySteps.java index 69ab5f01760db04259db2c9f5168ae4f1dde9d42..ed7425e67a2f3aad382ef7d054fb484753a12571 100644 --- a/src/test/java/stepDefinitions/ui/simplOpen/AuthoritySteps.java +++ b/src/test/java/stepDefinitions/ui/simplOpen/AuthoritySteps.java @@ -27,6 +27,7 @@ import static framework.ui.helpers.Utils.clickButtonByLocator; import static framework.ui.locators.simplOpen.Authority.*; import static framework.ui.pages.simplOpen.AuthorityPage.*; import static org.junit.Assert.*; +import static org.junit.Assert.assertTrue; public class AuthoritySteps { public static final DateTimeFormatter DATE_CUCUMBER_INPUT = DateTimeFormatter.ofPattern("dd/MM/yyyy"); @@ -333,6 +334,22 @@ public class AuthoritySteps { authorityPage.itemsPerPageSelectionInTableDropdown(numberValueByPage); } + @When("the access denied message is displayed") + public void theAccessDeniedMessageIsDisplayed() { + assertElementIsVisibleByLocator(page.getByText(ACCESS_DENIED)); + } + + + @When("the user clicks on the Create Identity Attribute button") + public void theUserClicksOnTheCreateIdentityAttributeButton() { + clickButtonByLocator(NEW_ATTRIBUTE_BUTTON_LOCATOR); + } + + @When("the user presses on the delete button") + public void theUserClicksOnTheDeleteIdentityAttributeButton() { + page.locator(IDENTITY_ATTRIBUTE_LIST_DELETE_COLUMN_LOCATOR).first().click(); + } + @Then("the {string} is updated with a maximum of {int} results") public void theRequestListIsUpdatedShowingAMaximumNumberOfResultsPerPage(String listType, Integer numberValueByPage) { assertElementIsVisibleByLocator(page.locator(FILTER_TABLE)); @@ -699,11 +716,6 @@ public class AuthoritySteps { authorityPage.verifyTheDatesValuesOfTheColumnWereSorted(columnToSort); } - @When("the user clicks on the Create Identity Attribute button") - public void theUserClicksOnTheCreateIdentityAttributeButton() { - clickButtonByLocator(NEW_ATTRIBUTE_BUTTON_LOCATOR); - } - @Then("the sorting button {string} is enabled") public void theSortingButtonIsEnabled(String button) { assertThat(page.getByText(button)).isEnabled(); @@ -734,31 +746,24 @@ public class AuthoritySteps { assertElementIsVisibleByLocator(page.getByText(ROLE_RESTRICTED)); } - @When("the access denied message is displayed") - public void theAccessDeniedMessageIsDisplayed() { - assertElementIsVisibleByLocator(page.getByText(ACCESS_DENIED)); - } - @Then("the user clicks the Logout button") public void theUserClicksTheLogoutButton() { clickButtonByLocator(ACCOUNT_CIRCLE_ICON); clickButtonByLocator(LOGOUT_BUTTON); } - @Then("the list displays a boolean value for each Identity Attribute in the {string} column") - public void theUsersDisplaysBooleanForEachIdentityAttributeInColumn(String columnName) { - Locator columnLocator = switch (columnName) { - case "Assignable to Role" -> page.locator(IDENTITY_ATTRIBUTE_LIST_ASSIGNABLE_TO_ROLE_COLUMN_LOCATOR); - case "In use" -> page.locator(IDENTITY_ATTRIBUTE_LIST_IN_USE_COLUMN_LOCATOR); - default -> throw new IllegalArgumentException("Unknown column: " + columnName); - }; - - List<String> columnValues = columnLocator.allTextContents(); + @Then ("the list displays {string} for each Identity Attribute in the {string} column") + public void validate_column_value_for_each_identity_attribute(String columnValue, String columnName) { + authorityPage.validateColumnValueForEachIdentityAttribute(columnName); + } - for (String value : columnValues) { - value = value.trim().toLowerCase(); - assertTrue(String.format("Invalid boolean value found"), "true".equals(value) || "false".equals(value)); - } + @Then("the dialog for the delete action is displayed successfully") + public void theDialogIsDisplayedSuccessfully() { + assertElementIsVisibleByLocator(page.locator(IDENTITY_ATTRIBUTE_LIST_DELETE_DIALOG_LOCATOR)); + assertElementIsVisibleByLocator(page.locator(IDENTITY_ATTRIBUTE_LIST_DELETE_DIALOG_TITLE_LOCATOR)); + assertElementIsVisibleByLocator(page.locator(IDENTITY_ATTRIBUTE_LIST_DELETE_DIALOG_MESSAGE_LOCATOR)); + assertElementIsVisibleByLocator(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Delete"))); + assertElementIsVisibleByLocator(page.getByRole(AriaRole.BUTTON, new Page.GetByRoleOptions().setName("Cancel"))); } @Then("the list of Identity Attributes is displayed")