mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
add tests for time bound creation inside time unit view
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -13,12 +13,14 @@ If using for adding new, provide arrayFieldName.
|
||||
For editing existing row, use existingObject and editAction.
|
||||
*/
|
||||
export const EditingForm = <T extends object, ParentType extends object>({
|
||||
dataCy,
|
||||
buttonText,
|
||||
formFields,
|
||||
editAction,
|
||||
existingObject,
|
||||
arrayFieldName,
|
||||
}: {
|
||||
dataCy?: string
|
||||
buttonText: string
|
||||
formFields: EditingFormField[]
|
||||
arrayFieldName?: keyof ParentType
|
||||
@@ -48,7 +50,7 @@ export const EditingForm = <T extends object, ParentType extends object>({
|
||||
}
|
||||
|
||||
return (
|
||||
<EditingModal {...{ buttonText, onSave }}>
|
||||
<EditingModal {...{ dataCy, buttonText, onSave }}>
|
||||
<Box sx={{ display: 'flex', flexDirection: 'column', gap: '1em' }}>
|
||||
{formFields.map(field => (
|
||||
<TextField
|
||||
|
||||
@@ -82,6 +82,7 @@ export const TimeUnitTab = () => {
|
||||
{!mode.read && (
|
||||
<Box display="flex" gap={1} marginBottom={'15px'}>
|
||||
<EditingForm<TimeBound, TimeUnitDetailsType>
|
||||
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 && (
|
||||
<Box display="flex" gap={1} marginBottom={'15px'}>
|
||||
<EditingForm<TimeBound, TimeUnitDetailsType>
|
||||
dataCy="add-new-low-bound-form"
|
||||
buttonText="Add new time bound"
|
||||
formFields={formFields}
|
||||
editAction={(newLowTimeBound: TimeBound) => {
|
||||
|
||||
Reference in New Issue
Block a user