@@ -160,7 +160,7 @@ context('Document Operations', () => {
160160 . type ( '{esc}' )
161161 } )
162162
163- it ( 'should upload a document' , ( ) => {
163+ it ( 'should upload a document using drag and drop ' , ( ) => {
164164 cy . extendedFiles ( ) . then ( win => {
165165 const file = new win . ExFile ( '/' , [ new Blob ( [ 'sample text content.' ] ) ] , 'upload_test.txt' , { type : 'text/plain' } )
166166
@@ -182,6 +182,38 @@ context('Document Operations', () => {
182182 } )
183183 } )
184184
185+ it ( 'should upload a document using the upload dialog' , ( ) => {
186+ cy . writeFile ( require ( 'path' ) . resolve ( Cypress . env ( 'homedir' ) , 'upload_file_test.txt' ) , 'sample text content' ) ;
187+ cy . get ( '[node-id$=test]' )
188+ . rightclick ( )
189+ cy . get ( '[data-command="fusion.upload-document"]' )
190+ . should ( 'be.visible' )
191+ . contains ( 'Upload document(s)' )
192+ . click ( )
193+ cy . get ( '.dialogBlock .theia-Tree.theia-FileTree' )
194+ const timer = Date . now ( ) ;
195+ new Cypress . Promise ( ( resolve , reject ) => {
196+ function tick ( ) {
197+ const file = cy . $$ ( '.theia-TreeNode:contains(upload_file_test.txt)' ) ;
198+ if ( file . length ) {
199+ cy . wrap ( file [ 0 ] )
200+ . click ( { force : true } )
201+ cy . get ( '.main' ) . click ( ) ;
202+ fetchSpy . calledWithMatch ( Cypress . env ( 'API_HOST' ) + '/exist/restxqs/fusiondb/document?uri=/db/test/upload_file_test.txt' , { method : 'PUT' } )
203+ cy . get ( '[node-id$="test\\/upload_file_test.txt"]' )
204+ . should ( 'be.visible' )
205+ resolve ( ) ;
206+ } else {
207+ if ( Date . now ( ) < timer + 5000 ) {
208+ cy . get ( '.theia-FileTree.theia-FileDialog.ps .ps__rail-y' ) . click ( 'bottom' , { force : true } )
209+ cy . wait ( 100 ) . then ( tick ) ;
210+ }
211+ }
212+ }
213+ tick ( )
214+ } )
215+ } )
216+
185217 it ( 'should move a document' , ( ) => {
186218 const dataTransfer = new DataTransfer ( ) ;
187219 cy . get ( '[node-id$="test\\/test.xml"]' )
0 commit comments