@@ -61,6 +61,40 @@ describe('Import csv', () => {
6161 cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
6262 } )
6363
64+ it ( 'Import csv from device with updating of existent files' , ( ) => {
65+ cy . intercept ( { method : 'GET' , url : '**/apps/tables/row/table/*' } ) . as ( 'rowsReq' )
66+
67+ cy . loadTable ( 'Welcome to Nextcloud Tables!' )
68+
69+ cy . wait ( '@rowsReq' ) . then ( ( { response } ) => {
70+ const firstRow = response . body [ 0 ]
71+ const csv = [
72+ [ 'id' , 'What' , 'How to do' ] ,
73+ [ firstRow . id , 'What (Updated)' , 'How to do (Updated)' ] ,
74+ ]
75+
76+ cy . writeFile ( 'cypress/fixtures/test-import-update.csv' , csv . map ( row => row . join ( ',' ) ) . join ( '\n' ) )
77+ } )
78+
79+ cy . clickOnTableThreeDotMenu ( 'Import' )
80+ cy . get ( '.modal__content button' ) . contains ( 'Upload from device' ) . click ( )
81+ cy . get ( 'input[type="file"]' ) . selectFile ( 'cypress/fixtures/test-import-update.csv' , { force : true } )
82+
83+ cy . get ( '.modal__content button' ) . contains ( 'Preview' ) . click ( )
84+ cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 3 )
85+
86+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload/table/*' } ) . as ( 'importUploadReq' )
87+ cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
88+ cy . wait ( '@importUploadReq' )
89+ cy . get ( '[data-cy="importResultColumnsFound"]' , { timeout : 20000 } ) . should ( 'contain.text' , '2' )
90+ cy . get ( '[data-cy="importResultColumnsMatch"]' ) . should ( 'contain.text' , '3' )
91+ cy . get ( '[data-cy="importResultColumnsCreated"]' ) . should ( 'contain.text' , '0' )
92+ cy . get ( '[data-cy="importResultRowsInserted"]' ) . should ( 'contain.text' , '0' )
93+ cy . get ( '[data-cy="importResultRowsUpdated"]' ) . should ( 'contain.text' , '1' )
94+ cy . get ( '[data-cy="importResultParsingErrors"]' ) . should ( 'contain.text' , '0' )
95+ cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
96+ } )
97+
6498} )
6599
66100describe ( 'Import csv from Files file action' , ( ) => {
0 commit comments