@@ -27,20 +27,12 @@ describe('Import csv', () => {
2727 cy . get ( '.file-picker button span' ) . contains ( 'Import' ) . click ( )
2828 cy . get ( '.modal__content .import-filename' , { timeout : 5000 } ) . should ( 'be.visible' )
2929
30- cy . intercept ( { method : 'POST' , url : '**/apps/tables/import-preview/**' } ) . as ( 'importPreviewPath' )
3130 cy . get ( '.modal__content button' ) . contains ( 'Preview' ) . click ( )
32- cy . wait ( '@importPreviewPath' )
33- cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 4 )
31+ cy . get ( '.file_import__preview tbody tr' ) . should ( 'have.length' , 4 )
3432
35- cy . intercept ( { method : 'POST' , url : '**/apps/tables/import/table/*' } ) . as ( 'importUploadReq' )
33+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/import/table/*/jobs ' } ) . as ( 'importUploadReq' )
3634 cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
37- cy . wait ( '@importUploadReq' )
38- cy . get ( '[data-cy="importResultColumnsFound"]' ) . should ( 'contain.text' , '4' )
39- cy . get ( '[data-cy="importResultColumnsMatch"]' ) . should ( 'contain.text' , '4' )
40- cy . get ( '[data-cy="importResultColumnsCreated"]' ) . should ( 'contain.text' , '0' )
41- cy . get ( '[data-cy="importResultRowsInserted"]' ) . should ( 'contain.text' , '3' )
42- cy . get ( '[data-cy="importResultParsingErrors"]' ) . should ( 'contain.text' , '0' )
43- cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
35+ cy . wait ( '@importUploadReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
4436 } )
4537
4638 it ( 'Import csv from device' , ( ) => {
@@ -49,20 +41,12 @@ describe('Import csv', () => {
4941 cy . get ( '.modal__content button' ) . contains ( 'Upload from device' ) . click ( )
5042 cy . get ( 'input[type="file"]' ) . selectFile ( 'cypress/fixtures/test-import.csv' , { force : true } )
5143
52- cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload-preview/**' } ) . as ( 'importPreviewUpload' )
5344 cy . get ( '.modal__content button' ) . contains ( 'Preview' ) . click ( )
54- cy . wait ( '@importPreviewUpload' )
5545 cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 4 )
5646
57- cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload/table/*' } ) . as ( 'importUploadReq' )
47+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload/table/*/jobs ' } ) . as ( 'importUploadReq' )
5848 cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
59- cy . wait ( '@importUploadReq' )
60- cy . get ( '[data-cy="importResultColumnsFound"]' , { timeout : 20000 } ) . should ( 'contain.text' , '4' )
61- cy . get ( '[data-cy="importResultColumnsMatch"]' ) . should ( 'contain.text' , '4' )
62- cy . get ( '[data-cy="importResultColumnsCreated"]' ) . should ( 'contain.text' , '0' )
63- cy . get ( '[data-cy="importResultRowsInserted"]' ) . should ( 'contain.text' , '3' )
64- cy . get ( '[data-cy="importResultParsingErrors"]' ) . should ( 'contain.text' , '0' )
65- cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
49+ cy . wait ( '@importUploadReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
6650 } )
6751
6852 it ( 'Import csv from device with updating of existent files' , ( ) => {
@@ -84,99 +68,57 @@ describe('Import csv', () => {
8468 cy . get ( '.modal__content button' ) . contains ( 'Upload from device' ) . click ( )
8569 cy . get ( 'input[type="file"]' ) . selectFile ( 'cypress/fixtures/test-import-update.csv' , { force : true } )
8670
87- cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload-preview/**' } ) . as ( 'importPreviewUpdate' )
8871 cy . get ( '.modal__content button' ) . contains ( 'Preview' ) . click ( )
89- cy . wait ( '@importPreviewUpdate' )
9072 cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 3 )
9173
92- cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload/table/*' } ) . as ( 'importUploadReq' )
74+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload/table/*/jobs ' } ) . as ( 'importUploadReq' )
9375 cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
94- cy . wait ( '@importUploadReq' )
95- cy . get ( '[data-cy="importResultColumnsFound"]' , { timeout : 20000 } ) . should ( 'contain.text' , '2' )
96- cy . get ( '[data-cy="importResultColumnsMatch"]' ) . should ( 'contain.text' , '3' )
97- cy . get ( '[data-cy="importResultColumnsCreated"]' ) . should ( 'contain.text' , '0' )
98- cy . get ( '[data-cy="importResultRowsInserted"]' ) . should ( 'contain.text' , '0' )
99- cy . get ( '[data-cy="importResultRowsUpdated"]' ) . should ( 'contain.text' , '1' )
100- cy . get ( '[data-cy="importResultParsingErrors"]' ) . should ( 'contain.text' , '0' )
101- cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
76+ cy . wait ( '@importUploadReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
10277 } )
10378
10479} )
10580
10681describe ( 'Import csv from Files file action' , ( ) => {
107- const rowActionsButton = '[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button'
108- const importToTablesAction = '[data-cy-files-list-row-action="import-to-tables"]'
109-
110- const openImportToTablesAction = ( retries = 8 ) => {
111- cy . get ( rowActionsButton ) . click ( )
112- cy . get ( 'body' ) . then ( $body => {
113- if ( $body . find ( importToTablesAction ) . length > 0 ) {
114- cy . get ( importToTablesAction ) . first ( ) . click ( )
115- return
116- }
117-
118- if ( retries <= 0 ) {
119- throw new Error ( 'Import to Tables action did not become available in file actions menu' )
120- }
121-
122- cy . get ( 'body' ) . click ( 0 , 0 )
123- cy . wait ( 1000 )
124- openImportToTablesAction ( retries - 1 )
125- } )
126- }
12782
128- before ( function ( ) {
83+ before ( function ( ) {
12984 cy . createRandomUser ( ) . then ( user => {
13085 localUser = user
13186 cy . login ( localUser )
13287 cy . uploadFile ( 'test-import.csv' , 'text/csv' )
13388 } )
13489 } )
13590
136- beforeEach ( function ( ) {
91+ beforeEach ( function ( ) {
13792 cy . login ( localUser )
138- cy . visit ( 'apps/files/files' , { timeout : 120000 } )
139- cy . get ( '[data-cy-files-list-row-name="test-import.csv"]' , { timeout : 120000 } ) . should ( 'be.visible' )
93+ cy . visit ( 'apps/files/files' )
14094 } )
14195
14296 it ( 'Import to new table' , ( ) => {
143- openImportToTablesAction ( )
97+ cy . get ( '[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button' ) . click ( )
98+ cy . get ( '[data-cy-files-list-row-action="import-to-tables"]' ) . click ( )
14499
145100 cy . intercept ( {
146101 method : 'POST' ,
147- url : '**/apps/tables/import/table/*' ,
102+ url : '**/apps/tables/import/table/*/jobs ' ,
148103 } ) . as ( 'importNewTableReq' )
149104 cy . get ( '[data-cy="fileActionImportButton"]' ) . click ( { force : true } )
150105 cy . wait ( '@importNewTableReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
151-
152- cy . get ( '[data-cy="importResultColumnsFound"]' ) . should ( 'contain.text' , '4' )
153- cy . get ( '[data-cy="importResultColumnsMatch"]' ) . should ( 'contain.text' , '0' )
154- cy . get ( '[data-cy="importResultColumnsCreated"]' ) . should ( 'contain.text' , '4' )
155- cy . get ( '[data-cy="importResultRowsInserted"]' ) . should ( 'contain.text' , '3' )
156- cy . get ( '[data-cy="importResultParsingErrors"]' ) . should ( 'contain.text' , '0' )
157- cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
158106 } )
159107
160108 it ( 'Import to existing table' , ( ) => {
161- openImportToTablesAction ( )
109+ cy . get ( '[data-cy-files-list-row-name="test-import.csv"] [data-cy-files-list-row-actions] .action-item button' ) . click ( )
110+ cy . get ( '[data-cy-files-list-row-action="import-to-tables"]' ) . click ( )
162111
163112 cy . get ( '.modal__content [data-cy="importAsNewTableSwitch"] input' ) . uncheck ( { force : true } )
164113 cy . get ( '[data-cy="selectExistingTableDropdown"]' ) . type ( 'Welcome to Nextcloud Tables!' )
165114 cy . get ( '.name-parts' ) . click ( )
166115
167116 cy . intercept ( {
168117 method : 'POST' ,
169- url : '**/apps/tables/import/table/*' ,
118+ url : '**/apps/tables/import/table/*/jobs ' ,
170119 } ) . as ( 'importExistingTableReq' )
171120 cy . get ( '[data-cy="fileActionImportButton"]' ) . click ( { force : true } )
172121 cy . wait ( '@importExistingTableReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
173-
174- cy . get ( '[data-cy="importResultColumnsFound"]' ) . should ( 'contain.text' , '4' )
175- cy . get ( '[data-cy="importResultColumnsMatch"]' ) . should ( 'contain.text' , '4' )
176- cy . get ( '[data-cy="importResultColumnsCreated"]' ) . should ( 'contain.text' , '0' )
177- cy . get ( '[data-cy="importResultRowsInserted"]' ) . should ( 'contain.text' , '3' )
178- cy . get ( '[data-cy="importResultParsingErrors"]' ) . should ( 'contain.text' , '0' )
179- cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
180122 } )
181123
182124} )
0 commit comments