Skip to content

Commit

Permalink
cypress tests for integer field errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Mar 13, 2020
1 parent 15719c6 commit a5772aa
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ packages/tc-ui/dist

cypress/screenshots/
cypress/videos/
cypress/fixtures/
dist/
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
populateMinimumViableFields,
save,
resetDb,
visitEditPage
} = require('../../../test-helpers/cypress');

describe('End-to-end - record Number type', () => {
Expand All @@ -16,28 +17,55 @@ describe('End-to-end - record Number type', () => {
});
});

it('can record an integer', () => {
cy.get('input[name=someInteger]').type(someInteger);
save();
describe('int', () => {

cy.get('#code').should('have.text', code);
cy.get('#someString').should('have.text', someString);
cy.get('#someInteger').should('have.text', String(someInteger));
});
it('can record an integer', () => {
cy.get('input[name=someInteger]').type(someInteger);
save();

it('can not accept non-integer value', () => {
cy.get('input[name=someInteger]').type(someInteger / 7);
save();

cy.url().should('contain', '/MainType/create');
cy.get('.o-message__content-main').should(
'contain',
'Oops. Could not create MainType record for e2e-demo',
);
cy.get('.o-message__content-additional').should(
'contain',
`Invalid value \`${someInteger /
7}\` for property \`someInteger\` on type \`MainType\`: Must be a finite integer`,
);
});
cy.get('#code').should('have.text', code);
cy.get('#someString').should('have.text', someString);
cy.get('#someInteger').should('have.text', String(someInteger));
});

it('rejects floats', () => {
cy.get('input[name=someInteger]').type('0.5');
save();

cy.url().should('contain', '/MainType/create');
cy.get('.o-message__content-main').should(
'contain',
'Oops. Could not create MainType record for e2e-demo',
);
cy.get('.o-message__content-additional').should(
'contain',
`Invalid value \`0.5\` for property \`someInteger\` on type \`MainType\`: Must be a finite integer`,
);
});

it('rejects text', () => {
cy.get('input[name=someInteger]').type('haha');
save();

cy.url().should('contain', '/MainType/create');
cy.get('.o-message__content-main').should(
'contain',
'Oops. Could not create MainType record for e2e-demo',
);
cy.get('.o-message__content-additional').should(
'contain',
`Invalid value \`haha\` for property \`someInteger\` on type \`MainType\`: Must be a finite integer`,
);
});

it('saves and redisplays zero', () => {
cy.get('input[name=someInteger]').type('0');
save();

cy.url().should('contain', '/MainType/create');
cy.get('#someInteger').should('have.text', '0');
visitEditPage()
cy.get('input[name=someInteger]').should('have.value', '0');
});
})
});

0 comments on commit a5772aa

Please sign in to comment.