Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
The integration test must check the already
implemented interaction of the action buttons.

Signed-off-by: Carla Martinez <[email protected]>
  • Loading branch information
carma12 committed Jan 31, 2025
1 parent b48e0c1 commit 9ef61ff
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/features/automem_user_groups.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Feature: Automember > User group rules
Create and delete automember user group rules. Change default user group rule.

Background:
Given I am logged in as "Administrator"
Given I am on "user-group-rules" page

# Prep: Create a new user group to work with
Scenario: Create a new user group to work with
Given I am on "user-groups" page
When I click on "Add" button
* I type in the field "Group name" text "my_automember_group"
When in the modal dialog I click on "Add" button
* I should see "success" alert with text "New user group added"
Then I should see "my_automember_group" entry in the data table

# User group rules operations
Scenario: Add a new automember user group rule
Given I am on "user-group-rules" page
When I click on "Add" button
* I click in the "Automember" selector field
* I select "my_automember_group" option in the "Automember" selector
* in the modal dialog I click on "Add" button
* I should see "success" alert with text "Entry successfully added"
Then I should see "my_automember_group" entry in the data table

Scenario: Delete an automember user group rule
Given I should see "my_automember_group" entry in the data table
Then I select entry "my_automember_group" in the data table
When I click on "Delete" button
* I see "Remove auto membership rules" modal
* I should see "my_automember_group" entry in the data table
When in the modal dialog I click on "Delete" button
* I should see "success" alert with text "The selected rules have been removed successfully"
Then I should not see "my_automember_group" entry in the data table

Scenario: Set default user group rule
Given I am on "user-group-rules" page
When I click in the selector field with ID "typeahead-select-input"
* I click toolbar dropdown item "admins"
Then I see "Default user group" modal
When in the modal dialog I click on "OK" button
Then I should see "success" alert with text "Default group updated"
* in the selector with ID "typeahead-select-input" I should see option "admins" selected

# Cleanup: Delete the user group
Scenario: Delete the user group
Given I am on "user-groups" page
Given I should see "my_automember_group" entry in the data table
Then I select entry "my_automember_group" in the data table
When I click on "Delete" button
* I see "Remove user groups" modal
* I should see "my_automember_group" entry in the data table
When in the modal dialog I click on "Delete" button
* I should see "success" alert with text "User groups removed"
Then I should not see "my_automember_group" entry in the data table

15 changes: 15 additions & 0 deletions tests/features/steps/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,12 @@ When("I click in the {string} selector field", (selectorName: string) => {
.click();
});

When("I click in the selector field with ID {string}", (id: string) => {
cy.get("div.pf-v5-c-menu-toggle")
.find("div[id=" + id + "]")
.click();
});

When(
"I select {string} in the {string} form selector field",
(selection: string, selectorName: string) => {
Expand All @@ -451,6 +457,15 @@ Then(
}
);

Then(
"in the selector with ID {string} I should see option {string} selected",
(id: string, option: string) => {
cy.get("div.pf-v5-c-menu-toggle")
.find("div[id=" + id + "]")
.find("input[value='" + option + "']");
}
);

// Also works for dropdown menus
When(
"I select {string} option in the {string} selector",
Expand Down

0 comments on commit 9ef61ff

Please sign in to comment.