diff --git a/cypress/e2e/signUp.cy.js b/cypress/e2e/signUp.cy.js index 87cc96d..7cc1210 100644 --- a/cypress/e2e/signUp.cy.js +++ b/cypress/e2e/signUp.cy.js @@ -1,5 +1,22 @@ +import { generateUser } from '../support/commands'; describe('Sign Up page', () => { it('should provide an ability to register new account', () => { + const { username, email, password } = generateUser(); + cy.visit('https://react-redux.realworld.io/#/register'); + cy.get('[placeholder="Username"]') + .type(username); + + cy.get('[placeholder="Email"]') + .type(email); + + cy.get('[placeholder="Password"]') + .type(password); + + cy.contains('button', 'Sign in') + .click(); + + cy.get('a.nav-link') + .should('contain', username); }); }); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 119ab03..8e8ccf6 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -23,3 +23,15 @@ // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) +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 };