Created
May 21, 2017 21:13
-
-
Save ddeath/0260c1d4f453b3ab6c3ac9ef6724c16e to your computer and use it in GitHub Desktop.
Failing tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Creating client', () => { | |
before(() => { | |
cy.login(); | |
cy.visit('http://xyz/clients') | |
cy.get('#user-app-navigation li.active') | |
.get('a'); | |
cy.get('#user-app-navigation li.active a').should('have.attr', 'href') | |
.and('include', '/clients'); | |
}) | |
it('Should show new form', () => { | |
cy.get('#new-client-li').click() | |
.url().should('contain', '/clients/new') | |
}); | |
context('Validation', () => { | |
it('No errors should be shown on pristine form', () => { | |
cy.get('#first_name-validation-box').should("not.exist"); | |
cy.get('#last_name-validation-box').should("not.exist"); | |
cy.get('#email-validation-box').should("not.exist"); | |
cy.get('#day_of_birth-validation-box').should("not.exist"); | |
cy.get('#month_of_birth-validation-box').should("not.exist"); | |
cy.get('#year_of_birth-validation-box').should("not.exist"); | |
cy.get('#sex-validation-box').should("not.exist"); | |
cy.get('#weight-validation-box').should("not.exist"); | |
cy.get('#height-validation-box').should("not.exist"); | |
}); | |
context('First name', () => { | |
it('Should error when empty', () => { | |
cy.get('#client-basic-details input[name="first_name"]').focus().blur(); | |
cy.get('#first_name-validation-box').should('exist'); | |
}); | |
it('Should pass with string', () => { | |
cy.get('#client-basic-details input[name="first_name"]').type('Janko'); | |
cy.get('#first_name-validation-box').should('not.exist'); | |
}); | |
}); | |
context('Last name', () => { | |
it('Should error when empty', () => { | |
cy.get('#client-basic-details input[name="last_name"]').focus().blur(); | |
cy.get('#last_name-validation-box').should('exist'); | |
}); | |
it('Should pass with string', () => { | |
cy.get('#client-basic-details input[name="last_name"]').type('Mrkvicka'); | |
cy.get('#last_name-validation-box').should('not.exist'); | |
}); | |
}); | |
context('Email', () => { | |
it('Should error on empty email', () => { | |
cy.get('#client-basic-details input[name="email"]').focus().blur(); | |
cy.get('#email-validation-box').should('exist'); | |
}); | |
it('Should error on non valid email', () => { | |
cy.get('#client-basic-details input[name="email"]').type('non@valid') | |
cy.get('#email-validation-box').should('exist'); | |
}); | |
it('Should pass on valid email', () => { | |
cy.get('#client-basic-details input[name="email"]').clear(); | |
cy.get('#client-basic-details input[name="email"]').type('[email protected]'); | |
cy.get('#email-validation-box').should('not.exist'); | |
}); | |
it('Should pass on valid email with long domain', () => { | |
cy.get('#client-basic-details input[name="email"]').clear(); | |
cy.get('#client-basic-details input[name="email"]').type('[email protected]'); | |
cy.get('#email-validation-box').should('not.exist'); | |
}); | |
}); | |
context('Day of birth', () => { | |
it('Should error on non valid day', () => { | |
cy.get('#client-basic-details input[name="day_of_birth"]').type('45').blur(); | |
cy.get('#day_of_birth-validation-box').should('exist'); | |
cy.get('#client-basic-details input[name="day_of_birth"]').clear().type('0'); | |
cy.get('#day_of_birth-validation-box').should('exist'); | |
}); | |
it('Should error on non numeric characters', () => { | |
cy.get('#client-basic-details input[name="day_of_birth"]').clear().type('hello'); | |
cy.get('#day_of_birth-validation-box').should('exist'); | |
cy.get('#client-basic-details input[name="day_of_birth"]').clear().type('-25'); | |
cy.get('#day_of_birth-validation-box').should('exist'); | |
}); | |
it('Should pass on valid day of birth', () => { | |
cy.get('#client-basic-details input[name="day_of_birth"]').clear().type('25'); | |
cy.get('#day_of_birth-validation-box').should('not.exist'); | |
}); | |
}); | |
context('Month of birth', () => { | |
it('Should error on non valid month', () => { | |
cy.get('#client-basic-details input[name="month_of_birth"]').type('13').blur(); | |
cy.get('#month_of_birth-validation-box').should('exist'); | |
cy.get('#client-basic-details input[name="month_of_birth"]').clear().type('0'); | |
cy.get('#month_of_birth-validation-box').should('exist'); | |
}); | |
it('Should error on non numeric characters', () => { | |
cy.get('#client-basic-details input[name="month_of_birth"]').clear().type('hello'); | |
cy.get('#month_of_birth-validation-box').should('exist'); | |
cy.get('#client-basic-details input[name="month_of_birth"]').clear().type('-5'); | |
cy.get('#month_of_birth-validation-box').should('exist'); | |
}); | |
it('Should pass on valid month of birth', () => { | |
cy.get('#client-basic-details input[name="month_of_birth"]').clear().type('5'); | |
cy.get('#month_of_birth-validation-box').should('not.exist'); | |
}); | |
}); | |
context('Year of birth', () => { | |
it('Should error on non valid year', () => { | |
cy.get('#client-basic-details input[name="year_of_birth"]').type('5113').blur(); | |
cy.get('#year_of_birth-validation-box').should('exist'); | |
cy.get('#client-basic-details input[name="year_of_birth"]').clear().type('1000'); | |
cy.get('#year_of_birth-validation-box').should('exist'); | |
}); | |
it('Should error on non numeric characters', () => { | |
cy.get('#client-basic-details input[name="year_of_birth"]').clear().type('hello'); | |
cy.get('#year_of_birth-validation-box').should('exist'); | |
cy.get('#client-basic-details input[name="year_of_birth"]').clear().type('-2010'); | |
cy.get('#year_of_birth-validation-box').should('exist'); | |
}); | |
it('Should pass on valid year of birth', () => { | |
cy.get('#client-basic-details input[name="year_of_birth"]').clear().type(Cypress.moment().year() - 10); | |
cy.get('#year_of_birth-validation-box').should('not.exist'); | |
}); | |
}); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment