Skip to content

Commit

Permalink
test: add e2e test for row
Browse files Browse the repository at this point in the history
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
  • Loading branch information
enjeck committed Jan 8, 2024
1 parent c1ec69e commit 3c2d495
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
27 changes: 27 additions & 0 deletions cypress/e2e/tables-rows.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,31 @@ describe('Rows for a table', () => {
cy.get('.modal-container:visible').should('not.exist')
cy.get('.custom-table table').contains('Changed column value').should('not.exist')
})

it('Check mandatory fields error', () => {
cy.contains('.app-menu-entry--label', 'Tables').click()
cy.contains('button', 'Create new table').click()
cy.get('.tile').contains('ToDo').click({ force: true })
cy.get('.modal__content').should('be.visible')
cy.get('.modal__content input[type="text"]').clear().type('to do list')
cy.contains('button', 'Create table').click()

cy.get('.app-navigation-entry-link').contains('to do list').click({ force: true })
cy.get('.NcTable').contains('Create row').click({ force: true })

cy.get('[data-cy="createRowModal"] .notecard--error').should('exist')
cy.get('[data-cy="createRowSaveButton"]').should('be.disabled')
cy.get('.modal__content .slot input').first().type('My first task')
cy.get('[data-cy="createRowModal"] .notecard--error').should('not.exist')
cy.get('[data-cy="createRowSaveButton"]').should('be.enabled')
cy.get('[data-cy="createRowSaveButton"]').click()

cy.get('.app-navigation-entry-link').contains('to do list').click({ force: true })
cy.get('.custom-table table').contains('My first task').parent().parent().find('[aria-label="Edit row"]').click()
cy.get('[data-cy="editRowModal"] .notecard--error').should('not.exist')
cy.get('.modal__content .slot input').first().clear()
cy.get('[data-cy="editRowModal"] .notecard--error').should('exist')
cy.get('[data-cy="editRowSaveButton"]').should('be.disabled')

})
})
4 changes: 2 additions & 2 deletions src/modules/modals/CreateRow.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<NcModal v-if="showModal" @close="actionCancel">
<NcModal v-if="showModal" @close="actionCancel" data-cy="createRowModal">
<div class="modal__content">
<div class="row">
<div class="col-4">
Expand All @@ -24,7 +24,7 @@
{{ t('tables', 'Add more') }}
</NcCheckboxRadioSwitch>
</div>
<NcButton v-if="!localLoading" class="primary" :aria-label="t('tables', 'Save row')" :disabled="hasEmptyMandatoryRows" @click="actionConfirm()">
<NcButton v-if="!localLoading" class="primary" :aria-label="t('tables', 'Save row')" :disabled="hasEmptyMandatoryRows" @click="actionConfirm()" data-cy="createRowSaveButton">
{{ t('tables', 'Save') }}
</NcButton>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/modules/modals/EditRow.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<NcModal v-if="showModal" @close="actionCancel">
<NcModal v-if="showModal" @close="actionCancel" data-cy="editRowModal">
<div class="modal__content">
<div class="row">
<div class="col-4">
Expand Down Expand Up @@ -32,6 +32,7 @@
</NcButton>
</div>
<NcButton v-if="canUpdateData(activeElement) && !localLoading" :aria-label="t('tables', 'Save')" type="primary"
data-cy="editRowSaveButton"
:disabled="hasEmptyMandatoryRows"
@click="actionConfirm">
{{ t('tables', 'Save') }}
Expand Down

0 comments on commit 3c2d495

Please sign in to comment.