Feature/cypressio
This commit is contained in:
committed by
Jean-Baptiste Pasquier
parent
beed19cb42
commit
9df738a15f
5
cypress/fixtures/example.json
Normal file
5
cypress/fixtures/example.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
108
cypress/integration/tests.spec.js
Normal file
108
cypress/integration/tests.spec.js
Normal file
@ -0,0 +1,108 @@
|
||||
/// <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/');
|
||||
// });
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
20
cypress/plugins/index.js
Normal file
20
cypress/plugins/index.js
Normal file
@ -0,0 +1,20 @@
|
||||
/// <reference types="cypress" />
|
||||
// ***********************************************************
|
||||
// This example plugins/index.js can be used to load plugins
|
||||
//
|
||||
// You can change the location of this file or turn off loading
|
||||
// the plugins file with the 'pluginsFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/plugins-guide
|
||||
// ***********************************************************
|
||||
|
||||
// This function is called when a project is opened or re-opened (e.g. due to
|
||||
// the project's config changing)
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
module.exports = (on, config) => {
|
||||
// require('cypress-terminal-report').installPlugin(on);
|
||||
};
|
25
cypress/support/commands.js
Normal file
25
cypress/support/commands.js
Normal file
@ -0,0 +1,25 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add("login", (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
30
cypress/support/index.js
Normal file
30
cypress/support/index.js
Normal file
@ -0,0 +1,30 @@
|
||||
// ***********************************************************
|
||||
// This example support/index.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
|
||||
//require('cypress-terminal-report').installSupport();
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
Cypress.on('uncaught:exception', (err, runnable) => {
|
||||
// returning false here prevents Cypress from
|
||||
// failing the test
|
||||
console.log('Cypress detected uncaught exception', err);
|
||||
return false;
|
||||
});
|
||||
|
||||
Cypress.on('fail', () => Cypress.runner.abort())
|
Reference in New Issue
Block a user