Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
vendor/
node_modules/
cypress/screenshots
cypress/videos
composer.lock
package-lock.json
3 changes: 3 additions & 0 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"baseUrl": "http://localhost:3300"
}
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -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"
}
5 changes: 5 additions & 0 deletions cypress/integration/home_page_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('The Home Page', () => {
it('successfully loads', () => {
cy.visit('/')
})
})
113 changes: 113 additions & 0 deletions cypress/integration/login_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
describe('user login', () => {
context('using login url', () => {
beforeEach(() => {
cy.visit('/login.php');
});

it('says Burning Flipside Profile Login', () => {
cy.get('body').contains('Burning Flipside Profile Login');
});

it('when submitting empty form', () => {
cy.get('#login_main_form').children('button[type=submit]').click();
// there is no visible feedback that an error has occurred
});
});

context('using login modal', () => {
let base = new URL(Cypress.config().baseUrl).pathname;

beforeEach(() => {
cy.logout();
cy.visit('/');

cy.server();
cy.route({method: 'POST', url: base+'/api/v1/login', onAbort: () => {console.log(arguments);}}).as('authenticate');
});

it('says Burning Flipside Profile Login', () => {
cy.get('a').contains('Login').click();
cy.get('#login-dialog').contains('Login');
});

it('when submitting empty form', () => {
cy.get('a').contains('Login').click();
cy.get('#login_dialog_form').children('button[type=submit]').click();
cy.wait('@authenticate').then((xhr) => {
expect(xhr.status).to.eq(403);
cy.location().should((loc) => {
expect(loc.pathname).to.eq(base+'/login.php');
});
cy.get('body').contains('Login Failed!');
});
});

it('form can be submitted by pressing the enter key', () => {
cy.get('a').contains('Login').click();
cy.get('#login_dialog_form').children('input[name=username]').type('me@example.com{enter}');
cy.wait('@authenticate').then((xhr) => {
expect(xhr.status).to.eq(403);
// I expect there should be visible feedback that an error has occurred
// there is none
});
});

it('when submitting incomplete credentials', () => {
cy.get('a').contains('Login').click();
cy.get('#login_dialog_form').children('input[name=username]').type('gooduser');
cy.get('#login_dialog_form').children('button[type=submit]').click();
cy.wait('@authenticate').then((xhr) => {
expect(xhr.status).to.eq(403);
// I expect there should be visible feedback that an error has occurred
// there is none
});
});

it('when submitting invalid credentials', () => {
cy.get('a').contains('Login').click();
cy.wait(200); //give the dialog time to render, otherwise this sometimes types in the wrong fields
cy.get('#login_dialog_form').children('input[name=username]').type('gooduser');
cy.get('#login_dialog_form').children('input[name=password]').type('badpass');
cy.get('#login_dialog_form').children('button[type=submit]').click();
cy.wait('@authenticate').then((xhr) => {
expect(xhr.status).to.eq(403);
// I expect there should be visible feedback that an error has occurred
// there is none
});
});

it('allows login using username', () => {
cy.get('a').contains('Login').click();
cy.wait(200); //give the dialog time to render, otherwise this sometimes types in the wrong fields
cy.get('#login_dialog_form').children('input[name=username]').type('gooduser');
cy.get('#login_dialog_form').children('input[name=password]').type('goodpass');
cy.get('#login_dialog_form').children('button[type=submit]').click();
cy.wait('@authenticate').then((xhr) => {
expect(xhr.status).to.eq(200);

cy.location().should((location) => {
expect(location.pathname).to.eq(base+'/');
});

cy.get('body').contains('Logout');
});
});

it('allows login using email sddress', () => {
cy.get('a').contains('Login').click();
cy.wait(200); //give the dialog time to render, otherwise this sometimes types in the wrong fields
cy.get('#login_dialog_form').children('input[name=username]').type('good@example.org');
cy.get('#login_dialog_form').children('input[name=password]').type('goodpass');
cy.get('#login_dialog_form').children('button[type=submit]').click();
cy.wait('@authenticate').then((xhr) => {
expect(xhr.status).to.eq(200);

cy.location().should((location) => {
expect(location.pathname).to.eq(base+'/');
});

cy.get('body').contains('Logout');
});
});
});
});
21 changes: 21 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <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) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}
33 changes: 33 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ***********************************************
// 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) => { ... })
Cypress.Commands.add('logout', () => {
cy.request({
method: 'POST',
url: `/api/v1/logout`,
body: {
},
});
});
20 changes: 20 additions & 0 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ***********************************************************
// 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'

// Alternatively you can use CommonJS syntax:
// require('./commands')