-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Refactor E2E tests towards greater maintainability and robustness
- Loading branch information
1 parent
07521f5
commit 9b8b16c
Showing
18 changed files
with
571 additions
and
244 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class AccountDetailsPage { | ||
|
||
/** | ||
* @param {Keycloak} keycloak | ||
*/ | ||
constructor(keycloak) { | ||
this.keycloak = keycloak; | ||
} | ||
|
||
elements = { | ||
emailInput: () => cy.get('#email'), | ||
firstNameInput: () => cy.get('#firstName'), | ||
lastNameInput: () => cy.get('#lastName'), | ||
saveBtn: () => cy.get('button').contains('Save') | ||
} | ||
|
||
visit() { | ||
cy.intercept('GET', '/realms/master/account/**') | ||
.as("accountDetails"); | ||
cy.visit('/realms/master/account'); | ||
cy.wait('@accountDetails'); | ||
} | ||
|
||
configurePersonalInfo(email, firstName, lastName) { | ||
this.elements.emailInput().clear(); | ||
this.elements.emailInput().type(email); | ||
this.elements.firstNameInput().clear().type(firstName); | ||
this.elements.lastNameInput().clear().type(lastName); | ||
|
||
cy.intercept('POST', '/realms/master/account/**') | ||
.as("saveAccountDetails"); | ||
this.elements.saveBtn().click(); | ||
cy.wait("@saveAccountDetails"); | ||
} | ||
} | ||
|
||
module.exports = AccountDetailsPage; |
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,21 @@ | ||
class ForgotPasswordPage { | ||
elements = { | ||
userNameInput: () => cy.get('#username'), | ||
submitBtn: () => cy.get('input[type=submit]') | ||
} | ||
|
||
visit() { | ||
cy.visit('/realms/master/login-actions/reset-credentials'); | ||
} | ||
|
||
triggerPasswordReset(userEmail) { | ||
this.elements.userNameInput().clear().type(userEmail); | ||
this.elements.submitBtn().click(); | ||
cy.get('body').should('contain.text', | ||
'You should receive an email shortly with further instructions.'); | ||
cy.mhGetMailsBySubject('Reset password') | ||
.should('have.length', 1); | ||
} | ||
} | ||
|
||
module.exports = ForgotPasswordPage; |
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,23 @@ | ||
class Keycloak { | ||
|
||
elements = { | ||
userDropdown: () => cy.get('#user-dropdown'), | ||
notification: () => cy.get('.pf-c-alert__title'), | ||
accountDropdown: () => cy.get('[data-testid="options"]') | ||
} | ||
|
||
signOutViaUIAndClearCache() { | ||
this.elements.userDropdown().click() | ||
cy.get('#sign-out').get('a').contains('Sign out').click({force: true}); | ||
|
||
cy.clearAllCookies(); | ||
cy.clearAllLocalStorage(); | ||
cy.clearAllSessionStorage(); | ||
} | ||
|
||
assertIsLoggedInAsUser(userFirstName, userLastName) { | ||
this.elements.accountDropdown().should('contain', userFirstName + ' ' + userLastName); | ||
} | ||
} | ||
|
||
module.exports = Keycloak; |
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,29 @@ | ||
class LoginPage { | ||
|
||
elements = { | ||
usernameField: () => cy.get('#username'), | ||
passwordField: () => cy.get('#password'), | ||
logInBtn: () => cy.get('#kc-login'), | ||
forgotPasswordBtn: () => cy.get("a").contains("Forgot Password?") | ||
} | ||
|
||
visitForAdmin() { | ||
cy.visit('/admin'); | ||
} | ||
|
||
visitForUser() { | ||
cy.visit('/realms/master/account'); | ||
} | ||
|
||
logIn(login, password) { | ||
this.elements.usernameField().type(login); | ||
this.elements.passwordField().type(password); | ||
|
||
cy.intercept('POST', '/realms/master/login-actions/authenticate*') | ||
.as("loginSubmit"); | ||
this.elements.logInBtn().click(); | ||
cy.wait("@loginSubmit"); | ||
} | ||
} | ||
|
||
module.exports = LoginPage; |
Oops, something went wrong.