-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #183
base: next
Are you sure you want to change the base?
solution #183
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,50 @@ | ||
/// <reference types="cypress" /> | ||
/// <reference types="../support" /> | ||
|
||
import SettingsPageObject from '../support/pages/settings.pageObject'; | ||
|
||
const settingsPage = new SettingsPageObject(); | ||
|
||
describe('Settings page', () => { | ||
before(() => { | ||
let user; | ||
|
||
before(() => { | ||
cy.task('generateUser').then((generateUser) => { | ||
user = generateUser; | ||
}); | ||
}); | ||
|
||
beforeEach(() => { | ||
|
||
cy.task('db:clear'); | ||
cy.visit('/'); | ||
cy.register(); | ||
cy.login(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
settingsPage.visit(); | ||
}); | ||
|
||
it('should provide an ability to update username', () => { | ||
|
||
settingsPage.editUsername(user.username); | ||
settingsPage.submitEdit(); | ||
settingsPage.verifyProfilePage(user.username); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
}); | ||
|
||
it('should provide an ability to update bio', () => { | ||
|
||
settingsPage.editBio(user.bio); | ||
settingsPage.submitEdit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After updating the bio, consider adding a verification step similar to the username update to ensure the bio has been updated successfully. |
||
}); | ||
|
||
it('should provide an ability to update an email', () => { | ||
|
||
settingsPage.editEmail(user.email); | ||
settingsPage.submitEdit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After updating the email, consider adding a verification step to ensure the email has been updated successfully. |
||
}); | ||
|
||
it('should provide an ability to update password', () => { | ||
|
||
settingsPage.editPassword(user.password); | ||
settingsPage.submitEdit(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After updating the password, consider adding a verification step to ensure the password has been updated successfully. |
||
}); | ||
|
||
it('should provide an ability to log out', () => { | ||
|
||
settingsPage.logoutUser(); | ||
settingsPage.verifyLogout(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import PageObject from '../PageObject'; | ||
|
||
class SettingsPageObject extends PageObject { | ||
url = '/settings'; | ||
|
||
get usernameField() { | ||
return cy.getByDataCy('settings-username-field'); | ||
} | ||
|
||
editUsername(username) { | ||
this.usernameField.clear().type(username); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
|
||
get bioField() { | ||
return cy.getByDataCy('settings-bio-field'); | ||
} | ||
|
||
editBio(bio) { | ||
this.bioField.clear().type(bio); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
|
||
get emailField() { | ||
return cy.getByDataCy('settings-email-field'); | ||
} | ||
|
||
editEmail(email) { | ||
this.emailField.clear().type(email); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
|
||
get passwordField() { | ||
return cy.getByDataCy('settings-password-field'); | ||
} | ||
|
||
editPassword(password) { | ||
this.passwordField.clear().type(password); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
} | ||
|
||
get submitBtn() { | ||
return cy.getByDataCy('settings-submit-btn'); | ||
} | ||
|
||
submitEdit() { | ||
this.submitBtn.click(); | ||
} | ||
|
||
get logoutBtn() { | ||
return cy.getByDataCy('settings-logout-btn'); | ||
} | ||
|
||
logoutUser() { | ||
this.logoutBtn.click(); | ||
} | ||
|
||
verifyProfilePage(username='riot') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
return cy.url().should('contain', `/profile/${username}`); | ||
} | ||
|
||
verifyLogout(username='riot') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
return cy.url().should('not.contain', `/profile/${username}`); | ||
} | ||
} | ||
|
||
export default SettingsPageObject; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
cy.register()
method is called here, but it is not clear if it uses theuser
object generated in thebefore
hook. Ensure that the registration process uses the same user data to maintain consistency across tests.