diff --git a/cypress/e2e/column-selection.cy.js b/cypress/e2e/column-selection.cy.js index a8edd1c78..4b4344e2f 100644 --- a/cypress/e2e/column-selection.cy.js +++ b/cypress/e2e/column-selection.cy.js @@ -18,9 +18,6 @@ describe('Test column ' + columnTitle, () => { beforeEach(function() { cy.login(localUser) cy.visit('apps/tables') - }) - - it('Table and column setup', () => { cy.createTable(tableTitle) }) @@ -29,40 +26,34 @@ describe('Test column ' + columnTitle, () => { cy.createSelectionColumn(columnTitle, ['first option', 'second option', '👋 third option', '🤷🏻 fifths'], 'second option', true) // check if default value is set on row creation - cy.get('button').contains('Create row').click() - cy.get('.modal-container__content h2').contains('Create row').should('be.visible') - cy.get('.modal__content .title').contains(columnTitle).should('be.visible') - cy.get('.modal__content .title').click() + cy.get('[data-cy="createRowBtn"]').click() + cy.get('[data-cy="createRowModal"]').should('be.visible') + cy.get('[data-cy="createRowModal"] .title').should('be.visible') + cy.get('[data-cy="createRowModal"] .title').click() cy.get('.vs__dropdown-toggle .vs__selected span[title="second option"]').should('exist') - cy.get('button').contains('Save').click() - cy.get('.custom-table table tr td div').contains('second option').should('be.visible') + cy.get('[data-cy="createRowSaveButton"]').click() + cy.get('[data-cy="ncTable"] tr td div').contains('second option').should('be.visible') // create a row and select non default value cy.get('button').contains('Create row').click() - cy.get('.modal__content .slot input').first().click() + cy.get('[data-cy="createRowModal"] .slot input').first().click() cy.get('ul.vs__dropdown-menu li span[title="👋 third option"]').click() - cy.get('button').contains('Save').click() - cy.get('.custom-table table tr td div').contains('third option').should('be.visible') + cy.get('[data-cy="createRowSaveButton"]').click() + cy.get('[data-cy="ncTable"] tr td div').contains('third option').should('be.visible') - // delete first row - cy.get('.NcTable tr td button').first().click() - cy.get('button').contains('Delete').click() - cy.get('button').contains('I really').click() - cy.get('.custom-table table tr td div').contains('second').should('not.exist') + cy.deleteRow(0) + cy.get('[data-cy="ncTable"] tr td div').contains('second').should('not.exist') // edit second row - cy.get('.NcTable tr td button').first().click() - cy.get('.modal__content .slot input').first().click() + cy.get('[data-cy="ncTable"] [data-cy="editRowBtn"]').first().click() + cy.get('[data-cy="editRowModal"] .slot input').first().click() cy.get('ul.vs__dropdown-menu li span[title="first option"]').click() - cy.get('button').contains('Save').click() - cy.get('.custom-table table tr td div').contains('first option').should('be.visible') + cy.get('[data-cy="editRowSaveButton"]').click() + cy.get('[data-cy="ncTable"] tr td div').contains('first option').should('be.visible') - // delete first row - cy.get('.NcTable tr td button').first().click() - cy.get('button').contains('Delete').click() - cy.get('button').contains('I really').click() + cy.deleteRow(0) - cy.removeColumn(columnTitle) + cy.deleteTable(tableTitle) }) it('Test empty selection', () => { @@ -70,11 +61,11 @@ describe('Test column ' + columnTitle, () => { cy.createSelectionColumn(columnTitle, ['first option', 'second option', '👋 third option', '🤷🏻 fifths'], null, true) // check if default value is set on row creation - cy.get('button').contains('Create row').click() - cy.get('.modal-container__content h2').contains('Create row').should('be.visible') - cy.get('button').contains('Save').click() - cy.get('.custom-table table tr td div').should('exist') - cy.get('.NcTable tr td button').should('exist') + cy.get('[data-cy="createRowBtn"]').click() + cy.get('[data-cy="createRowModal"]').should('be.visible') + cy.get('[data-cy="createRowSaveButton"]').click() + cy.get('[data-cy="ncTable"] tr td div').should('exist') + cy.get('[data-cy="ncTable"] [data-cy="editRowBtn"]').should('exist') }) }) diff --git a/cypress/e2e/context.cy.js b/cypress/e2e/context.cy.js index 6363d2ef8..68c0c1ec8 100644 --- a/cypress/e2e/context.cy.js +++ b/cypress/e2e/context.cy.js @@ -112,6 +112,7 @@ describe('Manage a context', () => { // verify that context was deleted from current user cy.get(`[data-cy="navigationContextItem"]:contains("${contextTitle}")`).find('button').click({ force: true }) + cy.wait(1000) cy.get('[data-cy="navigationContextDeleteBtn"]').contains('Delete application').click({ force: true }) cy.get('[data-cy="deleteContextModal"]').should('be.visible') cy.get('[data-cy="deleteContextModal"] button').contains('Delete').click() @@ -196,7 +197,7 @@ describe('Manage a context', () => { cy.get('[data-cy="ncTable"] table').contains('first row').should('exist') cy.get('[data-cy="ncTable"] table').contains('first row').parent().parent().find('[aria-label="Edit row"]').click() cy.get('[data-cy="editRowDeleteButton"]').click() - cy.get('[data-cy="editRowEditConfirmButton"]').click() + cy.get('[data-cy="editRowDeleteConfirmButton"]').click() cy.get('[data-cy="ncTable"] table').contains('first row').should('not.exist') }) }) \ No newline at end of file diff --git a/cypress/e2e/tables-share.cy.js b/cypress/e2e/tables-share.cy.js index 0109d7050..d84f836af 100644 --- a/cypress/e2e/tables-share.cy.js +++ b/cypress/e2e/tables-share.cy.js @@ -4,6 +4,7 @@ */ let localUser let localUser2 +let tableTitle = 'Shared todo' describe('Manage a table', () => { @@ -16,32 +17,25 @@ describe('Manage a table', () => { }) }) - beforeEach(function() { - }) it('Share table', () => { cy.login(localUser) cy.visit('apps/tables') - // create table to share - cy.get('.icon-loading').should('not.exist') cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true }) cy.get('.tile').contains('ToDo').click({ force: true }) - cy.get('.modal__content input[type="text"]').clear().type('Shared todo') - cy.contains('button', 'Create table').click() - - cy.get('.app-navigation-entry-link').contains('Shared todo').click({ force: true }) - cy.get('.NcTable table tr th').last().find('button').click({ force: true }) - cy.get('.v-popper__popper.v-popper--theme-dropdown.action-item__popper.v-popper__popper--shown').contains('Share').click({ force: true }) - cy.get('.sharing input').type(localUser2.userId) - cy.wait(1000).get('.sharing input').type('{enter}') - - cy.get('h3').contains('Shares').parent().find('ul').contains(localUser2.userId).should('exist') - }) + cy.get('.modal__content input[type="text"]').clear().type(tableTitle) + cy.get('[data-cy="createTableSubmitBtn"]').scrollIntoView().click() + cy.loadTable(tableTitle) + cy.get('[data-cy="customTableAction"] button').click() + cy.get('[data-cy="dataTableShareBtn"]').click() + cy.get('[data-cy="shareFormSelect"] input').type(localUser2.userId) + cy.get(`.vs__dropdown-menu [user="${localUser2.userId}"]`).click() + cy.wait(1000) + cy.get('[data-cy="sharedWithList"]').contains(localUser2.userId).should('exist') - it('Check for shared table', () => { cy.login(localUser2) cy.visit('apps/tables') - cy.get('.app-navigation-entry-link').contains('Shared todo').should('exist') + cy.get('[data-cy="navigationTableItem"]').contains(tableTitle).should('exist') }) }) diff --git a/cypress/e2e/tables-table.cy.js b/cypress/e2e/tables-table.cy.js index 5531932e7..d12d60dfb 100644 --- a/cypress/e2e/tables-table.cy.js +++ b/cypress/e2e/tables-table.cy.js @@ -75,22 +75,14 @@ describe('Manage a table', () => { }) it('Delete', () => { - cy.get('.app-navigation__list').contains('ToDo list').click({ force: true }) - cy.get('[data-cy="customTableAction"] button').click() - cy.get('.action-button__text').contains('Edit table').click() - - cy.get('.modal-container button').contains('Delete').click() - cy.get('.modal-container button').contains('I really want to delete this table!').click() - - cy.wait(10).get('.toastify.toast-success').should('be.visible') - cy.get('.app-navigation__list').contains('to do list').should('not.exist') + cy.deleteTable('ToDo list') }) it('Transfer', () => { cy.get('.icon-loading').should('not.exist') cy.get('[data-cy="navigationCreateTableIcon"]').click({ force: true }) cy.get('.tile').contains('ToDo').click({ force: true }) - cy.get('.modal__content input[type="text"]').clear().type('test table') + cy.get('[data-cy="createTableModal"] input[type="text"]').clear().type('test table') cy.contains('button', 'Create table').click() cy.get('.app-navigation__list').contains('test table').click({ force: true }) diff --git a/cypress/e2e/view.cy.js b/cypress/e2e/view.cy.js index a5ddb2085..3f3b27f05 100644 --- a/cypress/e2e/view.cy.js +++ b/cypress/e2e/view.cy.js @@ -126,7 +126,7 @@ describe('Interact with views', () => { // Delete rows in the view cy.get('[data-cy="customTableRow"]').contains('first row').parent().parent().find('[data-cy="editRowBtn"]').click() cy.get('[data-cy="editRowModal"] [data-cy="editRowDeleteButton"]').contains('Delete').click() - cy.get('[data-cy="editRowModal"] [data-cy="editRowEditConfirmButton"]').contains('I really want to delete this row!').click() + cy.get('[data-cy="editRowModal"] [data-cy="editRowDeleteConfirmButton"]').contains('I really want to delete this row!').click() cy.get('[data-cy="editRowModal"]').should('not.exist') cy.get('[data-cy="customTableRow"]').contains('first row').should('not.exist') diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 13a02095d..b10164650 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -86,6 +86,23 @@ Cypress.Commands.add('createTable', (title) => { cy.contains('h1', title).should('be.visible') }) +Cypress.Commands.add('deleteTable', (title) => { + cy.get('[data-cy="navigationTableItem"]').contains(title).click({ force: true }) + cy.get('[data-cy="customTableAction"] button').click() + cy.get('[data-cy="dataTableEditTableBtn"]').click() + cy.get('[data-cy="editTableModal"] [data-cy="editTableDeleteBtn"]').click() + cy.get('[data-cy="editTableModal"] [data-cy="editTableConfirmDeleteBtn"]').click() + cy.wait(10).get('.toastify.toast-success').should('be.visible') + cy.get('[data-cy="navigationTableItem"]').contains('to do list').should('not.exist') +}) + + +Cypress.Commands.add('deleteRow', (rowIndex) => { + cy.get('[data-cy="ncTable"] [data-cy="editRowBtn"]').eq(rowIndex).click() + cy.get('[data-cy="editRowDeleteButton"]').click({ force: true }) + cy.get('[data-cy="editRowDeleteConfirmButton"]').click({ force: true }) +}) + Cypress.Commands.add('createView', (title) => { cy.get('[data-cy="customTableAction"] button').click() cy.get('[data-cy="dataTableCreateViewBtn"]').contains('Create view').click({ force: true }) @@ -123,6 +140,7 @@ Cypress.Commands.add('createContext', (title) => { Cypress.Commands.add('openContextEditModal', (title) => { cy.get(`[data-cy="navigationContextItem"]:contains("${title}")`).find('button').click({ force: true }) + cy.wait(1000) cy.get('[data-cy="navigationContextEditBtn"]').contains('Edit application').click({ force: true }) cy.get('[data-cy="editContextModal"]').should('be.visible') }) @@ -142,7 +160,7 @@ Cypress.Commands.add('sortTableColumn', (columnTitle, mode = 'ASC') => { }) Cypress.Commands.add('loadTable', (name) => { - cy.get('[data-cy="navigationTableItem"] a[title="' + name + '"]').click({ force: true }) + cy.get('[data-cy="navigationTableItem"] a[title="' + name + '"]').last().click({ force: true }) }) Cypress.Commands.add('getTutorialTableName', () => { diff --git a/src/modules/main/sections/DataTable.vue b/src/modules/main/sections/DataTable.vue index 633d8293e..d15f9bf83 100644 --- a/src/modules/main/sections/DataTable.vue +++ b/src/modules/main/sections/DataTable.vue @@ -13,7 +13,8 @@ -