hubl/cypress/integration/signup.spec.js

60 lines
2.4 KiB
JavaScript

/// <reference types="Cypress" />
/* globals cy, expect */
context('Signup Browser Testing', () => {
const username = 'testuser_signup_' + Math.floor(1000 + Math.random() * 9000),
email = username + '@testemail.com',
password = 'testpwd';
before(() => {
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
it('visit the homepage', () => {
cy.visit('/');
});
it('should await for an user login', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/auth/login/');
});
});
describe('Signup process', () => {
it('should click on signup page link', () => {
cy.get('.sib-link.sib-register-link').click();
});
it('should write erroneous user data', () => {
cy.get('#id_username').type('!"#$%&');
cy.get('#id_username').should('have.value', '!"#$%&');
cy.get('#id_email').type(email.split('.')[0]);
cy.get('#id_email').should('have.value', email.split('.')[0]);
cy.get('#id_password1').type(password + 'wrong1');
cy.get('#id_password1').should('have.value', password + 'wrong1');
cy.get('#id_password2').type(password + 'wrong2');
cy.get('#id_password2').should('have.value', password + 'wrong2');
});
it('should click on signup button', () => {
cy.get('.sib-registration-btn').click();
});
it('should provide errors about erroneous user data', () => {
cy.get('tbody tr:nth-child(1) ul.errorlist li')
.should('contain.text', 'Enter a valid username. This value may contain only letters, numbers, and ./+/-/_ characters.');
cy.get('tbody tr:nth-child(2) ul.errorlist li')
.should('contain.text', 'Enter a valid email address.');
cy.get('tbody tr:nth-child(4) ul.errorlist li')
.should('contain.text', 'The two password fields didn\'t match.');
});
it('should write correct user data', () => {
cy.get('#id_username').clear().type(username);
cy.get('#id_username').should('have.value', username);
cy.get('#id_email').clear().type(email);
cy.get('#id_email').should('have.value', email);
cy.get('#id_password1').clear().type(password);
cy.get('#id_password1').should('have.value', password);
cy.get('#id_password2').clear().type(password);
cy.get('#id_password2').should('have.value', password);
});
it('should click on signup button', () => {
cy.get('.sib-registration-btn').click();
});
});
});