Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JamieBuckell
Last active May 13, 2019 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JamieBuckell/5c098e0e9b18167538d7165cbf8b21c7 to your computer and use it in GitHub Desktop.
Save JamieBuckell/5c098e0e9b18167538d7165cbf8b21c7 to your computer and use it in GitHub Desktop.
Login with speed
const states = require('../states/admin_logins.json');
Cypress.Commands.add('login', () => {
cy.request({
method: 'POST',
url: 'http://localhost:5000/api/1.0/user/auth?tenant=greatrun',
body: {
emailAddress: states.working.email,
password: states.working.password,
}
})
.then((resp) => {
window.localStorage.setItem('admin_token', resp.body.accessToken);
})
})
const states = require('../../states/admin_logins.json');
const customers = require('../../states/customer_details.json');
const url = 'http://localhost:5000';
describe('Manage Customers Procedure', function() {
beforeEach(() => {
cy.login(states.working.email, states.working.password, url, '/admin/#/dashboard');
cy.visit(url+'/admin/#/customers');
});
it(`Create Customer`, function() {
cy.visit(url+'/admin/#/customers/create');
cy.get('#firstName').type(customers.working.first_name).should('have.value', customers.working.first_name);
cy.get('#surname').type(customers.working.last_name).should('have.value', customers.working.last_name);
cy.get('#emailAddress').type(customers.working.email).should('have.value', customers.working.email);
cy.get('#dobObject').type(customers.working.dob).should('have.value', customers.working.dob);
cy.get('#genderId').select(customers.working.gender).should('contain', customers.working.gender);
cy.get('#mobileContactNumber').type(customers.working.mobile_telephone).should('have.value', customers.working.mobile_telephone);
cy.get('#postcode').type(customers.working.address_postcode).should('have.value', customers.working.address_postcode);
cy.get('#address-country').click();
cy.contains('.dropdown-item', customers.working.address_country).click();
cy.get('#address-search').click();
cy.get('#address-results').click();
cy.contains('.dropdown-item', 'My address is not here').click();
cy.get('#address-line-one').type(customers.working.address_line_1).should('have.value', customers.working.address_line_1);
cy.get('#address-line-two').type(customers.working.address_line_2).should('have.value', customers.working.address_line_2);
cy.get('#address-line-three').type(customers.working.address_line_3).should('have.value', customers.working.address_line_3);
cy.get('#address-city').type(customers.working.address_city).should('have.value', customers.working.address_city);
cy.get('.pull-right .btn-primary').should('contain', 'Create').click();
cy.get('.modal-footer .btn-primary').should('contain', 'Yes, Save').click();
cy.get('.alert > div > div').should('contain', 'New Customer was successfully created');
cy.url().should('include', '/admin/#/customers');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment