-
Notifications
You must be signed in to change notification settings - Fork 199
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
base: main
Are you sure you want to change the base?
Add sign-up test #176
Conversation
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.
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'); |
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 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.
cy.get('input[placeholder="Username"]').type(user.username); | ||
cy.get('input[placeholder="Email"]').type(user.email); | ||
cy.get('input[placeholder="Password"]').type(user.password); |
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 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); |
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.
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.
No description provided.