diff --git a/cypress/e2e/signUp.cy.js b/cypress/e2e/signUp.cy.js index 87cc96d..3df89b5 100644 --- a/cypress/e2e/signUp.cy.js +++ b/cypress/e2e/signUp.cy.js @@ -1,5 +1,26 @@ +/// +import { generateUser } from '../support/generateUser'; + +const url = 'https://react-redux.realworld.io'; + describe('Sign Up page', () => { it('should provide an ability to register new account', () => { + const user = generateUser(); + + cy.visit(url + '/#/register'); + + cy.get(`input[placeholder='Username']`) + .type(user.username); + cy.get(`input[placeholder='Email']`) + .type(user.email); + cy.get(`input[placeholder='Password']`) + .type(user.password); + + cy.get(`button[type='submit']`) + .click(); + cy.get(`a[class='nav-link']`) + .contains(user.username) + .should('exist'); }); }); diff --git a/cypress/support/generateUser.js b/cypress/support/generateUser.js new file mode 100644 index 0000000..d64d81f --- /dev/null +++ b/cypress/support/generateUser.js @@ -0,0 +1,12 @@ +import { faker } from '@faker-js/faker'; + +function generateUser() { + const randomNumber = Math.random().toString().slice(2, 6); + const username = faker.internet.userName() + '_' + randomNumber; + const email = `${username}@mail.com`; + const password = '12345Qwert!'; + + return { email, password, username }; +} + +module.exports = { generateUser };