hubl/cypress/integration/signup.spec.js

62 lines
2.6 KiB
JavaScript

/// <reference types="Cypress" />
/* globals cy */
context('Signup Browser Testing', () => {
let username = 'testuser_creation_',
email = '',
password = 'testpwd';
before(() => {
cy.randomNum().then(num => {
username += num;
email = username + '@testemail.com';
});
cy.clearLocalStorageSnapshot();
cy.clearLocalStorage({ domain: null });
cy.clearCookies({ domain: null });
});
it('should visit user login screen', () => cy.userLogin());
describe('Signup process', () => {
it('should click on signup page link', () => {
cy.get('.sib-link.sib-register-link').click();
});
it('should write incorrect 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 incorrect 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();
});
it('should show email confirmation dialog', () => {
cy.contains('h1.text-center', 'Un e-mail d\'activation a été envoyé.').should("exist");
cy.contains('p.text-center', 'Vérifie ta boite mail et clique sur le lien pour activer ton compte.').should("exist");
});
});
});