Skip to content

Commit

Permalink
added cypress tests for file action import
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody committed Mar 4, 2024
1 parent 6226ff4 commit c717b33
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 6 deletions.
55 changes: 55 additions & 0 deletions cypress/e2e/tables-import.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
})

})
3 changes: 3 additions & 0 deletions src/modules/modals/FileActionImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:description="t('tables', 'This will create a new table from the data in this file.')">
<div style="display: flex; flex-flow: row wrap; align-items: center;">
<NcCheckboxRadioSwitch
data-cy="importAsNewTableSwitch"
:aria-label="t('tables', 'Import as new table')"
:checked.sync="importAsNew"
type="switch"
Expand Down Expand Up @@ -47,6 +48,7 @@
<div style="display: flex; flex-flow: row nowrap; margin: 20px 0;">
<NcSelect
v-model="selectedTable"
data-cy="selectExistingTableDropdown"
:options="tableOptions"
:aria-label-combobox="t('tables', 'Select the table to import into')"
:placeholder="t('tables', 'Select an existing table')"
Expand All @@ -67,6 +69,7 @@

<div class="end">
<NcButton
data-cy="fileActionImportButton"
:aria-label="t('tables', 'Import')"
type="primary"
:disabled="importingFile"
Expand Down
24 changes: 18 additions & 6 deletions src/modules/modals/ImportResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,44 @@
<tbody>
<tr>
<td>{{ t('tables', 'Found columns') }}</td>
<td>{{ results.found_columns_count }}</td>
<td data-cy="importResultColumnsFound">
{{ results.found_columns_count }}
</td>
</tr>

<tr>
<td>{{ t('tables', 'Matching columns') }}</td>
<td>{{ results.matching_columns_count }}</td>
<td data-cy="importResultColumnsMatch">
{{ results.matching_columns_count }}
</td>
</tr>

<tr>
<td>{{ t('tables', 'Created columns') }}</td>
<td>{{ results.created_columns_count }}</td>
<td data-cy="importResultColumnsCreated">
{{ results.created_columns_count }}
</td>
</tr>

<tr>
<td>{{ t('tables', 'Inserted rows') }}</td>
<td>{{ results.inserted_rows_count }}</td>
<td data-cy="importResultRowsInserted">
{{ results.inserted_rows_count }}
</td>
</tr>

<tr>
<td>{{ t('tables', 'Value parsing errors') }}</td>
<td>{{ results.errors_parsing_count }}</td>
<td data-cy="importResultParsingErrors">
{{ results.errors_parsing_count }}
</td>
</tr>

<tr>
<td>{{ t('tables', 'Row creation errors') }}</td>
<td>{{ results.errors_count }}</td>
<td data-cy="importResultRowErrors">
{{ results.errors_count }}
</td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit c717b33

Please sign in to comment.