80 lines
3.5 KiB
JavaScript
80 lines
3.5 KiB
JavaScript
/// <reference types="Cypress" />
|
|
/* globals cy, expect */
|
|
|
|
context('Creat User Browser Testing', () => {
|
|
const firstName = 'First',
|
|
lastName = 'Last',
|
|
username = 'testuser_creation_' + Math.floor(1000 + Math.random() * 9000),
|
|
email = username + '@testemail.com';
|
|
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('User Creation process', () => {
|
|
it('should login', () => {
|
|
cy.get('#id_username').type('admin');
|
|
cy.get('#id_username').should('have.value', 'admin');
|
|
cy.get('#id_password').type('admin');
|
|
cy.get('#id_password').should('have.value', 'admin');
|
|
cy.get('.connection-btn').click();
|
|
cy.get('.accept-button').click();
|
|
cy.location().should((loc) => {
|
|
expect(loc.pathname).to.eq('/');
|
|
});
|
|
});
|
|
it('should visit the user creation screen', () => {
|
|
cy.visit('/admin/admin-users/admin-users-create');
|
|
cy.location().should((loc) => {
|
|
expect(loc.pathname).to.eq('/admin/admin-users/admin-users-create');
|
|
});
|
|
// Workaround - seems to be a bug when accessing the route directly
|
|
cy.get('.accept-button').click();
|
|
// End workaround
|
|
});
|
|
/*it('should enter erroneous user data and submit', () => {
|
|
cy.get('#admin-users-create input[name="first_name"]').type(firstName);
|
|
cy.get('#admin-users-create input[name="first_name"]').should('have.value', firstName);
|
|
cy.get('#admin-users-create input[name="last_name"]').type(lastName);
|
|
cy.get('#admin-users-create input[name="last_name"]').should('have.value', lastName);
|
|
cy.get('#admin-users-create input[name="username"]').type('!"#$%&');
|
|
cy.get('#admin-users-create input[name="username"]').should('have.value', '!"#$%&');
|
|
cy.get('#admin-users-create input[name="email"]').type(email.split('.')[0]);
|
|
cy.get('#admin-users-create input[name="email"]').should('have.value', email.split('.')[0]);
|
|
});
|
|
it('should click on create user button', () => {
|
|
cy.get('#admin-users-create input[type="submit"]').click();
|
|
});
|
|
it('should provide errors about erroneous user data', () => {
|
|
// TO-DO: Check for error messages
|
|
cy.get('element')
|
|
.should('contain.text', 'Error message.');
|
|
});*/
|
|
it('should enter user data and submit', () => {
|
|
cy.get('#admin-users-create input[name="first_name"]').clear().type(firstName);
|
|
cy.get('#admin-users-create input[name="first_name"]').should('have.value', firstName);
|
|
cy.get('#admin-users-create input[name="last_name"]').clear().type(lastName);
|
|
cy.get('#admin-users-create input[name="last_name"]').should('have.value', lastName);
|
|
cy.get('#admin-users-create input[name="username"]').clear().type(username);
|
|
cy.get('#admin-users-create input[name="username"]').should('have.value', username);
|
|
cy.get('#admin-users-create input[name="email"]').clear().type(email);
|
|
cy.get('#admin-users-create input[name="email"]').should('have.value', email);
|
|
});
|
|
it('should click on create user button', () => {
|
|
cy.get('#admin-users-create input[type="submit"]').click();
|
|
});
|
|
it('should land on users list screen', () => {
|
|
cy.location().should((loc) => {
|
|
expect(loc.pathname).to.eq('/admin/admin-users');
|
|
});
|
|
});
|
|
});
|
|
});
|