diff --git a/cypress/e2e/timeUnit.cy.js b/cypress/e2e/timeUnit.cy.js index 7d43ac1f..ed971731 100644 --- a/cypress/e2e/timeUnit.cy.js +++ b/cypress/e2e/timeUnit.cy.js @@ -40,6 +40,55 @@ describe('Creating a time unit', () => { cy.get('[id=write-button]').should('be.disabled') }) + it('with incorrect, newly created bounds does not work', () => { + cy.visit(`/time-unit/new`) + cy.get('[id=tu_display_name-textfield]').type('Testing Time Unit Creation') + cy.get('[id=sequence-tableselection]').first().click() + cy.get('[data-cy=add-button-ALMAAsianlandmammalage]').first().click() + cy.get('[id=low_bnd-tableselection]').click() + cy.get('[data-cy=add-button-11]').first().click() + + cy.get('[data-cy=add-new-up-bound-form]').click() + cy.get('[name=b_name]').type('new upper time bound name') + cy.get('[name=b_comment]').type('test comment') + + cy.get('[name=age]').type('one') + cy.contains('Save').click() + cy.contains('Value must be a valid number') + + cy.get('[name=age]').clear() + cy.get('[name=age]').type('-2') + cy.contains('Save').click() + cy.contains('Value must be a valid number') + + cy.get('[name=age]').clear() + cy.get('[name=age]').type('0123') + cy.contains('Save').click() + cy.contains('Value must be a valid number') + + cy.get('[name=age]').clear() + cy.get('[name=age]').type('0,5') + cy.contains('Save').click() + cy.contains('Value must be a valid number') + + cy.get('[name=age]').clear() + cy.get('[name=age]').type('1') + cy.contains('Save').click() + cy.contains('Value must be a valid number').should('not.exist') + + cy.get('[id=write-button]').should('not.be.disabled') + + cy.get('[data-cy=add-new-low-bound-form]').click() + cy.get('[name=b_name]').type('new lower time bound name') + cy.get('[name=b_comment]').type('test comment') + cy.get('[name=age]').type('0.5') + cy.contains('Save').click() + + cy.contains('Upper Bound: Upper bound age has to be lower than lower bound age') + cy.contains('Lower Bound: Lower bound age has to be higher than upper bound age') + cy.get('[id=write-button]').should('be.disabled') + }) + it('with incorrect bounds does not work', () => { cy.visit(`/time-unit/new`) cy.get('[id=tu_display_name-textfield]').type('Testing Time Unit Creation') diff --git a/frontend/src/components/DetailView/common/EditingForm.tsx b/frontend/src/components/DetailView/common/EditingForm.tsx index c257e92d..c0ba3d55 100755 --- a/frontend/src/components/DetailView/common/EditingForm.tsx +++ b/frontend/src/components/DetailView/common/EditingForm.tsx @@ -13,12 +13,14 @@ If using for adding new, provide arrayFieldName. For editing existing row, use existingObject and editAction. */ export const EditingForm = ({ + dataCy, buttonText, formFields, editAction, existingObject, arrayFieldName, }: { + dataCy?: string buttonText: string formFields: EditingFormField[] arrayFieldName?: keyof ParentType @@ -48,7 +50,7 @@ export const EditingForm = ({ } return ( - + {formFields.map(field => ( { {!mode.read && ( + dataCy="add-new-up-bound-form" buttonText="Add new time bound" formFields={formFields} editAction={(newUpTimeBound: TimeBound) => { @@ -105,6 +106,7 @@ export const TimeUnitTab = () => { {!mode.read && ( + dataCy="add-new-low-bound-form" buttonText="Add new time bound" formFields={formFields} editAction={(newLowTimeBound: TimeBound) => {