@@ -10,7 +10,8 @@ describe('Import csv', () => {
1010 cy . createRandomUser ( ) . then ( user => {
1111 localUser = user
1212 cy . login ( localUser )
13- cy . uploadFile ( 'test-import.csv' , 'text/csv' )
13+ cy . uploadFile ( 'test-import-small.csv' , 'text/csv' )
14+ cy . uploadFile ( 'test-import-large.csv' , 'text/csv' )
1415 } )
1516 } )
1617
@@ -19,11 +20,11 @@ describe('Import csv', () => {
1920 cy . visit ( 'apps/tables' )
2021 } )
2122
22- it ( 'Import csv from Files' , ( ) => {
23+ it ( 'Import small csv from Files' , ( ) => {
2324 cy . loadTable ( 'Welcome to Nextcloud Tables!' )
2425 cy . clickOnTableThreeDotMenu ( 'Import' )
2526 cy . get ( '.modal__content button' ) . contains ( 'Select from Files' ) . click ( )
26- cy . get ( '.file-picker__files' ) . contains ( 'test-import' ) . click ( )
27+ cy . get ( '.file-picker__files' ) . contains ( 'test-import-small ' ) . click ( )
2728 cy . get ( '.file-picker button span' ) . contains ( 'Import' ) . click ( )
2829 cy . get ( '.modal__content .import-filename' , { timeout : 5000 } ) . should ( 'be.visible' )
2930
@@ -32,7 +33,7 @@ describe('Import csv', () => {
3233 cy . wait ( '@importPreviewPath' )
3334 cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 4 )
3435
35- cy . intercept ( { method : 'POST' , url : '**/apps/tables/import/table/*' } ) . as ( 'importUploadReq' )
36+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/v2/ import/table/*' } ) . as ( 'importUploadReq' )
3637 cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
3738 cy . wait ( '@importUploadReq' )
3839 cy . get ( '[data-cy="importResultColumnsFound"]' ) . should ( 'contain.text' , '4' )
@@ -43,18 +44,36 @@ describe('Import csv', () => {
4344 cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
4445 } )
4546
46- it ( 'Import csv from device' , ( ) => {
47+ it ( 'Import large csv from Files' , ( ) => {
48+ cy . loadTable ( 'Welcome to Nextcloud Tables!' )
49+ cy . clickOnTableThreeDotMenu ( 'Import' )
50+ cy . get ( '.modal__content button' ) . contains ( 'Select from Files' ) . click ( )
51+ cy . get ( '.file-picker__files' ) . contains ( 'test-import-large' ) . click ( )
52+ cy . get ( '.file-picker button span' ) . contains ( 'Import' ) . click ( )
53+ cy . get ( '.modal__content .import-filename' , { timeout : 5000 } ) . should ( 'be.visible' )
54+
55+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/import-preview/**' } ) . as ( 'importPreviewPath' )
56+ cy . get ( '.modal__content button' ) . contains ( 'Preview' ) . click ( )
57+ cy . wait ( '@importPreviewPath' )
58+ cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 4 )
59+
60+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/v2/import/table/*' } ) . as ( 'importUploadReq' )
61+ cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
62+ cy . wait ( '@importUploadReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
63+ } )
64+
65+ it ( 'Import small csv from device' , ( ) => {
4766 cy . loadTable ( 'Welcome to Nextcloud Tables!' )
4867 cy . clickOnTableThreeDotMenu ( 'Import' )
4968 cy . get ( '.modal__content button' ) . contains ( 'Upload from device' ) . click ( )
50- cy . get ( 'input[type="file"]' ) . selectFile ( 'cypress/fixtures/test-import.csv' , { force : true } )
69+ cy . get ( 'input[type="file"]' ) . selectFile ( 'cypress/fixtures/test-import-small .csv' , { force : true } )
5170
5271 cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload-preview/**' } ) . as ( 'importPreviewUpload' )
5372 cy . get ( '.modal__content button' ) . contains ( 'Preview' ) . click ( )
5473 cy . wait ( '@importPreviewUpload' )
5574 cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 4 )
5675
57- cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload/table/*' } ) . as ( 'importUploadReq' )
76+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/v2/ importupload/table/*' } ) . as ( 'importUploadReq' )
5877 cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
5978 cy . wait ( '@importUploadReq' )
6079 cy . get ( '[data-cy="importResultColumnsFound"]' , { timeout : 20000 } ) . should ( 'contain.text' , '4' )
@@ -65,6 +84,22 @@ describe('Import csv', () => {
6584 cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
6685 } )
6786
87+ it ( 'Import large csv from device' , ( ) => {
88+ cy . loadTable ( 'Welcome to Nextcloud Tables!' )
89+ cy . clickOnTableThreeDotMenu ( 'Import' )
90+ cy . get ( '.modal__content button' ) . contains ( 'Upload from device' ) . click ( )
91+ cy . get ( 'input[type="file"]' ) . selectFile ( 'cypress/fixtures/test-import-large.csv' , { force : true } )
92+
93+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload-preview/**' } ) . as ( 'importPreviewUpload' )
94+ cy . get ( '.modal__content button' ) . contains ( 'Preview' ) . click ( )
95+ cy . wait ( '@importPreviewUpload' )
96+ cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 4 )
97+
98+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/v2/importupload/table/*' } ) . as ( 'importUploadReq' )
99+ cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
100+ cy . wait ( '@importUploadReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
101+ } )
102+
68103 it ( 'Import csv from device with updating of existent files' , ( ) => {
69104 cy . intercept ( { method : 'GET' , url : '**/apps/tables/row/table/*' } ) . as ( 'rowsReq' )
70105
@@ -89,7 +124,7 @@ describe('Import csv', () => {
89124 cy . wait ( '@importPreviewUpdate' )
90125 cy . get ( '.file_import__preview tbody tr' , { timeout : 20000 } ) . should ( 'have.length' , 3 )
91126
92- cy . intercept ( { method : 'POST' , url : '**/apps/tables/importupload/table/*' } ) . as ( 'importUploadReq' )
127+ cy . intercept ( { method : 'POST' , url : '**/apps/tables/v2/ importupload/table/*' } ) . as ( 'importUploadReq' )
93128 cy . get ( '.modal__content button' ) . contains ( 'Import' ) . click ( )
94129 cy . wait ( '@importUploadReq' )
95130 cy . get ( '[data-cy="importResultColumnsFound"]' , { timeout : 20000 } ) . should ( 'contain.text' , '2' )
@@ -104,10 +139,9 @@ describe('Import csv', () => {
104139} )
105140
106141describe ( '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'
108142 const importToTablesAction = '[data-cy-files-list-row-action="import-to-tables"]'
109-
110- const openImportToTablesAction = ( retries = 8 ) => {
143+ const openImportToTablesAction = ( file , retries = 8 ) => {
144+ const rowActionsButton = `[data-cy-files-list-row-name=" ${ file } "] [data-cy-files-list-row-actions] .action-item button`
111145 cy . get ( rowActionsButton ) . click ( )
112146 cy . get ( 'body' ) . then ( $body => {
113147 if ( $body . find ( importToTablesAction ) . length > 0 ) {
@@ -116,35 +150,37 @@ describe('Import csv from Files file action', () => {
116150 }
117151
118152 if ( retries <= 0 ) {
119- throw new Error ( ' Import to Tables action did not become available in file actions menu' )
153+ throw new Error ( ` Import to Tables action did not become available in file actions menu for file: ${ file } ` )
120154 }
121155
122156 cy . get ( 'body' ) . click ( 0 , 0 )
123157 cy . wait ( 1000 )
124- openImportToTablesAction ( retries - 1 )
158+ openImportToTablesAction ( file , retries - 1 )
125159 } )
126160 }
127161
128162 before ( function ( ) {
129163 cy . createRandomUser ( ) . then ( user => {
130164 localUser = user
131165 cy . login ( localUser )
132- cy . uploadFile ( 'test-import.csv' , 'text/csv' )
166+ cy . uploadFile ( 'test-import-small.csv' , 'text/csv' )
167+ cy . uploadFile ( 'test-import-large.csv' , 'text/csv' )
133168 } )
134169 } )
135170
136171 beforeEach ( function ( ) {
137172 cy . login ( localUser )
138173 cy . visit ( 'apps/files/files' , { timeout : 120000 } )
139- cy . get ( '[data-cy-files-list-row-name="test-import.csv"]' , { timeout : 120000 } ) . should ( 'be.visible' )
174+ cy . get ( '[data-cy-files-list-row-name="test-import-small.csv"]' , { timeout : 120000 } ) . should ( 'be.visible' )
175+ cy . get ( '[data-cy-files-list-row-name="test-import-large.csv"]' , { timeout : 120000 } ) . should ( 'be.visible' )
140176 } )
141177
142- it ( 'Import to new table' , ( ) => {
143- openImportToTablesAction ( )
178+ it ( 'Import small file to new table' , ( ) => {
179+ openImportToTablesAction ( 'test-import-small.csv' )
144180
145181 cy . intercept ( {
146182 method : 'POST' ,
147- url : '**/apps/tables/import/table/*' ,
183+ url : '**/apps/tables/v2/ import/table/*' ,
148184 } ) . as ( 'importNewTableReq' )
149185 cy . get ( '[data-cy="fileActionImportButton"]' ) . click ( { force : true } )
150186 cy . wait ( '@importNewTableReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
@@ -157,16 +193,27 @@ describe('Import csv from Files file action', () => {
157193 cy . get ( '[data-cy="importResultRowErrors"]' ) . should ( 'contain.text' , '0' )
158194 } )
159195
160- it ( 'Import to existing table' , ( ) => {
161- openImportToTablesAction ( )
196+ it ( 'Import large file to new table' , ( ) => {
197+ openImportToTablesAction ( 'test-import-large.csv' )
198+
199+ cy . intercept ( {
200+ method : 'POST' ,
201+ url : '**/apps/tables/v2/import/table/*' ,
202+ } ) . as ( 'importNewTableReq' )
203+ cy . get ( '[data-cy="fileActionImportButton"]' ) . click ( { force : true } )
204+ cy . wait ( '@importNewTableReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
205+ } )
206+
207+ it ( 'Import small file to existing table' , ( ) => {
208+ openImportToTablesAction ( 'test-import-small.csv' )
162209
163210 cy . get ( '.modal__content [data-cy="importAsNewTableSwitch"] input' ) . uncheck ( { force : true } )
164211 cy . get ( '[data-cy="selectExistingTableDropdown"]' ) . type ( 'Welcome to Nextcloud Tables!' )
165212 cy . get ( '.name-parts' ) . click ( )
166213
167214 cy . intercept ( {
168215 method : 'POST' ,
169- url : '**/apps/tables/import/table/*' ,
216+ url : '**/apps/tables/v2/ import/table/*' ,
170217 } ) . as ( 'importExistingTableReq' )
171218 cy . get ( '[data-cy="fileActionImportButton"]' ) . click ( { force : true } )
172219 cy . wait ( '@importExistingTableReq' ) . its ( 'response.statusCode' ) . should ( 'equal' , 200 )
0 commit comments