Skip to content
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

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions cypress/e2e/settings.cy.js
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();

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 the user object generated in the before hook. Ensure that the registration process uses the same user data to maintain consistency across tests.

cy.login();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cy.login() method is called here, but it is not clear if it uses the user object generated in the before hook. Ensure that the login process uses the same user data to maintain consistency across tests.

settingsPage.visit();
});

it('should provide an ability to update username', () => {

settingsPage.editUsername(user.username);
settingsPage.submitEdit();
settingsPage.verifyProfilePage(user.username);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verifyProfilePage method is called with user.username, but the default parameter in verifyProfilePage is 'riot'. Ensure that the verifyProfilePage method in settings.pageObject.js is correctly using the passed username parameter.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verifyProfilePage method is used here to verify the username update. Ensure that this method correctly checks the updated username on the profile page.

});

it('should provide an ability to update bio', () => {

settingsPage.editBio(user.bio);
settingsPage.submitEdit();

Choose a reason for hiding this comment

The 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();

Choose a reason for hiding this comment

The 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();

Choose a reason for hiding this comment

The 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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verifyLogout method is used here to verify the logout functionality. Ensure that this method correctly checks that the user is logged out.

});
});
63 changes: 63 additions & 0 deletions cypress/support/pages/settings.pageObject.js
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The editUsername method is missing the username parameter. You should pass username as an argument to this method to ensure it works correctly.

}

get bioField() {
return cy.getByDataCy('settings-bio-field');
}

editBio(bio) {
this.bioField.clear().type(bio);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The editBio method is missing the bio parameter. You should pass bio as an argument to this method to ensure it works correctly.

}

get emailField() {
return cy.getByDataCy('settings-email-field');
}

editEmail(email) {
this.emailField.clear().type(email);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The editEmail method is missing the email parameter. You should pass email as an argument to this method to ensure it works correctly.

}

get passwordField() {
return cy.getByDataCy('settings-password-field');
}

editPassword(password) {
this.passwordField.clear().type(password);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The editPassword method is missing the password parameter. You should pass password as an argument to this method to ensure it works correctly.

}

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') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verifyProfilePage method uses a default username 'riot'. Ensure that this method can accept dynamic usernames to verify the profile page for different users.

return cy.url().should('contain', `/profile/${username}`);
}

verifyLogout(username='riot') {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The verifyLogout method uses a default username 'riot'. Ensure that this method can accept dynamic usernames to verify the logout functionality for different users.

return cy.url().should('not.contain', `/profile/${username}`);
}
}

export default SettingsPageObject;