From 71a8ad1e2ec4ebce233c8c5e3115de60bb2a9852 Mon Sep 17 00:00:00 2001 From: Luka Trovic Date: Fri, 8 Mar 2024 15:48:21 +0100 Subject: [PATCH] feat: create new table from import Signed-off-by: Luka Trovic --- cypress/e2e/tables-table.cy.js | 24 +++++++++++++++++++++++- src/modules/modals/CreateTable.vue | 16 +++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/tables-table.cy.js b/cypress/e2e/tables-table.cy.js index ce9ab1bb6..fc4d6e54f 100644 --- a/cypress/e2e/tables-table.cy.js +++ b/cypress/e2e/tables-table.cy.js @@ -24,7 +24,7 @@ describe('Manage a table', () => { cy.get('.modal__content').should('be.visible') cy.get('.modal__content input[type="text"]').clear().type('to do list') cy.get('.modal__content #description-editor .tiptap.ProseMirror').type('to Do List description') - cy.contains('button', 'Create table').click() + cy.contains('button', 'Create table').scrollIntoView().click() cy.contains('button', 'Create row').should('be.visible') cy.contains('h1', 'to do list').should('be.visible') @@ -32,6 +32,28 @@ describe('Manage a table', () => { cy.contains('.paragraph-content', 'to Do List description').should('be.visible') }) + it('Create with import', () => { + cy.uploadFile('test-import.csv', 'text/csv') + cy.contains('.app-menu-entry--label', 'Tables').click() + cy.contains('button', 'Create new table').click() + cy.get('.tile').contains('Import').click({ force: true }) + cy.get('.modal__content').should('be.visible') + cy.get('.modal__content input[type="text"]').clear().type('import list') + cy.contains('button', 'Create table').scrollIntoView().click() + cy.contains('h2', 'Import').should('be.visible') + + cy.get('.modal__content button').contains('Select from Files').click() + cy.get('.file-picker__files').contains('test-import').click() + cy.get('.file-picker button span').contains('Choose test-import.csv').click() + cy.get('.modal__content button').contains('Import').click() + cy.get('[data-cy="importResultColumnsFound"]').should('contain.text', '4') + cy.get('[data-cy="importResultColumnsMatch"]').should('contain.text', '0') + cy.get('[data-cy="importResultColumnsCreated"]').should('contain.text', '4') + cy.get('[data-cy="importResultRowsInserted"]').should('contain.text', '3') + cy.get('[data-cy="importResultParsingErrors"]').should('contain.text', '0') + cy.get('[data-cy="importResultRowErrors"]').should('contain.text', '0') + }) + it('Update title And Description', () => { cy.get('.app-navigation__list').contains('to do list').click({ force: true }) cy.get('[data-cy="customTableAction"] button').click() diff --git a/src/modules/modals/CreateTable.vue b/src/modules/modals/CreateTable.vue index 1dcd7801c..cfd18fce5 100644 --- a/src/modules/modals/CreateTable.vue +++ b/src/modules/modals/CreateTable.vue @@ -45,6 +45,14 @@ :tabbable="true" @set-template="setTemplate('custom')" /> +
+ +
item.name === name) || '' this.icon = templateObject?.icon @@ -139,7 +150,7 @@ export default { } if (!this.customTitleChosen) { - if (name === 'custom') { + if (name === 'custom' || name === 'import') { this.title = '' } else { const templateObject = this.templates?.find(item => item.name === name) || '' @@ -163,6 +174,9 @@ export default { const newTableId = await this.sendNewTableToBE(this.templateChoice) if (newTableId) { await this.$router.push('/table/' + newTableId) + if (this.templateChoice === 'import') { + emit('tables:modal:import', { element: { tableId: newTableId, id: newTableId }, isView: false }) + } this.actionCancel() } }