-
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
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,5 +1,13 @@ | ||
import { generateUser } from '../support/generate'; | ||
|
||
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'); | ||
cy.get('input[placeholder="Username"]').type(user.username); | ||
cy.get('input[placeholder="Email"]').type(user.email); | ||
cy.get('input[placeholder="Password"]').type(user.password); | ||
Comment on lines
+7
to
+9
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 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('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 commentThe 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. |
||
}); | ||
}); |
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.