From c717b33f9ec23a5df0cb00f46a731c1cff6c052b Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Mon, 4 Mar 2024 15:01:40 -0500 Subject: [PATCH] added cypress tests for file action import Signed-off-by: Elizabeth Danzberger --- cypress/e2e/tables-import.cy.js | 55 +++++++++++++++++++++++++ src/modules/modals/FileActionImport.vue | 3 ++ src/modules/modals/ImportResults.vue | 24 ++++++++--- 3 files changed, 76 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/tables-import.cy.js b/cypress/e2e/tables-import.cy.js index c5b275a9d..e6f2c07c8 100644 --- a/cypress/e2e/tables-import.cy.js +++ b/cypress/e2e/tables-import.cy.js @@ -17,10 +17,12 @@ describe('Import csv', () => { cy.uploadFile('test-import.csv', 'text/csv') cy.loadTable('Tutorial') cy.clickOnTableThreeDotMenu('Import') + cy.get('.modal__content button').contains('Select a file').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', '4') cy.get('[data-cy="importResultColumnsCreated"]').should('contain.text', '0') @@ -30,3 +32,56 @@ describe('Import csv', () => { }) }) + +describe('Import csv from Files file action', () => { + + before(function() { + cy.createRandomUser().then(user => { + localUser = user + }) + }) + + beforeEach(function() { + cy.login(localUser) + cy.visit('apps/files/files') + cy.uploadFile('test-import.csv', 'text/csv') + }) + + it('Import to new table', () => { + cy.reload() + + cy.get('[data-cy-files-list-row-actions] .action-item button').click() + cy.get('[data-cy-files-list-row-action="import-to-tables"]').click() + cy.get('[data-cy="fileActionImportButton"]').click() + + cy.wait(5200) + + 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('Import to existing table', () => { + cy.get('[data-cy-files-list-row-actions] .action-item button').click() + cy.get('[data-cy-files-list-row-action="import-to-tables"]').click() + + cy.get('[data-cy="importAsNewTableSwitch"]').click() + cy.get('[data-cy="selectExistingTableDropdown"]').type('tutorial') + + cy.wait(3000) + + cy.get('.name-parts').click() + cy.get('[data-cy="fileActionImportButton"]').click() + + cy.get('[data-cy="importResultColumnsFound"]').should('contain.text', '4') + cy.get('[data-cy="importResultColumnsMatch"]').should('contain.text', '4') + cy.get('[data-cy="importResultColumnsCreated"]').should('contain.text', '0') + 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') + }) + +}) diff --git a/src/modules/modals/FileActionImport.vue b/src/modules/modals/FileActionImport.vue index e73983a72..072925014 100644 --- a/src/modules/modals/FileActionImport.vue +++ b/src/modules/modals/FileActionImport.vue @@ -9,6 +9,7 @@ :description="t('tables', 'This will create a new table from the data in this file.')">
{{ t('tables', 'Found columns') }} - {{ results.found_columns_count }} + + {{ results.found_columns_count }} + {{ t('tables', 'Matching columns') }} - {{ results.matching_columns_count }} + + {{ results.matching_columns_count }} + {{ t('tables', 'Created columns') }} - {{ results.created_columns_count }} + + {{ results.created_columns_count }} + {{ t('tables', 'Inserted rows') }} - {{ results.inserted_rows_count }} + + {{ results.inserted_rows_count }} + {{ t('tables', 'Value parsing errors') }} - {{ results.errors_parsing_count }} + + {{ results.errors_parsing_count }} + {{ t('tables', 'Row creation errors') }} - {{ results.errors_count }} + + {{ results.errors_count }} +