-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
233 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { When, Then, Given } from "@badeball/cypress-cucumber-preprocessor"; | ||
import "../../../cypress/support/commands"; | ||
import { BASE_URL, loginAsAnUser } from "../../../cypress/support/commands"; | ||
|
||
// navigation | ||
Given("I am on {string} page", (handle: string) => { | ||
cy.url().then(($url) => { | ||
if (!$url.includes(handle)) { | ||
cy.visit(BASE_URL + "/" + handle); | ||
} | ||
}); | ||
}); | ||
|
||
// login | ||
Given("I am logged in as {string}", (username: string) => { | ||
cy.url().then(($url) => { | ||
if (!$url.includes("modern_ui")) { | ||
loginAsAnUser("admin", "Secret123"); | ||
} | ||
}); | ||
cy.get( | ||
"div.pf-c-masthead__content button span.pf-c-dropdown__toggle-text" | ||
).then(($ele) => { | ||
if ($ele.text() != username) { | ||
loginAsAnUser("admin", "Secret123"); | ||
} | ||
}); | ||
}); | ||
|
||
When( | ||
"I log in as {string} with password {string}", | ||
(username: string, password: string) => { | ||
loginAsAnUser(username, password); | ||
} | ||
); | ||
|
||
When("I logout", () => {}); | ||
|
||
// Side menu | ||
When("I open the side menu", () => { | ||
cy.get('[id="nav-toggle"]').then(($ele) => { | ||
if ($ele.attr("aria-expanded") === "false") { | ||
$ele.trigger("click"); | ||
} | ||
}); | ||
}); | ||
|
||
When("I close the side menu", () => { | ||
cy.get('[id="nav-toggle"]').then(($ele) => { | ||
if ($ele.attr("aria-expanded") === "true") { | ||
$ele.trigger("click"); | ||
} | ||
}); | ||
}); | ||
|
||
// Buttons and tabs | ||
When("I click on {string} tab", (tabText: string) => { | ||
cy.get("nav a").contains(tabText).click(); | ||
}); | ||
|
||
When("I click on {string} button", function (buttonText: string) { | ||
cy.get("button").contains(buttonText).click(); | ||
}); | ||
|
||
Then("button {string} should be enabled", function (buttonText: string) { | ||
cy.get("button").contains(buttonText).should("be.enabled"); | ||
}); | ||
|
||
Then("button {string} should be disabled", function (buttonText: string) { | ||
cy.get("button").contains(buttonText).should("be.disabled"); | ||
}); | ||
|
||
// Modals | ||
When( | ||
"in the modal dialog I click on {string} button", | ||
function (buttonText: string) { | ||
cy.get("[role=dialog] button").contains(buttonText).click(); | ||
} | ||
); | ||
|
||
When( | ||
"in the modal dialog I check {string} radio selector", | ||
(selectorText: string) => { | ||
cy.get("[role=dialog] input[type=radio]+label") | ||
.contains(selectorText) | ||
.click(); | ||
} | ||
); | ||
|
||
Then("I see {string} modal", (modalHeading: string) => { | ||
cy.get("[role=dialog] h1 span").contains(modalHeading); | ||
}); | ||
|
||
// Fields | ||
When( | ||
"I type in the field {string} text {string}", | ||
(fieldName: string, content: string) => { | ||
cy.get("[role=dialog] label") | ||
.contains(fieldName) | ||
.parent() | ||
.then(($label) => { | ||
cy.get("[name=modal-form-" + $label.attr("for") + "]").type(content); | ||
}); | ||
} | ||
); | ||
|
||
// Data tables | ||
When("I select entry {string} in the data table", (name: string) => { | ||
cy.get("tr[id=" + name + "] input[type=checkbox]").check(); | ||
}); | ||
|
||
When("I click on {string} entry in the data table", (name: string) => { | ||
cy.get("tr[id=" + name + "] a") | ||
.contains(name) | ||
.trigger("click"); | ||
}); | ||
|
||
Then("I should see {string} entry in the data table", (name: string) => { | ||
cy.get("tr[id=" + name + "]").should("be.visible"); | ||
}); | ||
|
||
Then("I should not see {string} entry in the data table", (name: string) => { | ||
cy.get("tr[id=" + name + "]").should("not.exist"); | ||
}); | ||
Then( | ||
"entry {string} should have attribute {string} set to {string}", | ||
function (name: string, column: string, value: string) { | ||
cy.get("tr[id=" + name + "] td[data-label=" + column + "]").contains(value); | ||
} | ||
); | ||
|
||
// Notifications | ||
Then( | ||
"I should see {string} alert with text {string}", | ||
(type: string, content: string) => { | ||
cy.get("div.pf-c-alert").contains(content); | ||
} | ||
); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import { When, Then, Given } from "@badeball/cypress-cucumber-preprocessor"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,63 @@ | ||
Feature: User manipulation | ||
Create, edit, delete, preserve and activate users | ||
|
||
|
||
Background: | ||
Given I am on login page | ||
When I log in as "admin" with password "Secret123" | ||
|
||
Scenario: Add a new user | ||
Given I open the side menu | ||
* I click on "Active users" tab | ||
* I close the side menu | ||
* there is only admin user active | ||
Given I am logged in as "Administrator" | ||
Given I am on "active-users" page | ||
|
||
Scenario Outline: Add a new user | ||
When I click on "Add" button | ||
* I type in the field "User login" text "testuser1" | ||
* I type in the field "First name" text "Arthur" | ||
* I type in the field "Last name" text "Dent" | ||
* I type in the field "New Password" text "ILoveKlingonPoetry42" | ||
* I type in the field "Verify password" text "ILoveKlingonPoetry42" | ||
* I type in the field "User login" text "<userLogin>" | ||
* I type in the field "First name" text "<firstName>" | ||
* I type in the field "Last name" text "<lastName>" | ||
* I type in the field "New Password" text "<password>" | ||
* I type in the field "Verify password" text "<password>" | ||
* in the modal dialog I click on "Add" button | ||
Then I should see "testuser1" entry in the data table | ||
Then I should see "<userLogin>" entry in the data table | ||
Examples: | ||
| userLogin | firstName | lastName | password | | ||
| testuser1 | Arthur | Dent | ILoveKlingonPoetry42 | | ||
| testuser2 | Banana | Bread | FishAndChips097 | | ||
| testuser3 | Cypress | Gateway | TestingIsFun73 | | ||
|
||
|
||
Scenario: Delete a user | ||
Given I should see "testuser1" entry in the data table | ||
When I select entry "testuser1" in the data table | ||
And I click on "Delete" button | ||
Then I see "Remove Active Users" modal | ||
|
||
When in the modal dialog I check "Delete" radio selector | ||
And in the modal dialog I click on "Delete" button | ||
Then I should not see "testuser1" entry in the data table | ||
|
||
Scenario: Disable a user | ||
Given I should see "testuser2" entry in the data table | ||
When I select entry "testuser2" in the data table | ||
Then button "Disable" should be enabled | ||
Then button "Enable" should be disabled | ||
|
||
When I click on "Disable" button | ||
Then I see "Disable confirmation" modal | ||
|
||
When in the modal dialog I click on "Disable" button | ||
Then I should see "testuser2" entry in the data table | ||
Then entry "testuser2" should have attribute "Status" set to "Disabled" | ||
|
||
Scenario: Re-enable a user | ||
Given I should see "testuser2" entry in the data table | ||
When I select entry "testuser2" in the data table | ||
Then button "Enable" should be enabled | ||
Then button "Disable" should be disabled | ||
|
||
When I click on "Enable" button | ||
Then I see "Enable confirmation" modal | ||
|
||
Then in the modal dialog I click on "Enable" button | ||
Then I should see "testuser2" entry in the data table | ||
Then entry "testuser2" should have attribute "Status" set to "Enabled" | ||
|
||
Scenario: Open user details | ||
Given I should see "testuser2" entry in the data table | ||
When I click on "testuser2" entry in the data table |