hubl/cypress/integration/tests.spec.js

109 lines
5.0 KiB
JavaScript

/// <reference types="Cypress" />
context('Browser testing', () => {
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('Login process', () => {
it('should write "admin" on username field and "password" on password field', () => {
cy.get('#id_username').type('admin');
cy.get('#id_username').should('have.value', 'admin');
cy.get('#id_password').type('password');
cy.get('#id_password').should('have.value', 'password');
});
it('should click on login button', () => {
cy.get(':nth-child(1) > .flex-column > [type="submit"]').click();
});
it('should provide an error, username and password mismatch.', () => {
cy.get('.error').should('contain.text', 'Ton nom d\'utilisateur et ton mot de passe ne correspondent pas. Réessaye.')
});
it('should write "admin" on password field then press the login button', () => {
cy.get('#id_password').type('admin');
cy.get('#id_password').should('have.value', 'admin');
cy.get(':nth-child(1) > .flex-column > [type="submit"]').click();
});
it('should ask for user permission to access their datas.', () => {
cy.location().should((loc) => {
expect(loc.pathname).to.eq('/authorize')
});
cy.get('.accept-button').click();
});
// it('should redirect the user to the app.', () => {
// cy.get('.accept-button').click();
// cy.location().should((loc) => {
// expect(loc.protocol + "//" + loc.host).to.eq(Cypress.config().baseUrl);
// expect(loc.pathname).to.eq('/');
// });
// });
// });
// describe('Main interface', () => {
// // it('should show my name on top right', () => {
// // cy.get('sib-display-value').contains('Admin');
// // });
// it('should show my username on the left menu', () => {
// cy.get('[fields="username, badge"][data-src="http://localhost:8000/users/admin/"] > :nth-child(1) > sib-display-div > div').contains('admin');
// });
// it('should open a chat with myself', () => {
// cy.get('[fields="username, badge"][data-src="http://localhost:8000/users/admin/"] > :nth-child(1) > sib-display-div > div').click();
// cy.get('.name').contains('admin');
// });
// it('should not work, because I have no Prosody configured', () => {
// cy.get('.content-box > .chat-view > sib-chat').should('be.empty');
// });
// describe('Circles', () => {
// it('should navigate the Administration from left menu', () => {
// cy.get('.create > sib-link').click();
// cy.get('#admin-circles > .content-box > .content-box__header > .without-margin').contains('Administration');
// cy.get('#admin-circle-list > .content-box__info > .admin-header > .admin-header__title').contains('Circles');
// });
// it('should navigate to Circle creation', () => {
// cy.get('#admin-circle-list > .content-box__info > .admin-header > .button').click();
// cy.location().should((loc) => {
// expect(loc.pathname).to.contain('admin-circle-create');
// });
// });
// var name = new Uint32Array(1);
// crypto.getRandomValues(name);
// name = "Test Circle " + name;
// it('should allow Circle Creation', () => {
// cy.get('form > sib-form-label-text[name="name"] > label > input').type(name);
// cy.get('.content-box__info > sib-form > form > sib-form-label-text[name="description"] > label > input').type('With a great description!');
// cy.get('#admin-circle-create > .content-box__info > sib-form > form > [type="submit"]').click();
// cy.get('#admin-circle-list > div > div.table > sib-display').contains(name);
// });
// it('should open the circle information page', () => {
// cy.screenshot();
// cy.get('#navbar-router').contains(name).click();
// cy.get('[name="circle-information"] > li').click();
// });
// it('should delete the circle', () => {
// cy.get('.box-button > sib-ac-checker > .button').click();
// cy.get('#navbar-router').should('not.contain', name);
// });
// });
// });
// describe('Logout process', () => {
// it('should properly log out the user', () => {
// cy.get('#user-controls__profile > div').click();
// cy.get('#user-controls__panel > nav > button').click();
// // Dirty fix for logout, targeting logout button is not enough.
// cy.clearLocalStorage({ domain: null });
// cy.clearCookies({ domain: null });
// cy.location().should((loc) => {
// expect(loc.pathname).to.eq('/auth/login/');
// });
// });
});
});