Skip to content

Commit

Permalink
Simplify cypress assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Apr 27, 2021
1 parent d6c62fe commit 9ee0e25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
Expand Up @@ -136,13 +136,7 @@ describe('<%= entityClass %> e2e test', () => {
}
_%>

<%_ if (field.fieldTypeTimed) { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).type('<%= fieldValue %>').invoke('val').should('equal', '<%= fieldValue %>');

<%_ } else if (field.fieldTypeDuration) { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).type('PT12S').should('have.value', 'PT12S');

<%_ } else if (field.fieldTypeBoolean) { _%>
<%_ if (field.fieldTypeBoolean) { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).should('not.be.checked');
cy.get(`[data-cy="<%= fieldName %>"]`).click().should('be.checked');

Expand All @@ -152,12 +146,9 @@ describe('<%= entityClass %> e2e test', () => {
<%_ } else if (fieldIsEnum) { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).select('<%= fieldValue %>');

<%_ } else if(field.fieldTypeNumeric || field.fieldTypeLocalDate) { _%>
<%_ } else if (field.fieldTypeString || field.fieldTypeNumeric || field.fieldTypeLocalDate || field.fieldTypeTimed || field.fieldTypeDuration) { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).type('<%= fieldValue %>').should('have.value', '<%= fieldValue %>');

<%_ } else if (field.fieldTypeString) { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).type('<%= fieldValue %>').invoke('val').should('eq', '<%= fieldValue %>');

<%_ } else { _%>
cy.get(`[data-cy="<%= fieldName %>"]`).type('<%= fieldValue %>').invoke('val').should('match', new RegExp('<%= fieldValue %>'));

Expand Down
3 changes: 3 additions & 0 deletions utils/field.js
Expand Up @@ -116,6 +116,9 @@ const generateFakeDataForField = (field, faker, changelogDate, type = 'csv') =>
} else {
data = undefined;
}
} else if (field.fieldType === DURATION && type === 'cypress') {
data = `PT${faker.datatype.number({ min: 1, max: 59 })}M`;

// eslint-disable-next-line no-template-curly-in-string
} else if ([INTEGER, LONG, FLOAT, '${floatType}', DOUBLE, BIG_DECIMAL, DURATION].includes(field.fieldType)) {
data = faker.datatype.number({
Expand Down

0 comments on commit 9ee0e25

Please sign in to comment.