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

Add sign-up test #176

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add sign-up test #176

wants to merge 1 commit into from

Conversation

IrTur
Copy link

@IrTur IrTur commented Oct 9, 2024

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Great job on your code! 😃 It's well-written and follows Cypress best practices. However, there are some minor improvements that can be made to enhance the maintainability and readability of your code. Keep up the good work and consider these suggestions for future projects! 👍

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

describe('Sign Up page', () => {
it('should provide an ability to register new account', () => {

const user = generateUser();
cy.visit('https://react-redux.realworld.io/#/register?_k=rkc761');

Choose a reason for hiding this comment

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

The URL you are visiting is hard-coded. This can lead to maintenance issues if the URL changes in the future. Consider defining it as a constant or environment variable at the top of your tests or in a configuration file. This way, if the URL changes, you only need to update it in one place.

Comment on lines +7 to +9
cy.get('input[placeholder="Username"]').type(user.username);
cy.get('input[placeholder="Email"]').type(user.email);
cy.get('input[placeholder="Password"]').type(user.password);

Choose a reason for hiding this comment

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

The selectors you are using to target input fields are based on their placeholder text. While this works, it might break if the placeholder text changes in the future. A more robust solution would be to add data attributes in your application code and select elements based on these. This makes your tests more resilient against changes in the UI.

cy.get('input[placeholder="Email"]').type(user.email);
cy.get('input[placeholder="Password"]').type(user.password);
cy.get('button[type="submit"]').click();
cy.get('.nav-link').should('contain', user.username);

Choose a reason for hiding this comment

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

You are asserting that the username appears somewhere in the navigation bar. This test might pass even if the registration did not succeed and the username is displayed in an error message or some other context. To make the test more precise, you could assert that the username is displayed in a specific location, such as within a 'Profile' link.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants