50 lines
2.1 KiB
JavaScript
50 lines
2.1 KiB
JavaScript
/// <reference types="Cypress" />
|
|
/* globals cy, expect */
|
|
|
|
context('Create User Browser Testing', () => {
|
|
let firstName = 'First ',
|
|
lastName = 'Last ',
|
|
username = 'testuser_creation_',
|
|
email = '';
|
|
before(() => {
|
|
cy.randomNum().then(num => {
|
|
firstName += num;
|
|
lastName += num;
|
|
username += num;
|
|
email = username + '@testemail.com';
|
|
});
|
|
cy.clearLocalStorageSnapshot();
|
|
cy.clearLocalStorage({ domain: null });
|
|
cy.clearCookies({ domain: null });
|
|
});
|
|
beforeEach(() => cy.restoreLocalStorage());
|
|
afterEach(() => cy.saveLocalStorage());
|
|
it('should visit user login screen', () => cy.userLogin());
|
|
it('should login', () => cy.login());
|
|
describe('User Creation process', () => {
|
|
it('should visit the user creation screen', () => cy.naviagte('/admin/admin-users/admin-users-create'));
|
|
it('should enter correct user data', () => {
|
|
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');
|
|
});
|
|
});
|
|
it('should land newly created user on users list screen', () => {
|
|
cy.contains('solid-display-value[name="name"]', firstName + ' ' + lastName).should("exist");
|
|
cy.contains('solid-display-value[name="username"]', username).should("exist");
|
|
});
|
|
});
|
|
});
|